fix(gateway): use TCP target group protocol for TLSRoute on passthrough NLB listeners - #4853
fix(gateway): use TCP target group protocol for TLSRoute on passthrough NLB listeners#4853pujitha24 wants to merge 1 commit into
Conversation
…gh NLB listeners Motivation: Issue kubernetes-sigs#4556 reported that a Gateway API NLB listener with `protocol: TLS` and `tls.mode: Passthrough` incorrectly built a TLS listener. That part was already fixed in v3.1.0 by downgrading the listener protocol to TCP for passthrough mode. However, follow-up reports on the same issue (from 2026-03-04 and 2026-03-10) show the fix was incomplete: when a `TLSRoute` is bound to such a passthrough listener, the controller still infers the *target group* protocol as TLS. This produces a real AWS API error when reconciling the load balancer: IncompatibleProtocols: The listener and the following target groups have incompatible protocols because the (now TCP) listener cannot be attached to a TLS target group. This is a functional failure, not cosmetic: the Gateway never reaches a working state and reconciliation errors repeatedly. Approach: `inferTargetGroupProtocolFromRoute` in pkg/gateway/model/model_build_target_group.go always returned `ProtocolTLS` for `TLSRouteKind` on an NLB, regardless of the actual listener protocol. It now takes the (already passthrough-downgraded) listener protocol and returns `ProtocolTCP` when the listener protocol is TCP, keeping `ProtocolTLS` for the `tls.mode: Terminate` case. Users who explicitly set `targetGroupProps.Protocol` are unaffected, since that explicit-override path is checked before the inference path. This only changes NLB behavior for TLSRoute; ALB target group protocol inference (which cannot take this NLB-only branch) is unaffected. Validation: go build ./... go test -count=1 ./pkg/gateway/model/... Both pass, including a corrected unit test case in Test_buildTargetGroupProtocol that had been asserting the buggy (mismatched) behavior. Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
|
Welcome @pujitha24! |
|
Hi @pujitha24. 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 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pujitha24 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 |
There was a problem hiding this comment.
Pull request overview
Fixes Gateway API NLB behavior for TLSRoute when a listener is configured as protocol: TLS with tls.mode: Passthrough: while the listener is already downgraded to TCP, the controller now also infers a TCP target group protocol to avoid AWS “IncompatibleProtocols” reconciliation failures.
Changes:
- Pass listener protocol into target group protocol inference so
TLSRouteon NLB can inferTCPwhen the (passthrough-downgraded) listener protocol isTCP. - Update the unit test to assert the corrected behavior for passthrough TLS listeners.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/gateway/model/model_build_target_group.go | Adjusts protocol inference for TLSRoute on NLB to align target group protocol with passthrough-downgraded TCP listeners. |
| pkg/gateway/model/model_build_target_group_test.go | Updates Test_buildTargetGroupProtocol to expect TCP for the passthrough-downgraded listener case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d84e663 to
56f6433
Compare
|
/assign @zac-nixon This is rebased and conflict-free whenever you get a chance to take a look. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4853 +/- ##
==========================================
+ Coverage 57.49% 57.52% +0.03%
==========================================
Files 396 396
Lines 31621 31675 +54
==========================================
+ Hits 18179 18220 +41
- Misses 12384 12397 +13
Partials 1058 1058 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/lgtm |
Motivation:
Issue #4556 reported that a Gateway API NLB listener with
protocol: TLSand
tls.mode: Passthroughincorrectly built a TLS listener. That partwas already fixed in v3.1.0 by downgrading the listener protocol to TCP
for passthrough mode.
However, follow-up reports on the same issue (from 2026-03-04 and
2026-03-10) show the fix was incomplete: when a
TLSRouteis bound tosuch a passthrough listener, the controller still infers the target
group protocol as TLS. This produces a real AWS API error when
reconciling the load balancer:
IncompatibleProtocols: The listener and the following target groups
have incompatible protocols
because the (now TCP) listener cannot be attached to a TLS target group.
This is a functional failure, not cosmetic: the Gateway never reaches a
working state and reconciliation errors repeatedly.
Approach:
inferTargetGroupProtocolFromRouteinpkg/gateway/model/model_build_target_group.go always returned
ProtocolTLSforTLSRouteKindon an NLB, regardless of the actuallistener protocol. It now takes the (already passthrough-downgraded)
listener protocol and returns
ProtocolTCPwhen the listener protocolis TCP, keeping
ProtocolTLSfor thetls.mode: Terminatecase. Userswho explicitly set
targetGroupProps.Protocolare unaffected, sincethat explicit-override path is checked before the inference path.
This only changes NLB behavior for TLSRoute; ALB target group protocol
inference (which cannot take this NLB-only branch) is unaffected.
Validation:
go build ./...
go test -count=1 ./pkg/gateway/model/...
Both pass, including a corrected unit test case in
Test_buildTargetGroupProtocol that had been asserting the buggy
(mismatched) behavior.
Fixes #4556
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com