-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Controller-gen can now update CRDs like before #3989
Conversation
The controller-gen tool is quite rude and won't tell you when one of the CRD manifests cannot be parsed when the option schemapatch is used. As an example, the following: sed -i 's/RFC8555/RFC8556/g' pkg/apis/certmanager/v1/types_issuer.go controller-gen schemapatch:manifests=./deploy/crds output:dir=./deploy/crds paths=./pkg/apis/... should trigger a change in the crd-clusterissuers.yaml: @@ -3184,7 +3184,7 @@ spec: type: object properties: acme: - description: ACME [...] communicate with a RFC8555 + description: ACME [...] communicate with a RFC8556 type: object Unfortunately, controller-gen v0.2.9-0.20200414181213-645d44dca7c0 silently skips faulty CRD manifests. In our case, the CRD had become a non-YAML file (we need to use some if statements): {{- if .Values.webhook.url.host }} url: https://{{ .Values.webhook.url.host }}/convert {{- else }} service: name: {{ template "webhook.fullname" . }} namespace: {{ .Release.Namespace | quote }} path: /convert {{- end }} Two issues can be found (we can use a YAML parser like yq for that): 1. The pipe "|" used in ".Release.Namespace | quote" makes it an invalid YAML file. We could rewrite that to {{ quote .Release.Namespace }} but I decided to go with actual quotes like with the rest of the file. 2. The {{ if }}, {{ else }} and {{ end }} are also invalid YAML syntax, and one easy workaround is to comment them. So many workarounds... but it now works! Signed-off-by: Maël Valais <mael@vls.dev>
Weird, tests are passing on my machine 😅 Seems like some form of flakiness... % ./devel/cluster/create-kind.sh
% ./devel/setup-e2e-deps.sh
% bazel run //test/integration/ctl:go_default_test -- -test.v
Executing tests from //test/integration/ctl:go_default_test
-----------------------------------------------------------------------------
--- FAIL: TestCtlRenew (88.19s)
testwebhook.go:110: Waiting for ListenPort to be allocated (got error: Run() must be called before Port())
apiserver.go:75: Found CRD with name "certificaterequests.cert-manager.io"
apiserver.go:75: Found CRD with name "certificates.cert-manager.io"
apiserver.go:75: Found CRD with name "challenges.acme.cert-manager.io"
apiserver.go:75: Found CRD with name "clusterissuers.cert-manager.io"
apiserver.go:75: Found CRD with name "issuers.cert-manager.io"
apiserver.go:75: Found CRD with name "orders.acme.cert-manager.io"
--- FAIL: TestCtlRenew/--all_and_namespace_given (1.12s)
ctl_renew_test.go:157: Post "http://127.0.0.1:40339/apis/cert-manager.io/v1/namespaces/testns-1/certificates": context deadline exceeded /retest |
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 tested it locally and verified that the CRDs are updated properly.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maelvls, wallrj The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Note: I reported the issue in kubernetes-sigs/controller-tools#571 |
Fixes #3943. The controller-gen tool is quite rude and won't tell you when one of the CRD manifests cannot be parsed when the option schemapatch is used. As an example, the following:
should trigger a change in the crd-clusterissuers.yaml:
Unfortunately, controller-gen v0.2.9 (645d44dc) silently skips faulty CRD manifests. In our case, the CRD had become a non-YAML file (we need to use some if statements):
Two issues can be found (we can use a YAML parser like yq for that):
The pipe "|" used in
.Release.Namespace | quote
makes it an invalid YAML file. We could rewrite that to{{ quote .Release.Namespace }}
but I decided to go with actual quotes like with the rest of the file:
"{{ .Release.Namespace }}"
The
{{ if }}
,{{ else }}
and{{ end }}
are also invalid YAML syntax, and one easy workaround is to comment them./kind cleanup
/milestone v1.4