-
Notifications
You must be signed in to change notification settings - Fork 719
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
Mark the Version field required and adapt CRD generation for trivialVersions #2480
Conversation
Currently if the Version field is not set, we reject the resource in the validation webhook. If the webhook is disabled, the operator returns an error early in the reconciliation. This could be considered a breaking API change, but the Version field was already required implicitly, just not caught by the OpenAPI validation.
A bug in controller-tools prevent validation to appear in the generated CRDs if trivialVersions is set and multiple versions do not share the exact same schema. See kubernetes-sigs/controller-tools#349. This commit removes the usage of `crd:trivialVersions=true`, to "manually" (through Kustomize) apply the CRD modifications so we end up with the trivialVersion scheme. That is: a single `validation` field matching the OpenAPISchema of the currently stored version (v1).
One thing I noticed while testing is that we will want to update the controller-gen check in the makefile: I think any changes should probably be a separate PR though, because 0.2.4 also adds some of the markers required for structural schema ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick test on Openshift 3.11, looks good 👍
Thanks !
This PR should have been split into 2:
Version
field as mandatoryHowever they both rely on each other:
CI would fail building manifests in both individual cases. Hence a single PR with 2 commits.
1. Mark the Version field as required in all CRD
Currently if the Version field is not set, we reject the resource in the
validation webhook.
If the webhook is disabled, the operator returns an error early in the
reconciliation.
This could be considered a breaking API change, but the Version field
was already required implicitly, just not caught by the OpenAPI
validation.
Fixes #2395.
2. Customize CRDs to work around trivialVersions gen bug
A bug in controller-tools prevent validation to appear in the generated
CRDs if trivialVersions is set and multiple versions do not share the
exact same schema.
See kubernetes-sigs/controller-tools#349.
This commit removes the usage of
crd:trivialVersions=true
, to"manually" (through Kustomize) apply the CRD modifications so we end up
with the trivialVersion scheme. That is: a single
validation
fieldmatching the OpenAPISchema of the currently stored version (v1).
Fixes #2479.