-
Notifications
You must be signed in to change notification settings - Fork 418
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
preserveUnknownFields=false doesn't work with crdVersions=v1 #476
Comments
I'm hitting the same issue, any ideas? |
I had the same issue here. It was an issue about upgrading from v1beta1 to v1 CRD. The solution was simply to manually add |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Update tools to newer versions. Note that despite preserveUnknownFields, this is not included in the generated CRDs due to [1]. Importing our local kustomize hack to include it here does not seem worthwhile since it is mostly an upgrade issue. [1] - kubernetes-sigs/controller-tools#476
Update tools to newer versions. Note that despite preserveUnknownFields, this is not included in the generated CRDs due to [1]. Importing our local kustomize hack to include it here does not seem worthwhile since it is mostly an upgrade issue. [1] - kubernetes-sigs/controller-tools#476
Update tools to newer versions. Note that despite preserveUnknownFields, this is not included in the generated CRDs due to [1]. Importing our local kustomize hack to include it here does not seem worthwhile since it is mostly an upgrade issue. [1] - kubernetes-sigs/controller-tools#476
Any updates on this? |
Rotten issues close after 30d of inactivity. Send feedback to sig-contributor-experience at kubernetes/community. |
@fejta-bot: Closing this issue. In response to this:
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. |
@elanv: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
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. |
By generating v1 instead of v1beta1, kubectl explain now works. preserveUnknownFields is needed for explain to work when upgrading from CRD v1beta1 to v1 but controller-gen has a bug [1] that causes it not be included in the generated CRD yaml. Use kustomize to add it the CRDs. Keep the webhooks at their prior version until we decide to or must update them. The new controller-gen defaults to newer version. [1] - kubernetes-sigs/controller-tools#476
By generating v1 instead of v1beta1, kubectl explain now works. preserveUnknownFields is needed for explain to work when upgrading from CRD v1beta1 to v1 but controller-gen has a bug [1] that causes it not be included in the generated CRD yaml. Use kustomize to add it the CRDs. Keep the webhooks at their prior version until we decide to or must update them. The new controller-gen defaults to newer version. [1] - kubernetes-sigs/controller-tools#476
/reopen |
@kevindelgado: Reopened this issue. In response to this:
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. |
/assign |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closing this issue. In response to this:
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. |
By generating v1 instead of v1beta1, kubectl explain now works. preserveUnknownFields is needed for explain to work when upgrading from CRD v1beta1 to v1 but controller-gen has a bug [1] that causes it not be included in the generated CRD yaml. Use kustomize to add it the CRDs. Keep the webhooks at their prior version until we decide to or must update them. The new controller-gen defaults to newer version. [1] - kubernetes-sigs/controller-tools#476
Still hitting this problem, though I was able to manually edit the CRD to set it to false |
Update tools to newer versions. Note that despite preserveUnknownFields, this is not included in the generated CRDs due to [1]. Importing our local kustomize hack to include it here does not seem worthwhile since it is mostly an upgrade issue. [1] - kubernetes-sigs/controller-tools#476
By generating v1 instead of v1beta1, kubectl explain now works. preserveUnknownFields is needed for explain to work when upgrading from CRD v1beta1 to v1 but controller-gen has a bug [1] that causes it not be included in the generated CRD yaml. Use kustomize to add it the CRDs. Keep the webhooks at their prior version until we decide to or must update them. The new controller-gen defaults to newer version. [1] - kubernetes-sigs/controller-tools#476
Explicitly set `preserveUnknownFields: false` to enable strict CRD validation and prohibit unknown fields in test environment first. Conversion of CRD from v1beta1 to v1 (see #2991) resulted in `preserveUnknownFields: true`: ``` $ kubectl --context=example get crd platformcredentialssets.zalando.org -o yaml | grep preserveUnknownFields preserveUnknownFields: true message: 'spec.preserveUnknownFields: Invalid value: true: must be false' ``` and requires explicit false value to reset. See also kubernetes-sigs/controller-tools#476 (comment) Signed-off-by: Alexander Yastrebov <[email protected]>
Now it is trivial to implement like: $ git --no-pager diff -- pkg/crd/gen.go
diff --git a/pkg/crd/gen.go b/pkg/crd/gen.go
index 9eb4126b..cb6dd964 100644
--- a/pkg/crd/gen.go
+++ b/pkg/crd/gen.go
@@ -100,6 +100,12 @@ func transformRemoveCRDStatus(obj map[string]interface{}) error {
return nil
}
+// transformPreserveUnknownFields ensures we spec.preserveUnknownFields=false.
+func transformPreserveUnknownFields(obj map[string]interface{}) error {
+ obj["spec"].(map[interface{}]interface{})["preserveUnknownFields"] = false
+ return nil
+}
+
func (g Generator) Generate(ctx *genall.GenerationContext) error {
parser := &Parser{
Collector: ctx.Collector,
@@ -171,7 +177,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
} else {
fileName = fmt.Sprintf("%s_%s.%s.yaml", crdRaw.Spec.Group, crdRaw.Spec.Names.Plural, crdVersions[i])
}
- if err := ctx.WriteYAML(fileName, headerText, []interface{}{crd}, genall.WithTransform(transformRemoveCRDStatus), genall.WithTransform(genall.TransformRemoveCreationTimestamp)); err != nil {
+ if err := ctx.WriteYAML(fileName, headerText, []interface{}{crd}, genall.WithTransform(transformRemoveCRDStatus), genall.WithTransform(genall.TransformRemoveCreationTimestamp), genall.WithTransform(transformPreserveUnknownFields)); err != nil {
return err
}
} but unfortunately |
/remove-lifecycle rotten @AlexanderYastrebov Feel free to open a PR (please with a corresponding test) |
@sbueringer: Reopened this issue. In response to this:
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. |
Reinstate crd:preserveUnknownFields option removed by kubernetes-sigs#607 to allow specifying the value of deprecated spec.preserveUnknownFields CRD field. This is useful for updating CRDs that were automatically converted from v1beta1 version which had true as a default value and resulted in: ``` $ kubectl get crd foo.bar -o yaml | grep preserveUnknownFields preserveUnknownFields: true message: 'spec.preserveUnknownFields: Invalid value: true: must be false' ``` Fixes kubernetes-sigs#476
Reinstate crd:preserveUnknownFields option removed by kubernetes-sigs#607 to allow specifying the value of deprecated spec.preserveUnknownFields CRD field. This is useful for updating CRDs that were automatically converted from v1beta1 version which had true as a default value and resulted in: ``` $ kubectl get crd foo.bar -o yaml | grep preserveUnknownFields preserveUnknownFields: true message: 'spec.preserveUnknownFields: Invalid value: true: must be false' ``` For kubernetes-sigs#476
Ok, created #912 |
Reinstate crd:preserveUnknownFields option removed by kubernetes-sigs#607 to allow specifying the value of deprecated spec.preserveUnknownFields CRD field. This is useful for updating CRDs that were automatically converted from v1beta1 version which had true as a default value and resulted in: ``` $ kubectl get crd foo.bar -o yaml | grep preserveUnknownFields preserveUnknownFields: true message: 'spec.preserveUnknownFields: Invalid value: true: must be false' ``` For kubernetes-sigs#476
Reinstate crd:preserveUnknownFields option removed by kubernetes-sigs#607 to allow specifying the value of deprecated spec.preserveUnknownFields CRD field. This is useful for updating CRDs that were automatically converted from v1beta1 version which had true as a default value and resulted in: ``` $ kubectl get crd foo.bar -o yaml | grep preserveUnknownFields preserveUnknownFields: true message: 'spec.preserveUnknownFields: Invalid value: true: must be false' ``` For kubernetes-sigs#476
* crd: allow specifying spec.preserveUnknownFields Reinstate crd:preserveUnknownFields option removed by #607 to allow specifying the value of deprecated spec.preserveUnknownFields CRD field. This is useful for updating CRDs that were automatically converted from v1beta1 version which had true as a default value and resulted in: ``` $ kubectl get crd foo.bar -o yaml | grep preserveUnknownFields preserveUnknownFields: true message: 'spec.preserveUnknownFields: Invalid value: true: must be false' ``` For #476 * crd: rename marker to DeprecatedV1beta1CompatibilityPreserveUnknownFields
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
@sbueringer @alvaroaleman I guess we can close this as done? |
Yes we can, thx! /close |
@sbueringer: Closing this issue. In response to this:
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-sigs/prow repository. |
crdVersions=v1
which is the new default, doesn't work in conjunction withpreserveUnknownFields=false
. Thespec.preserveUnknownFields
simply doesn't appear in the crd. There is an integration test forv1beta1
, but not forv1
.I'm running the following command in a kubebuilder repo:
I'm using defaults in my schema and if applying to a
1.16.13-gke.1
cluster, I get:If I add spec.preserveUnknownFields manually to the crd it works
My workaround in the makefile right now is
The text was updated successfully, but these errors were encountered: