Skip to content

Commit 2c33217

Browse files
zhaohuabingzirain
authored andcommitted
address comment
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
1 parent 0e0b30a commit 2c33217

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

internal/xds/translator/listener.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -502,28 +502,12 @@ func hcmStatPrefix(irListener *ir.HTTPListener, nameSchemeV2 bool) string {
502502
return fmt.Sprintf("%s-%d", statPrefix, irListener.Port)
503503
}
504504

505+
// use the same name for the route config as the filter chain name, as they're 1:1 mapping.
505506
func routeConfigName(irListener *ir.HTTPListener, nameSchemeV2 bool) string {
506507
if irListener.TLS != nil {
507-
return httpsListenerRouteConfigName(irListener)
508+
return httpsListenerFilterChainName(irListener)
508509
}
509-
return httpListenerRouteConfigName(irListener, nameSchemeV2)
510-
}
511-
512-
// port value is used for the route config name for HTTP listeners. as multiple HTTP listeners on the same port are
513-
// using the same route config.
514-
func httpListenerRouteConfigName(irListener *ir.HTTPListener, nameSchemeV2 bool) string {
515-
if nameSchemeV2 {
516-
return fmt.Sprint(irListener.ExternalPort)
517-
}
518-
// For backward compatibility, we use the listener name as the route config name.
519-
return irListener.Name
520-
}
521-
522-
// irListener name is used as the route config name for HTTPS listener, as HTTPS Listener is 1:1 mapping to the filter chain,
523-
// and the HCM in each filter chain uses a unique route config.
524-
// The Gateway API layer ensures that each listener has a unique combination of hostname and port.
525-
func httpsListenerRouteConfigName(irListener *ir.HTTPListener) string {
526-
return irListener.Name
510+
return httpListenerDefaultFilterChainName(irListener, nameSchemeV2)
527511
}
528512

529513
// port value is used for the default filter chain name for HTTP listeners, as multiple HTTP listeners are merged into

internal/xds/translator/testdata/out/xds-ir/xds-name-scheme-v2.listeners.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
configSource:
2626
ads: {}
2727
resourceApiVersion: V3
28-
routeConfigName: "80"
28+
routeConfigName: http-80
2929
serverHeaderTransformation: PASS_THROUGH
3030
statPrefix: http-80
3131
useRemoteAddress: true

internal/xds/translator/testdata/out/xds-ir/xds-name-scheme-v2.routes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- ignorePortInHostMatching: true
2-
name: "80"
2+
name: http-80
33
virtualHosts:
44
- domains:
55
- foo.net

0 commit comments

Comments
 (0)