Skip to content
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

fix(MeshGateway): ensure that duplicate listeners are not added when crossMesh is enabled on a listener and Routes specify hostnames #8156

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/plugins/runtime/gateway/filter_chain_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (g *HTTPSFilterChainGenerator) Generate(

var filterChainBuilders []*envoy_listeners.FilterChainBuilder

if info.Listener.CrossMesh {
// For cross-mesh, we can only add one listener filter chain as there will not be any (usable) SNI available for filter chain matching
hosts = hosts[:1]
}
for _, host := range hosts {
log.V(1).Info("generating filter chain", "hostname", host.Hostname)

Expand Down
96 changes: 93 additions & 3 deletions pkg/plugins/runtime/gateway/gateway_route_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1440,30 +1440,120 @@ conf:
- port: 8080
protocol: HTTP
crossMesh: true
- port: 8081
protocol: HTTP
crossMesh: true
hostname: internal-cross-mesh.mesh
tags:
hostname: internal-cross-mesh.mesh
- port: 8082
protocol: HTTP
crossMesh: true
tags:
hostname: route-only
`, `
type: MeshGatewayRoute
mesh: default
name: echo-service
name: echo-service-default
selectors:
- match:
kuma.io/service: gateway-default
conf:
http:
rules:
- matches:
- path:
match: PREFIX
value: "/ext"
backends:
- destination:
kuma.io/service: external-httpbin
- matches:
- path:
match: PREFIX
value: "/echo"
backends:
- destination:
kuma.io/service: echo-service
`, `
type: MeshGatewayRoute
mesh: default
name: echo-service-with-hostname
selectors:
- match:
kuma.io/service: gateway-default
hostname: route-only
conf:
http:
hostnames:
- cross-mesh.mesh
- cross-mesh2.mesh
rules:
- matches:
- path:
match: PREFIX
value: "/ext"
value: "/hostname-ext"
backends:
- destination:
kuma.io/service: external-httpbin
- matches:
- path:
match: PREFIX
value: "/echo"
value: "/hostname-echo"
backends:
- destination:
kuma.io/service: echo-service
`, `
type: MeshGatewayRoute
mesh: default
name: echo-service-with-hostname-and-hostname-on-listener
selectors:
- match:
kuma.io/service: gateway-default
hostname: internal-cross-mesh.mesh
conf:
http:
hostnames:
- cross-mesh.mesh
rules:
- matches:
- path:
match: PREFIX
value: "/hostname-and-hostname-on-listener-no-match-ext"
backends:
- destination:
kuma.io/service: external-httpbin
- matches:
- path:
match: PREFIX
value: "/hostname-and-hostname-on-listener-no-match-echo"
backends:
- destination:
kuma.io/service: echo-service
`, `
type: MeshGatewayRoute
mesh: default
name: echo-service-with-hostname-and-different-hostname-on-listener
selectors:
- match:
kuma.io/service: gateway-default
hostname: internal-cross-mesh.mesh
conf:
http:
hostnames:
- internal-cross-mesh.mesh
rules:
- matches:
- path:
match: PREFIX
value: "/hostname-and-hostname-on-listener-match-ext"
backends:
- destination:
kuma.io/service: external-httpbin
- matches:
- path:
match: PREFIX
value: "/hostname-and-hostname-on-listener-match-echo"
backends:
- destination:
kuma.io/service: echo-service
Expand Down
Loading
Loading