Fix config/crd/bases vs helm/crds list-marker mismatch (gofmt ordering) - #737
Fix config/crd/bases vs helm/crds list-marker mismatch (gofmt ordering)#737HansG89 wants to merge 1 commit into
Conversation
controller-gen crd runs twice per service across build-controller.sh (config/crd/bases) and build-controller-release.sh (helm/crds), reading from the same generated apis/ Go source tree. gofmt's doc-comment reformatter rewrites Markdown "*" list markers to "-" (Go 1.19+), but previously only ran once, at the very end of build-controller.sh, after the config/crd/bases controller-gen call but before the build-controller-release.sh one. So for any field whose doc comment has a bullet list, config/crd/bases and helm/crds permanently disagree on marker style for identical text -- regenerating always flips one file's CRD YAML relative to the other's. Move the gofmt call to run immediately after ack-generate produces the apis/ source, before either controller-gen crd invocation, so both capture doc comments on the same side of gofmt's rewrite.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: HansG89 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @HansG89. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
Regenerates the controller using aws-controllers-k8s/code-generator#737, which moves gofmt's doc-comment normalization to run before either controller-gen crd invocation, instead of only after the first one. Without this fix, config/crd/bases/*.yaml and helm/crds/*.yaml disagree on Markdown list-marker style (* vs -) for the same enum description text (e.g. Job.spec.jobMode), which is what was failing glue-verify-code-gen on this PR. Both CRD YAML targets now agree.
Problem
For any generated field whose Go doc comment contains a Markdown bullet list (e.g. an enum's valid-values doc),
config/crd/bases/*.yamlandhelm/crds/*.yamlpermanently disagree on the list-marker style (*vs-) for identical description text. Regenerating a service controller always "flips" one of the two files relative to the other, which makes CI'sverify-code-gendiff check impossible to satisfy.Example live on
aws-controllers-k8s/glue-controllermain today (Job.spec.jobModedoc):This is what's currently blocking
aws-controllers-k8s/glue-controller#16in CI (glue-verify-code-gen)Root cause
Both YAML targets are produced by separate
controller-gen crdinvocations reading from the same generatedapis/<version>Go source tree, within a singlemake build-controllerrun:scripts/build-controller.sh:ack-generate apiswrites the Go doc comments (the HTML<li>renderer inpkg/api/docstring.goalways emits*-style markers), thencontroller-gen crdruns against that raw, not-yet-gofmt'd source to produceconfig/crd/bases/*.yaml.gofmt -wonly runs later, at the very end of this script.scripts/build-controller-release.sh(run immediately after, by the samemake build-controllertarget): its owncontroller-gen crdcall runs against the already-gofmt'd source (persisted from step 1's end-of-scriptgofmt -w) to producehelm/crds/*.yaml.Go's doc-comment reformatter rewrites
*-style Markdown list markers in doc comments to-. Because the twocontroller-gen crdcalls straddle that rewrite, they capture the same doc comment on opposite sides of it, and the two output targets disagree forever after, independent of anything the service-controller author does.Confirmed via local repro (isolated
gofmtruns reproducing the rewrite, plus a livemake build-controller SERVICE=gluerun before/after this fix).Fix
Move the doc-comment-normalizing
gofmt -winscripts/build-controller.shto run immediately afterack-generate apiscompletes, before eithercontroller-gen crdinvocation reads the source, instead of only at the end of the script (after the firstcontroller-gen crdcall has already run). The existing end-of-script full-treegofmt -w/goimports -wis left in place for the rest of the generated code (controller, deepcopy, etc.); runninggofmttwice on already-formatted source is a no-op.Verification
Ran
make build-controller SERVICE=gluetwice back-to-back against a cleanglue-controllercheckout:config/crd/bases/glue.services.k8s.aws_jobs.yamlandhelm/crds/glue.services.k8s.aws_jobs.yamlare now byte-identical (md5summatch) for thejobModefield and the rest of the schema.Diff is scoped to generated CRD YAML plus normal
gofmt'd doc-comment text inapis/*/types.go; no template,docstring.go, or schema-generation logic changes needed.cc @michaelhtm