Skip to content

fix: rename listener using its protocol and port #6544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Jul 30, 2025

Conversation

zhaohuabing
Copy link
Member

@zhaohuabing zhaohuabing commented Jul 17, 2025

Why do we need this PR?

Currently, the xDS listener is named after one of the owning Gateway Listeners. When multiple Gateway Listeners are configured listening on the same port, the generated xDS listener name is derived from a randomly selected Gateway Listener. This can cause unnecessary listener drains in Envoy if one of the Gateway Listeners is deleted or a new one is created using the same port.

To solve this issue, we need to rename the xDS listener to keep it consistent on the same port.

Some prior arts in this area

Project listener filterChain routeConfig virtualHost route
Istio(http) 0.0.0.0_80 http.80 httpbin.example.com:80 default.httpbin.0
Istio(https) 0.0.0.0_443 https.443.default.mygateway-istio-autogenerated-k8s-gateway-https.istio-system httpbin.example.com:443 default.httpbin.0
contour(http) 0.0.0.0_80 ingress_http *
kageway(http) http1~http2 http-1 http-1 I didn't find virtual hosts in RoutConfig - it seems a bug.
kageway(https) https-1~https-2 https-1/https-2 https-1/https-2 https-1~foo_example_com https-1~foo_example_com-route-0-httproute-httpbin-https-httpbin-0-0-matcher-0

From what I'v seen in these projects, there are two approaches for the xDS listener naming scheme:

  • ip_port 0.0.0.0_443 - we've discussed that we don't want the 0.0.0.0 part as all the user listeners are listening on 0.0.0.0, and we'll need protocol prefix because EG also supports UDP.
  • Gateway Listener name, the listener name is concatenated when multiple listeners share the same port. https-1~https-2 - we shouldn't consider this patter as this will also cause xDS listener to drain.

This PR resolves the issue by naming the xDS listener based on its listening port and protocol, ensuring consistent naming even when multiple Gateways share the same port.

Proposed xDS listener scheme

  1. Named after the listening port and protocol.
    default/gateway-1/http, after: tcp-80
    default/gateway-1/https, after: tcp-443
    default/gateway-1/tls, after: tcp-443
    default/gateway-1/tcp, after: tcp-81
    default/gateway-1/udp, after: udp-82

  2. Named after the listening port and application protocol.
    default/gateway-1/http, after: http-80
    default/gateway-1/https, after: https-443
    default/gateway-1/tls, after: tls-443
    default/gateway-1/tcp, after: tcp-81
    default/gateway-1/udp, after: udp-82

For each option, the listener statPrefix will also be renamed using the same xDS listener name.

I'm leaning slightly toward option2 - unless we need to support combinations of http/https/tcp/tls on the same port, and we can fall back to tcp-port for that.

Update: final decision is option 1.

The name of FilterChain name, RouteConfig, VirtualHost have, and listener statPrefix are also changed accordingly. move to a separate PR to limit the scope of this one.

Notice: xDS listener is a de-fact API surface - it's used by EnvoyPatchPolicy and ExtensionManager to modify xDS resources, and users may rely on it for configuring metrics or monitoring. To avoid introducing breaking change in v1.5 ,this change is gated by the XDSNameSchemeV2 runtime flag. This flag is disabled by default in v1.5, and it will be enabled in v1.6.

This PR also:

  • Adds Gateway Resource to the Listener metadata, so the ExtensionManager can use them as a replacement of the previous listener name if the Gateway and Listener resource names are required in its mutation processing. move to a separate PR to limit the scope of this one.

fix: #6534
release-note: yes

@zhaohuabing zhaohuabing requested a review from a team as a code owner July 17, 2025 09:02
@zhaohuabing zhaohuabing marked this pull request as draft July 17, 2025 09:02
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

❌ Patch coverage is 72.41379% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.15%. Comparing base (288e713) to head (e08d884).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
api/v1alpha1/envoygateway_helpers.go 42.85% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6544      +/-   ##
==========================================
+ Coverage   71.08%   71.15%   +0.07%     
==========================================
  Files         225      225              
  Lines       39264    39348      +84     
==========================================
+ Hits        27911    27999      +88     
+ Misses       9738     9736       -2     
+ Partials     1615     1613       -2     

☔ 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.

Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
@zhaohuabing zhaohuabing changed the title fix: rename listener using its address and port fix: rename listener using its protocol and port Jul 30, 2025
@zhaohuabing zhaohuabing marked this pull request as ready for review July 30, 2025 03:56
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
@zhaohuabing zhaohuabing requested a review from arkodg July 30, 2025 05:15
Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@zhaohuabing zhaohuabing enabled auto-merge (squash) July 30, 2025 05:37
@zhaohuabing zhaohuabing disabled auto-merge July 30, 2025 06:26
@zirain zirain enabled auto-merge (squash) July 30, 2025 06:31
@zhaohuabing zhaohuabing disabled auto-merge July 30, 2025 06:34
@zhaohuabing zhaohuabing merged commit 62c34a0 into envoyproxy:main Jul 30, 2025
49 of 51 checks passed
@zhaohuabing zhaohuabing deleted the fix-6534 branch July 30, 2025 07:24
@zhaohuabing zhaohuabing restored the fix-6534 branch July 30, 2025 08:20
@zhaohuabing zhaohuabing deleted the fix-6534 branch July 30, 2025 08:20
This was referenced Jul 30, 2025
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.

Unexpected listener draining upon gateway deletion on mergeGateways mode
5 participants