Skip to content

fix(gateway): use TCP target group protocol for TLSRoute on passthrough NLB listeners - #4853

Open
pujitha24 wants to merge 1 commit into
kubernetes-sigs:mainfrom
pujitha24:auto/issue-4556
Open

fix(gateway): use TCP target group protocol for TLSRoute on passthrough NLB listeners#4853
pujitha24 wants to merge 1 commit into
kubernetes-sigs:mainfrom
pujitha24:auto/issue-4556

Conversation

@pujitha24

Copy link
Copy Markdown

Motivation:
Issue #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.

Fixes #4556

Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com

…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>
Copilot AI review requested due to automatic review settings July 26, 2026 02:31
@kubernetes-prow kubernetes-prow Bot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @pujitha24!

It looks like this is your first PR to kubernetes-sigs/aws-load-balancer-controller 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/aws-load-balancer-controller has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@kubernetes-prow kubernetes-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pujitha24
Once this PR has been reviewed and has the lgtm label, please assign zac-nixon for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 TLSRoute on NLB can infer TCP when the (passthrough-downgraded) listener protocol is TCP.
  • 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.

@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Aug 1, 2026
@pujitha24

Copy link
Copy Markdown
Author

/assign @zac-nixon

This is rebased and conflict-free whenever you get a chance to take a look.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.52%. Comparing base (057c70f) to head (56f6433).
⚠️ Report is 25 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zac-nixon

Copy link
Copy Markdown
Collaborator

/lgtm
/approved

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Gateway API] gateway.k8s.aws/nlb listeners with protocol: TLS and tls.mode: Passthrough appear to build a TLS listener

4 participants