fix: inject port into legacy XListenerSet status to fix required field validation#14231
Merged
davidjumani merged 5 commits intoJul 13, 2026
Conversation
…d validation Signed-off-by: Babak Zarrinbal <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds compatibility logic so legacy XListenerSet CRDs continue to receive required status.listeners[*].port fields even though the promoted gwv1.ListenerEntryStatus no longer includes Port.
Changes:
- Inject
portinto legacy ListenerSet status entries by looking up matching listeners in spec. - Use
kubeutils.DetectListenerPortNumberto derive port defaults when spec port is 0. - Add unit tests covering multiple listener/protocol scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| pkg/kgateway/proxy_syncer/status_syncer.go | Injects legacy-required port into ListenerSet status before patching. |
| pkg/kgateway/proxy_syncer/inject_listener_ports_test.go | Adds unit tests for the listener port injection helper. |
…, test fixes Signed-off-by: Babak Zarrinbal <[email protected]>
davidjumani
approved these changes
Jul 13, 2026
davidjumani
added a commit
that referenced
this pull request
Jul 14, 2026
…d validation (#14231) Signed-off-by: Babak Zarrinbal <[email protected]> Co-authored-by: Babak Zarrinbal <[email protected]> Co-authored-by: David Jumani <[email protected]> Signed-off-by: David Jumani <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #14196.
Since v2.3.0 (PR #13671),
BuildListenerSetStatuswas migrated fromgwxv1a1.ListenerEntryStatustogwv1.ListenerEntryStatus. The promoted type no longer carries aPortfield, but the legacyXListenerSetCRD schema still requiresstatus.listeners[*].port. As a result, every reconcile cycle fails to patch XListenerSet status with:Changes:
pkg/kgateway/proxy_syncer/status_syncer.go: InpatchListenerSetStatus, injectportinto the unstructured status map before patching the legacy XListenerSet. AddsinjectListenerPortshelper that precomputes a name→port map fromls.Spec.Listenersusingkubeutils.DetectListenerPortNumber, with a namedlegacyPortFallbackconstant (65535) for both unknown protocols and unmatched listeners — matching v2.2.4 behaviour. The promoted ListenerSet path (legacyListenerSet == nil) is untouched.pkg/kgateway/proxy_syncer/inject_listener_ports_test.go: 8 table-driven unit tests covering spec-explicit port, HTTP/HTTPS default ports, unknown-protocol fallback, multiple listeners, orphan listener (no spec match → fallback port), missing key, and empty slice.Change Type
/kind fix
Changelog
Additional Notes
The fix is intentionally scoped to the legacy XListenerSet code path only. Copilot review comments addressed: named constant for 65535, O(n²) → O(n) precomputed map, fallback port for unmatched listeners, and test improvements.