Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Upgrade controller-runtime from v0.2.2 to v0.5.0 and its dependencies. #504

Merged
merged 1 commit into from
Mar 9, 2020

Conversation

sophieliu15
Copy link
Contributor

@sophieliu15 sophieliu15 commented 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 #488).

Notice that in v0.5.0, when the GVK does not exist, the controller-runtime manager will create an object reconciler without failure. Instead, the object reconciler and manager will terminate after starting the object reconciler. This is expected (see kubernetes-sigs/controller-runtime#840). We will address this issue in a follow-up PR by explicitly checking if a GVK exists before creating the corresponding object reconciler.

This PR also solved following incompatibility issues caused by controller-runtime upgrade:

  • Upgrade go version in go.mod and Dockerfile to 1.13. The errors.As in dynamicrestmapper.go 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 after k8s.io/apimachinery 1.16 (see here, and here)
  • Default LeaderElectionID in controller-runtime manager is removed after ⚠️ Remove defaulting for leader election ID kubernetes-sigs/controller-runtime#446.
  • NewlineReporter is moved from sigs.k8s.io/controller-runtime/pkg/envtest/ to https://godoc.org/sigs.k8s.io/controller-runtime/pkg/envtest/printer by this commit.
  • Upgrade controller-tools/cmd/controller-gen in ci-test.sh because we upgraded k8s.io/api to v0.17.3 which did not have Webhook in v1beta1. If we do not upgrade controller-gen, we will get error undefined: v1beta1.Webhook in [email protected] in pull-hnc-test.
  • Upgrade kustomize in ci-test.sh because otherwise it will downgrade k8s.io/client-go to v11.0.0, which will cause an error not enough arguments in call to watch.NewStreamWatcher from rest/request.go:598:31 in pull-hnc-test

Tested:

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

This partly solve: #488

@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 Mar 6, 2020
@sophieliu15
Copy link
Contributor Author

@yiqigao217 Feel free to take a look.

@sophieliu15
Copy link
Contributor Author

/retest

@k8s-ci-robot
Copy link
Contributor

@sophieliu15: GitHub didn't allow me to assign the following users: cancel.

Note that only kubernetes-sigs members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @adrianludwin cancel

Got errors:

# sigs.k8s.io/controller-tools/pkg/webhook
/home/prow/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/webhook/parser.go:98:29: undefined: v1beta1.Webhook
/home/prow/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/webhook/parser.go:129:9: undefined: v1beta1.Webhook
/home/prow/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/webhook/parser.go:161:21: undefined: v1beta1.Webhook
/home/prow/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/webhook/parser.go:162:23: undefined: v1beta1.Webhook
make: *** [Makefile:123: controller-gen] Error 2

Looks like we might need to update kubebuilder in hack/ci-test.sh to make it work (from a comment here). I am still experimenting to see if it works. I will try to unassign (not sure if this works) you first.

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 size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 6, 2020
@sophieliu15
Copy link
Contributor Author

/test pull-hnc-test

@sophieliu15 sophieliu15 force-pushed the crd_issue branch 5 times, most recently from e01d127 to 7ea29e2 Compare March 7, 2020 00:24
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Mainly a bunch of questions. One general comment - we're upgrading a bunch of things, not just controller-runtime, so maybe let's make the title of the commit and PR more general (e.g. "Upgrade golang, controller-runtime and other dependencies").

incubator/hnc/Dockerfile Show resolved Hide resolved
incubator/hnc/go.mod Show resolved Hide resolved
incubator/hnc/go.mod Outdated Show resolved Hide resolved
incubator/hnc/hack/ci-test.sh Outdated Show resolved Hide resolved
incubator/hnc/pkg/reconcilers/hnc_config.go Outdated Show resolved Hide resolved
@sophieliu15
Copy link
Contributor Author

sophieliu15 commented Mar 9, 2020

Mainly a bunch of questions. One general comment - we're upgrading a bunch of things, not just controller-runtime, so maybe let's make the title of the commit and PR more general (e.g. "Upgrade golang, controller-runtime and other dependencies").

@adrianludwin

The reason we upgraded everything else except controller-runtime was because we upgraded controller-runtime. How about "Upgrade controller-runtime and its dependencies"?

@sophieliu15 sophieliu15 changed the title Upgrade controller-runtime from v0.2.2 to v0.5.0. Upgrade controller-runtime from v0.2.2 to v0.5.0 and its dependencies. Mar 9, 2020
@adrianludwin
Copy link
Contributor

The reason we upgraded everything else except controller-runtime was because we upgraded controller-runtime. How about "Upgrade controller-runtime and its dependencies"?

The new title looks good

@sophieliu15 sophieliu15 force-pushed the crd_issue branch 3 times, most recently from 28e54a5 to 99e1b7e Compare March 9, 2020 18:01
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
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

This is just an infra change so no need to bug Ryan.

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 9, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, sophieliu15

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2020
@k8s-ci-robot k8s-ci-robot merged commit f9ddc6d into kubernetes-retired:master Mar 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 Indicates that a PR is ready to be merged. 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.

3 participants