Skip to content

fix: use omitzero instead of omitempty for supportedKinds to ensure backward compatibility - #4551

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:mainfrom
snorwin:fix-supportedkinds-omitempty
Feb 18, 2026
Merged

k8s-ci-robot merged 1 commit into
kubernetes-sigs:mainfrom
snorwin:fix-supportedkinds-omitempty

Conversation

@snorwin

@snorwin snorwin commented Feb 18, 2026 •

Copy link
Copy Markdown
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:
With the 1.5 release, the supportedKinds field in ListenerStatus was changed from required to optional, and omitempty was introduced.

While this appears to be a non-breaking API change, the addition of omitempty effectively breaks controllers reconciling older versions as soon as the dependency is updated to v1.5. Because the field is no longer explicitly set to an empty value, it may be omitted entirely from the status. However, certain conformance tests, e.g., GatewayInvalidRouteKind, still expect the field to be present, even if empty.

In our case, this resulted in the controller entering an endless reconcile loop with the following error:

"message":"failed to update status: Gateway.gateway.networking.k8s.io \"gateway-only-invalid-route-kind\" is invalid: [status.listeners[0].supportedKinds: Required value, <nil>: Invalid value: null: some validation rules were not checked because the object was invalid; correct the existing errors to complete validation]"

1.4.1

	// +required
	// +listType=atomic
	// +kubebuilder:validation:MaxItems=8
	SupportedKinds []RouteGroupKind `json:"supportedKinds"`

https://github.com/kubernetes-sigs/gateway-api/blob/v1.4.1/apis/v1/gateway_types.go#L1310-L1313

v1.5.0-rc.1

	// +optional
	// +listType=atomic
	// +kubebuilder:validation:MaxItems=8
	SupportedKinds []RouteGroupKind `json:"supportedKinds,omitempty"`

https://github.com/kubernetes-sigs/gateway-api/blob/v1.5.0-rc.1/apis/v1/gateway_types.go#L1365-L1368

This PR ensures compatibility by preventing supportedKinds from being omitted in cases where it must be explicitly set empty.

Which issue(s) this PR fixes:

N/A

Does this PR introduce a user-facing change?:

Replace `omitempty` with `omitzero` for `supportedKinds` in ListenerStatus to preserve backward compatibility for controllers reconciling older Gateway API versions.

…ackward compatibility

Signed-off-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Feb 18, 2026
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 18, 2026
@snorwin

snorwin commented Feb 18, 2026

Copy link
Copy Markdown
Member Author

/cc @davidjumani @rikatz

@snorwin

snorwin commented Feb 18, 2026

Copy link
Copy Markdown
Member Author

/retest

@rikatz

rikatz commented Feb 18, 2026

Copy link
Copy Markdown
Member

/approve

Leaving lgtm for someone else. I agree this is one of those very edge cases on how we test things and how they can be impacted by different assumptions of null vs empty :)

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 18, 2026

@davidjumani davidjumani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 18, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidjumani, rikatz, snorwin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@snorwin

snorwin commented Feb 18, 2026

Copy link
Copy Markdown
Member Author

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@snorwin: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.5

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.

@k8s-ci-robot
k8s-ci-robot merged commit d310a20 into kubernetes-sigs:main Feb 18, 2026
32 of 33 checks passed
@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@snorwin: new pull request created: #4556

Details

In response to this:

/cherry-pick release-1.5

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants