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

Bug 1997811: Bump k8s and controller-runtime dependencies to v0.21.x and v0.9.x #419

Merged

Conversation

timflannagan
Copy link
Contributor

@timflannagan timflannagan commented Aug 20, 2021

Overview

The marketplace operator is currently building and testing with an older Kubernetes version (v0.20.6) of clients and APIs. This can pose a maintenance burden going forward as we'll be deploying the marketplace operator using an unmaintained Kubernetes minor version as we progress future in the 4.x OCP lifecycle, and upgrading to OCP 4.9 will be needed for upgrading from EUS to EUS. Simply upgrading the controller runtime and k8s.io dependencies to a more recent (v0.21.x, v0.22.x) versions and making the requisite code changes is not possible as we're parking on a stale v0.19.x operator-sdk version. Currently, the marketplace operator uses the operator-sdk testing harness, which was deprecated in v0.19.x and removed entirely in v1.x in favor of controller runtime's envtest implementation. The operator-sdk testing harness is not compatible with client function signatures changes in controller-runtimes v0.7.x release, and bumping the operator-sdk dependency to a supported v1.x version involves several breaking changes. This PR is centered around the removal of the operator-sdk dependency entirely, replacing any direct package imports, and removing the testing harness entirely.

Minor Changes

  • Various unused packages have been removed.
  • The root list of CVO manifests have been regenerated.
  • Avoid disabling module support (GO111MODULE=off) when building the marketplace operator binary in the build/build.sh bash script.
  • Move the scripts/update-manifests.sh bash script to hack.
  • Avoid registering the v1beta1 CRD scheme in the main executable package.

Notable Changes

Avoid manually vendoring the OLM API types

#329 introduced these manually vendored APIs as the operator-sdk version at the time didn't support Go modules.

This removes those vendored packages in favor of the operator-framework/api dependency, which currently houses the CatalogSource type definitions the marketplace operator needs.

Any existing package imports in the code base are replaced to use the v0.10.5 api dependency instead of the (now) deleted manually vendored API packages.

Handle controller runtime v0.7.x breaking changes

The controller-runtime v0.7.x release introduced a couple of breaking changes:

  • mgr.Start(...) now takes a context.Context as a parameter instead of a stop channel.
  • Any Reconcile method now takes a context.Context parameter.
  • Any function or methods that passes around a runtime.Object needs to be updated to instead handle a client.Object and client.ObjectList instead.

Removing the operator-sdk dependency

Any code paths that directly import the github.com/operator-framework/operator-sdk package import have been removed.

The k8sutil.GetWatchNamespace() has been directly vendored in the pkg/apis/operators/shared package.

Avoid printing the operator-sdk version when starting up the marketplace operator executable.

Migrate the e2e testing packages to use Ginkgo instead of the operator-sdk testing harness. The majority of the OLM-related repositories (and the Kubernetes ecosystem as a whole) use Ginkgo for e2e testing. Any relevant marketplace e2e test has been migrated to a testing package in the test/e2e package.

Update the scripts/ directory and remove any operator-sdk-related bash scripts that are no longer needed. The root Makefile has been also updated to remove targets that are no longer needed. The e2e-job Makefile target, which is what the o/release ci-operator configuration is responsible for running, has been updated to simply inline the go test ... ./test/e2e/... command instead of utilizing a wrapper bash script to setup and run e2e tests.

@timflannagan
Copy link
Contributor Author

/retest

@timflannagan timflannagan force-pushed the bump-k8s-1.21 branch 3 times, most recently from 14463d6 to d385af1 Compare August 24, 2021 20:37
Update the controller-runtime dependency to a release version tag that
has contains the requisite updates for k8s 1.21 dependencies.
Update the cmd/manager/main.go executable package and remove the direct
operator-sdk package imports.

Directly vendor the function responsible for determining the operator
watch namespace in pkg/apis/operator/shared/shared.go and update the
import to reference that package instead.

Remove the operator-sdk version printing when the --version flag has
been specified.
Remove the unused pkg/proxy/proxy.go test as it's no longer needed with
the deprecated and removal of the OperatorSource API.

Remove the ProxyTests test handler package. Previously, this test
handler was being registered before the OperatorSource API was removed.

During the removal of the OperatorSource API [1], the removal of this
package was missed.

[1] operator-framework/operator-marketplace@82b5ef3
…mports

Remove the manual vendoring of the OLM CatalogSource API type introduced
in operator-framework#329.

Update relevant package imports to use the o-f/api dependency.
Update cmd/manager/main.go and avoid registering the v1beta1 CRD schema
in the main executable package.

Update the vendor tree and mark the `k8s.io/apiextensions-apiserver` as
an indirect dependency.
Remove the various operator-sdk-related bash scripts in scripts/.

Remove any unneeded Makefile targets.

Update the `e2e-job`, which is what o/release is configured to run, and
prefer to inline the `go test ...` command instead of using a bash
script.
@timflannagan
Copy link
Contributor Author

/retest

@timflannagan timflannagan changed the title Bump k8s and controller-runtime dependencies to v0.21.x and v0.9.x Bug 1997811: Bump k8s and controller-runtime dependencies to v0.21.x and v0.9.x Aug 25, 2021
@openshift-ci openshift-ci bot added bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Aug 25, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 25, 2021

@timflannagan: This pull request references Bugzilla bug 1997811, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.9.0) matches configured target release for branch (4.9.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @jianzhangbjz

In response to this:

Bug 1997811: Bump k8s and controller-runtime dependencies to v0.21.x and v0.9.x

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.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 25, 2021

@openshift-ci[bot]: GitHub didn't allow me to request PR reviews from the following users: jianzhangbjz.

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

In response to this:

@timflannagan: This pull request references Bugzilla bug 1997811, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.9.0) matches configured target release for branch (4.9.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @jianzhangbjz

In response to this:

Bug 1997811: Bump k8s and controller-runtime dependencies to v0.21.x and v0.9.x

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.

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.

@davegord
Copy link

/retest

@davegord
Copy link

/retest

1 similar comment
@davegord
Copy link

/retest

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

/lgtm

Only nit would be to see if we could further reduce or completely remove usage of context.TODO(). Non-blocking though.

@@ -87,12 +89,12 @@ type ReconcileCatalogSource struct {
client client.Client
}

func (r *ReconcileCatalogSource) Reconcile(request reconcile.Request) (reconcile.Result, error) {
func (r *ReconcileCatalogSource) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary/helpful/reasonable to pass this context down to anything called from this function (e.g. GetSingleton().Get() or Ensure())?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a cursory look through the repository and removed as many usages of context.TODO() outside of testing code that were easily replaceable. The status reported package, which is responsible for setting up a go routine to monitor the marketplace ClusterOperator resource (and as aside, I think we'd want to move that handlement to its own controller down the line) but the changeset for updating all the call sites to properly handle signals seemed riskier in the full context of these changes, so I held off there.

One other quick note, and something we can tackle outside of this PR, is we still embed OperatorSource logic in the various top-level functions/methods/etc. I wonder if it's worth the easier maintenance for 4.9+ to make the requisite changes. It likely would be a source for cherrypick failures when backporting bug fixes, but the surface area would be low. I'm not super worried about breaking other clients that depend on marketplace at this point either.

pkg/defaults/catsrcHelpers.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 30, 2021
Update relevant functions and methods in the marketplace operator
packages to avoid the usage of context.TODO() as much as possible.
Instead, update the signatures to include a context.Context parameter
that can be propagated at call sites.
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 30, 2021
Comment on lines -95 to -101
func createNewCatsrcInstance(client client.Client, catsrc olm.CatalogSource) error {
err := client.Create(context.TODO(), &catsrc)
if err != nil {
log.Warnf("Could not recreate default CatalogSource %s. Error: %s", catsrc.GetName(), err.Error())
return err
}
return nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realize the diff for this is somewhat misleading when quickly reviewing:

  • The Reconcile method was updated to take a context.Context parameter
  • The Ensure(...) and EnsureAll(...) now take context.Context parameters
  • The createNewCatsrcInstance function was removed as it was dead code

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

/lgtm

// Requested object was not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
// Return and don't requeue
return reconcile.Result{}, client.IgnoreNotFound(err)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 30, 2021
@timflannagan
Copy link
Contributor Author

/retest

@kevinrizza
Copy link
Member

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 30, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joelanford, kevinrizza, timflannagan

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 30, 2021
@timflannagan
Copy link
Contributor Author

/retest

1 similar comment
@timflannagan
Copy link
Contributor Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 30, 2021

@timflannagan: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Rerun command
ci/prow/okd-e2e-aws 76d819e link /test okd-e2e-aws

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit cfc16ec into operator-framework:master Aug 30, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 30, 2021

@timflannagan: All pull requests linked via external trackers have merged:

Bugzilla bug 1997811 has been moved to the MODIFIED state.

In response to this:

Bug 1997811: Bump k8s and controller-runtime dependencies to v0.21.x and v0.9.x

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.

@timflannagan timflannagan deleted the bump-k8s-1.21 branch August 30, 2021 21:37
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. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants