Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ DynamicRESTMapper that reloads on REST cache miss #554

Merged
merged 4 commits into from
Oct 10, 2019

Conversation

estroz
Copy link
Contributor

@estroz estroz commented Aug 8, 2019

pkg/client/apiutil: DynamicRESTMapper will reload the delegated meta.RESTMapper on a cache miss. API calls are rate-limited by a token bucket, and will return an ErrRateLimited containing a time.Duration signifying a wait time.

See operator-framework/operator-sdk#1329 for a discussion of why reloading on a cache miss is desirable.

Discussion points:

  • Any API changes needed.
  • How we want to rate limit, and what we want UX to look like.
  • Changes needed in other packages.

Closes #321

/cc @DirectXMan12 @mengqiy @joelanford @hasbro17

@k8s-ci-robot
Copy link
Contributor

@estroz: GitHub didn't allow me to request PR reviews from the following users: joelanford, hasbro17.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

pkg/client/apiutil: DynamicRESTMapper will reload the delegated meta.RESTMapper on a cache miss. API calls are rate-limited by a token bucket, and will return an ErrRateLimited containing a time.Duration signifying a wait time.

See operator-framework/operator-sdk#1329 for a discussion of why reloading on a cache miss is desirable.

Discussion points:

  • Any API changes needed.
  • How we want to rate limit, and what we want UX to look like.
  • Changes needed in other packages.

/cc @DirectXMan12 @mengqiy @joelanford @hasbro17

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 8, 2019
@DirectXMan12
Copy link
Contributor

Awesome, doing a review now, but from the description this seems to cover most of what I want.

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bunch of nits inline.

Also: in general, we try to have Godoc on private functions and methods (I've seen non-obviously-named private methods enough in k/k that it's easier just to have a blanket policy)

pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of minor comments, otherwise LGTM

pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Show resolved Hide resolved
pkg/manager/manager.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
@estroz estroz force-pushed the dynamic-restmapper branch 2 times, most recently from 1c617f5 to 6d7d994 Compare August 9, 2019 21:55
Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit, otherwise sqaush into logical commits and I'll approve

pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Show resolved Hide resolved
pkg/client/apiutil/dynamicrestmapper.go Outdated Show resolved Hide resolved
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 6, 2020
Reason for upgrade:
The new version uses [DynamicRESTMapper](https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/client/apiutil/dynamicrestmapper.go) as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR:

- Upgrade go version in `go.mod` and `Dockerfile` to 1.13. The [errors.As](https://golang.org/pkg/errors/#As) in [dynamicrestmapper.go](https://github.com/kubernetes-sigs/controller-runtime/blob/bfc982769615817ee15db8a543662652d900d27b/pkg/client/apiutil/dynamicrestmapper.go#L48) requires go 1.13.
- A higher version for k8s.io/cli-runtime and k8s.io/client-go are required after upgrading controller-runtime to v0.5.0
- Version changes of other packages in `go.mod` are updated automatically.
- serializer.DirectCodecFactory was renamed to [serializer.WithoutConversionCodecFactory](https://godoc.org/k8s.io/apimachinery/pkg/runtime/serializer#WithoutConversionCodecFactory) after k8s.io/apimachinery 1.16 (see [here](kubernetes/apimachinery@ed8af17), and [here](kubernetes/apimachinery@4fac835))
- Default [LeaderElectionID](https://github.com/kubernetes-sigs/controller-runtime/blob/bfc982769615817ee15db8a543662652d900d27b/pkg/leaderelection/leader_election.go#L46) in controller-runtime manager is removed after kubernetes-sigs/controller-runtime#446.
- [NewlineReporter](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/envtest/printer) is moved from `sigs.k8s.io/controller-runtime/pkg/envtest/` to `https://godoc.org/sigs.k8s.io/controller-runtime/pkg/envtest/printer` by [this](kubernetes-sigs/controller-runtime@748f55d#diff-42de1d59fbe8f8b90154f01dd01f5748) commit.
- In controller-runtime v0.2.2, if a resource does not exist, a
controller cannot be created successfully. After update
controller-runtime to v0.5.0, a controller can be created without error.
However, when the `Reconcile` method is triggered, there will be an
error complaining the resource does not exist. Therefore, we will
explicitly check if a resource exists before creating the corresponding
object reconciler in `createObjectReconciler` in `hnc_config.go` (see
details in kubernetes-sigs/controller-runtime#840)

Tested:

- Unit tests.
- Went through [demo script](https://docs.google.com/document/d/1tKQgtMSf0wfT3NOGQx9ExUQ-B8UkkdVZB6m4o3Zqn64/edit#) to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 6, 2020
Reason for upgrade:
The new version uses [DynamicRESTMapper](https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/client/apiutil/dynamicrestmapper.go) as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through [demo script](https://docs.google.com/document/d/1tKQgtMSf0wfT3NOGQx9ExUQ-B8UkkdVZB6m4o3Zqn64/edit#) to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 6, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 6, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 6, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 6, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 7, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 7, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 7, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 7, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.
- Manually test if the PR solves the restart problem as described in kubernetes-retired#488 with following workflow:
     - Install HNC
     - Install a new CRD
     - Config the new type in `config` singleton

Before this PR, corresponding object reconciler for the new type will not be created unless we restart HNC. After the change, corresponding object reconciler can be created and it reconciles objects of the new type as expected without restarting HNC.

This partly solve:  kubernetes-retired#488
sophieliu15 added a commit to sophieliu15/multi-tenancy that referenced this pull request Mar 9, 2020
Reason for upgrade:
The new version uses DynamicRESTMapper as default `RESTMapper` for controller runtime manager. `DynamicRESTMapper` will "reload the delegated `meta.RESTMapper` on a cache miss" (see kubernetes-sigs/controller-runtime#554), which can solve problem that we need to restart HNC after adding a new CRD to create corresponding object reconciler when using controller-runtime v0.2.2 (see details in kubernetes-retired#488).

Incompatibility issues addressed in this PR: see PR description

Tested:

- Unit tests.
- Went through demo script to make sure HNC behaves as expected on a GKE cluster.

This partly solve:  kubernetes-retired#488
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RESTMapper doesn't update to reflect new CRDs
7 participants