Skip to content

Replace apimachinery.Scheme with kubectl.Scheme

Mitchell Nielsen requested to merge operator-adjust-scheme into master

What does this MR do?

Replace apimachinery.Scheme with kubectl.Scheme

Replaces k8s.io/apimachinery/pkg/runtime.Scheme with k8s.io/kubectl/pkg/scheme.Scheme.

Sourced from suggestion in !661 (comment 1581854454).

This change ensures that objects like ServiceMonitors are successfully decoded from the Helm template by using the same scheme referenced in our Helm package: https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/blob/839ecaadfb2dea695f92804d427ee0d20b809faa/helm/builder.go#L173

Changelog: other

More information

Comment from @pursultani:

For deserializing objects, we use scheme.Codecs from k8s.io/kubectl/pkg/scheme. It uses scheme.Scheme from the same package (aliased kubectlscheme here).

In main.go we create an empty scheme variable, populate it, and pass it to GitLabReconciler. So the reconciler is fine with the new types. It can watch them and queue their events. It is the universal codec that doesn't have the same scheme as the reconciler.

What you have done here made it possible to pass the populated schemes down to universal codec, by populating the new types into it.

Test plan

See !661 (comment 1583078441) for context on the suggested change and the successful result when testing. Effectively:

  1. Deploy the Operator using an image that contains this change.
  2. Try to reconcile an object like a ServiceMonitor.
  3. Confirm that the object is reconciled.

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • Merge Request Title and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Tests added
  • Integration tests added to GitLab QA
  • Equivalent MR/issue for omnibus-gitlab opened
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Mitchell Nielsen

Merge request reports