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

Generated crd has a validation error #3082

Closed
shawkins opened this issue May 6, 2021 · 8 comments
Closed

Generated crd has a validation error #3082

shawkins opened this issue May 6, 2021 · 8 comments
Assignees

Comments

@shawkins
Copy link
Contributor

shawkins commented May 6, 2021

With crd-generator 5.2.1 my installed generated crd is reporting:

conditions:
  - lastTransitionTime: "2021-05-06T14:56:48Z"
    message: 'spec.preserveUnknownFields: Invalid value: true: must be false'
    reason: Violations
    status: "True"
    type: NonStructuralSchema

There's nothing on the custom resource class nor in the generated yml that mentions preserveUnknownFields.

cc @metacosm

@metacosm
Copy link
Collaborator

metacosm commented May 7, 2021

That's indeed weird. Can you try with a more recent version of the crd-generator-apt, please? Note that it's highly unlikely that we would backport fixes to 5.2.x. You should be able to use the crd-generator-apt dependency with a different version without it impacting the rest of the code, though.

@metacosm
Copy link
Collaborator

metacosm commented May 7, 2021

After some investigation, that seems to be an issue with upgrading CRDs from v1beta1 to v1. See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning for more information. The fix seems to manually set preserveUnknownFields to false in your CRD.

@shawkins
Copy link
Contributor Author

shawkins commented May 7, 2021

This situation is occurring with a fresh minikube and the v1beta1 crd.

It does not appear to happen when starting fresh and applying the v1 crd.

I'm fine with a manual workaround.

@metacosm
Copy link
Collaborator

metacosm commented May 7, 2021

This situation is occurring with a fresh minikube and the v1beta1 crd.

You mean it happens with just the v1beta1 CRD? Not an upgrade scenario?

@shawkins
Copy link
Contributor Author

shawkins commented May 7, 2021

You mean it happens with just the v1beta1 CRD? Not an upgrade scenario?

Yes. minikube delete, then start, then "kubectl apply -f ...", then "kubectl get crd ..." and the validation error is there.

@metacosm
Copy link
Collaborator

metacosm commented May 7, 2021

Not that this behavior seems to happen starting with kube 1.20, applying the CRD to 1.19 didn't lead to the validation error.

@metacosm
Copy link
Collaborator

metacosm commented May 7, 2021

Can we close this issue?

@shawkins
Copy link
Contributor Author

shawkins commented May 7, 2021

Yes, the resolution is to manually change the generated crd and the problem will go away with v1.

@metacosm metacosm closed this as completed May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants