Fix CRD markers#4178
Conversation
This commit corrects several invalid Kubebuilder validation markers that caused controller-gen validation errors. Changes: Removed +listType=atomic from non-array fields: gateway_types.go: Namespaces *RouteNamespaces (line 806) backendtlspolicy_types.go: WellKnownCACertificates (line 192) Replaced MaxLength with MaxItems for array fields: httproute_types.go: AllowedRequestHeaders []string (lines 1674, 1722) httproute_types.go: AllowedResponseHeaders []string (line 1733) Removed Minimum/Maximum from non-primitive fields: xlistenerset_types.go: Port PortNumber (lines 170, 255) Added CRD marker validation to hack/update-clientset.sh to detect invalid markers during development and CI. These fixes ensure validation markers are applied only to compatible field types. Signed-off-by: Killian Golds <kgolds@redhat.com>
Addresses reviewers feedback by moving validation to the type level. Creates StatusPortNumber for status fields requiring valid ports (1-65535). Signed-off-by: Killian Golds <kgolds@redhat.com>
|
Hi @KillianGolds. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with 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. |
|
/cc @rikatz |
|
/ok-to-test |
The v1alpha2 ReferenceGrant type is marked with +kubebuilder:skipversion, meaning no CRD is generated for this version (it’s just an alias to v1beta1). The +kubebuilder:printcolumn marker cannot be applied to a skipped version. This issue was uncovered by the CRD marker validation added in the previous commit. The printcolumn is already correctly defined in v1beta1 and does not need to be duplicated here. Signed-off-by: Killian Golds <kgolds@redhat.com>
|
nit: mostly of the description of the PR is wrong now, as you are:
otherwise looks good to me, thanks for catching this! Original discussion: #4172 My proposal is that once this gets merged, if we decide to port it to release 1.4, cherry-pick the commits from PR https://github.com/kubernetes-sigs/gateway-api/pull/4158/files and this to release 1.4 |
|
/retitle Fix CRD markers |
The rename makes it explicit that this type permits 0, helping prevent accidental use where StatusPortNumber (1–65535) should be preferred. Signed-off-by: Killian Golds <kgolds@redhat.com>
|
Nice work. /approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: KillianGolds, youngnick The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Simplifies the validation step to avoid generating files or requiring boilerplate headers. The validation still catches invalid markers but does not write any CRDs to disk.
Signed-off-by: Killian Golds <kgolds@redhat.com>
|
/hold |
|
/hold cancel |
* Fix incorrect Kubebuilder validation markers This commit corrects several invalid Kubebuilder validation markers that caused controller-gen validation errors. Changes: Removed +listType=atomic from non-array fields: gateway_types.go: Namespaces *RouteNamespaces (line 806) backendtlspolicy_types.go: WellKnownCACertificates (line 192) Replaced MaxLength with MaxItems for array fields: httproute_types.go: AllowedRequestHeaders []string (lines 1674, 1722) httproute_types.go: AllowedResponseHeaders []string (line 1733) Removed Minimum/Maximum from non-primitive fields: xlistenerset_types.go: Port PortNumber (lines 170, 255) Added CRD marker validation to hack/update-clientset.sh to detect invalid markers during development and CI. These fixes ensure validation markers are applied only to compatible field types. Signed-off-by: Killian Golds <kgolds@redhat.com> * Restore port validation by defining PortNumber types in v1alpha1 Addresses reviewers feedback by moving validation to the type level. Creates StatusPortNumber for status fields requiring valid ports (1-65535). Signed-off-by: Killian Golds <kgolds@redhat.com> * Removed invalid printcolumn marker from v1alpha2 ReferenceGrant The v1alpha2 ReferenceGrant type is marked with +kubebuilder:skipversion, meaning no CRD is generated for this version (it’s just an alias to v1beta1). The +kubebuilder:printcolumn marker cannot be applied to a skipped version. This issue was uncovered by the CRD marker validation added in the previous commit. The printcolumn is already correctly defined in v1beta1 and does not need to be duplicated here. Signed-off-by: Killian Golds <kgolds@redhat.com> * Rename PortNumber to PortNumberWith0 to prevent misuse The rename makes it explicit that this type permits 0, helping prevent accidental use where StatusPortNumber (1–65535) should be preferred. Signed-off-by: Killian Golds <kgolds@redhat.com> * Use output:none for CRD marker validation Simplifies the validation step to avoid generating files or requiring boilerplate headers. The validation still catches invalid markers but does not write any CRDs to disk. * clean duplicated echo statement Signed-off-by: Killian Golds <kgolds@redhat.com> --------- Signed-off-by: Killian Golds <kgolds@redhat.com>
* Fix incorrect Kubebuilder validation markers This commit corrects several invalid Kubebuilder validation markers that caused controller-gen validation errors. Changes: Removed +listType=atomic from non-array fields: gateway_types.go: Namespaces *RouteNamespaces (line 806) backendtlspolicy_types.go: WellKnownCACertificates (line 192) Replaced MaxLength with MaxItems for array fields: httproute_types.go: AllowedRequestHeaders []string (lines 1674, 1722) httproute_types.go: AllowedResponseHeaders []string (line 1733) Removed Minimum/Maximum from non-primitive fields: xlistenerset_types.go: Port PortNumber (lines 170, 255) Added CRD marker validation to hack/update-clientset.sh to detect invalid markers during development and CI. These fixes ensure validation markers are applied only to compatible field types. Signed-off-by: Killian Golds <kgolds@redhat.com> * Restore port validation by defining PortNumber types in v1alpha1 Addresses reviewers feedback by moving validation to the type level. Creates StatusPortNumber for status fields requiring valid ports (1-65535). Signed-off-by: Killian Golds <kgolds@redhat.com> * Removed invalid printcolumn marker from v1alpha2 ReferenceGrant The v1alpha2 ReferenceGrant type is marked with +kubebuilder:skipversion, meaning no CRD is generated for this version (it’s just an alias to v1beta1). The +kubebuilder:printcolumn marker cannot be applied to a skipped version. This issue was uncovered by the CRD marker validation added in the previous commit. The printcolumn is already correctly defined in v1beta1 and does not need to be duplicated here. Signed-off-by: Killian Golds <kgolds@redhat.com> * Rename PortNumber to PortNumberWith0 to prevent misuse The rename makes it explicit that this type permits 0, helping prevent accidental use where StatusPortNumber (1–65535) should be preferred. Signed-off-by: Killian Golds <kgolds@redhat.com> * Use output:none for CRD marker validation Simplifies the validation step to avoid generating files or requiring boilerplate headers. The validation still catches invalid markers but does not write any CRDs to disk. * clean duplicated echo statement Signed-off-by: Killian Golds <kgolds@redhat.com> --------- Signed-off-by: Killian Golds <kgolds@redhat.com>
* Fix incorrect Kubebuilder validation markers This commit corrects several invalid Kubebuilder validation markers that caused controller-gen validation errors. Changes: Removed +listType=atomic from non-array fields: gateway_types.go: Namespaces *RouteNamespaces (line 806) backendtlspolicy_types.go: WellKnownCACertificates (line 192) Replaced MaxLength with MaxItems for array fields: httproute_types.go: AllowedRequestHeaders []string (lines 1674, 1722) httproute_types.go: AllowedResponseHeaders []string (line 1733) Removed Minimum/Maximum from non-primitive fields: xlistenerset_types.go: Port PortNumber (lines 170, 255) Added CRD marker validation to hack/update-clientset.sh to detect invalid markers during development and CI. These fixes ensure validation markers are applied only to compatible field types. Signed-off-by: Killian Golds <kgolds@redhat.com> * Restore port validation by defining PortNumber types in v1alpha1 Addresses reviewers feedback by moving validation to the type level. Creates StatusPortNumber for status fields requiring valid ports (1-65535). Signed-off-by: Killian Golds <kgolds@redhat.com> * Removed invalid printcolumn marker from v1alpha2 ReferenceGrant The v1alpha2 ReferenceGrant type is marked with +kubebuilder:skipversion, meaning no CRD is generated for this version (it’s just an alias to v1beta1). The +kubebuilder:printcolumn marker cannot be applied to a skipped version. This issue was uncovered by the CRD marker validation added in the previous commit. The printcolumn is already correctly defined in v1beta1 and does not need to be duplicated here. Signed-off-by: Killian Golds <kgolds@redhat.com> * Rename PortNumber to PortNumberWith0 to prevent misuse The rename makes it explicit that this type permits 0, helping prevent accidental use where StatusPortNumber (1–65535) should be preferred. Signed-off-by: Killian Golds <kgolds@redhat.com> * Use output:none for CRD marker validation Simplifies the validation step to avoid generating files or requiring boilerplate headers. The validation still catches invalid markers but does not write any CRDs to disk. * clean duplicated echo statement Signed-off-by: Killian Golds <kgolds@redhat.com> --------- Signed-off-by: Killian Golds <kgolds@redhat.com>
* Fix incorrect Kubebuilder validation markers This commit corrects several invalid Kubebuilder validation markers that caused controller-gen validation errors. Changes: Removed +listType=atomic from non-array fields: gateway_types.go: Namespaces *RouteNamespaces (line 806) backendtlspolicy_types.go: WellKnownCACertificates (line 192) Replaced MaxLength with MaxItems for array fields: httproute_types.go: AllowedRequestHeaders []string (lines 1674, 1722) httproute_types.go: AllowedResponseHeaders []string (line 1733) Removed Minimum/Maximum from non-primitive fields: xlistenerset_types.go: Port PortNumber (lines 170, 255) Added CRD marker validation to hack/update-clientset.sh to detect invalid markers during development and CI. These fixes ensure validation markers are applied only to compatible field types. Signed-off-by: Killian Golds <kgolds@redhat.com> * Restore port validation by defining PortNumber types in v1alpha1 Addresses reviewers feedback by moving validation to the type level. Creates StatusPortNumber for status fields requiring valid ports (1-65535). Signed-off-by: Killian Golds <kgolds@redhat.com> * Removed invalid printcolumn marker from v1alpha2 ReferenceGrant The v1alpha2 ReferenceGrant type is marked with +kubebuilder:skipversion, meaning no CRD is generated for this version (it’s just an alias to v1beta1). The +kubebuilder:printcolumn marker cannot be applied to a skipped version. This issue was uncovered by the CRD marker validation added in the previous commit. The printcolumn is already correctly defined in v1beta1 and does not need to be duplicated here. Signed-off-by: Killian Golds <kgolds@redhat.com> * Rename PortNumber to PortNumberWith0 to prevent misuse The rename makes it explicit that this type permits 0, helping prevent accidental use where StatusPortNumber (1–65535) should be preferred. Signed-off-by: Killian Golds <kgolds@redhat.com> * Use output:none for CRD marker validation Simplifies the validation step to avoid generating files or requiring boilerplate headers. The validation still catches invalid markers but does not write any CRDs to disk. * clean duplicated echo statement Signed-off-by: Killian Golds <kgolds@redhat.com> --------- Signed-off-by: Killian Golds <kgolds@redhat.com>
What type of PR is this?
/kind bug
/kind cleanup
What this PR does / why we need it:
This PR fixes several incorrect kubebuilder validation markers in the gateway-api repository, similar to the fixes made in kubernetes-sigs/gateway-api-inference-extension#1679.
Background:
These validation errors were discovered while migrating KServe to use gateway-api-inference-extension (GIE) v1. During that migration work, running
controller-gen crdexposed validation marker issues in the GIE repository, which were fixed and merged in kubernetes-sigs/gateway-api-inference-extension#1679.After that fix was merged, continuing the KServe migration work revealed similar validation errors in the gateway-api repository itself. These errors affect downstream consumers like KServe who run
controller-tools genas part of their build process.The reason these issues haven't been caught previously is that gateway-api wasn't running
controller-gen crdvalidation as part of its build process. This PR both fixes the existing validation errors and adds the validation step to prevent future issues.Changes:
Restored port validation for XListenerSet (
apisx/v1alpha1):PortNumbertype definition fromv1tov1alpha1/shared_types.gowith validation (range 0–65535)StatusPortNumbertype inv1alpha1/shared_types.gowith validation (range 1–65535)Minimum/Maximummarkers fromPortfields inxlistenerset_types.go(validation now handled at type level)Portfield to useStatusPortNumbertypeRemoved invalid printcolumn marker (
apis/v1alpha2):+kubebuilder:printcolumnmarker fromv1alpha2 ReferenceGrant, which is marked with+kubebuilder:skipversionAdded CRD marker validation to build process:
hack/update-clientset.shto runcontroller-genCRD validation during buildsWhich issue(s) this PR fixes:
Fixes validation errors that affect downstream consumers like KServe who run
controller-genduring their build process. These were discovered during KServe migration to GIE v1, following the same issues fixed in kubernetes-sigs/gateway-api-inference-extension#1679.Does this PR introduce a user-facing change?:
Documentation References: