-
Notifications
You must be signed in to change notification settings - Fork 49
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
Set PreserveUnknownFields: false in v1 CRDs #124
Set PreserveUnknownFields: false in v1 CRDs #124
Conversation
Our CRDs were previously of version v1beta1. In v1beta1, spec.PreserveUnknownFields defaulted to `true`. As we did not set this value explicitly, the value was set to `true`. We've now updated our CRDs to v1. In v1, spec.PreserveUnknownFields defaults to false. In fact, it is being deprecated in favor of the more targeted x-kubernetes-preserve-unknown-fields field. Despite this new default, spec.PreserveUnknownFields remains `true` for our CRDs, even after applying the new v1 versions. This does not cause any bad behavior, but is incorrect. To fix this, we must set spec.PreserveUnknownFields to false in our CRDs. `controller-gen` v0.5.0 doesn't include an annotation for that, presumably because it's not longer the supported path for disabling pruning. So, I've achieved the desired effect with a simple kustomize patch. Contributes to open-policy-agent/gatekeeper#550 Signed-off-by: juliankatz <juliankatz@google.com>
d89d10d
to
2073faf
Compare
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.
Should we set this for the other CRDs as well?
Signed-off-by: juliankatz <juliankatz@google.com>
Codecov Report
@@ Coverage Diff @@
## master #124 +/- ##
==========================================
+ Coverage 44.26% 44.31% +0.04%
==========================================
Files 30 30
Lines 2417 2419 +2
==========================================
+ Hits 1070 1072 +2
Misses 1022 1022
Partials 325 325
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
I've added the field to the code that generates Constraint kind CRDs. I'll make a PR in g8r as well. |
Signed-off-by: juliankatz <juliankatz@google.com>
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.
Our CRDs were previously of version v1beta1. In v1beta1,
spec.PreserveUnknownFields defaulted to
true
. As we did not set thisvalue explicitly, the value was set to
true
.We've now updated our CRDs to v1. In v1, spec.PreserveUnknownFields
defaults to false. In fact, it is being deprecated in favor of the more
targeted x-kubernetes-preserve-unknown-fields field.
Despite this new default, spec.PreserveUnknownFields remains
true
forour CRDs, even after applying the new v1 versions. This does not cause
any bad behavior, but is incorrect. The simple fix is to set
spec.PreserveUnknownFields to false in all our CRDs.
As the Constraint kind CRD is generated in code, I've added this field
in constraint/pkg/client/crd_helpers.go.
The ConstraintTemplate CRD is generated using
controller-gen
, butv0.5.0 of the tool doesn't include an annotation for that, presumably
because it's not longer the supported path for disabling pruning. So, I've
achieved the desired effect with a simple kustomize patch.
Contributes to open-policy-agent/gatekeeper#550
Signed-off-by: juliankatz juliankatz@google.com