Skip to content

Commit

Permalink
Update internal/mode/static/state/graph/route_common.go
Browse files Browse the repository at this point in the history
Co-authored-by: Saylor Berman <s.berman@f5.com>
  • Loading branch information
salonichf5 and sjberman committed Mar 3, 2025
1 parent 45651cb commit 9d41a66
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
30 changes: 24 additions & 6 deletions config/tests/static-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ metadata:
name: nginx-gateway
namespace: nginx-gateway
labels:
helm.sh/chart: nginx-gateway-fabric-1.6.1
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "edge"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
Expand All @@ -23,13 +25,16 @@ spec:
spec:
initContainers:
- name: init
image: ghcr.io/nginx/nginx-gateway-fabric:edge
imagePullPolicy: Always
image: nginx-gateway-fabric:sa.choudhary
imagePullPolicy: Never
command:
- /usr/bin/gateway
- initialize
- --source
- /includes/main.conf
- --source
- /includes/mgmt.conf
- --nginx-plus
- --destination
- /etc/nginx/main-includes
env:
Expand Down Expand Up @@ -60,6 +65,9 @@ spec:
- --gatewayclass=nginx
- --config=nginx-gateway-config
- --service=nginx-gateway
- --nginx-plus
- --usage-report-secret=nplus-license
- --usage-report-endpoint=product.connect.nginxlab.net
- --metrics-disable
- --health-port=8081
- --leader-election-lock-name=nginx-gateway-leader-election
Expand All @@ -81,8 +89,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.uid
image: ghcr.io/nginx/nginx-gateway-fabric:edge
imagePullPolicy: Always
image: nginx-gateway-fabric:sa.choudhary
imagePullPolicy: Never
name: nginx-gateway
ports:
- name: health
Expand Down Expand Up @@ -118,8 +126,8 @@ spec:
mountPath: /var/run/nginx
- name: nginx-includes
mountPath: /etc/nginx/includes
- image: ghcr.io/nginx/nginx-gateway-fabric/nginx:edge
imagePullPolicy: Always
- image: nginx-gateway-fabric/nginx-plus:sa.choudhary
imagePullPolicy: Never
name: nginx
ports:
- containerPort: 80
Expand Down Expand Up @@ -152,6 +160,11 @@ spec:
mountPath: /var/cache/nginx
- name: nginx-includes
mountPath: /etc/nginx/includes
- name: nginx-lib
mountPath: /var/lib/nginx/state
- name: nginx-plus-license
mountPath: /etc/nginx/license.jwt
subPath: license.jwt
terminationGracePeriodSeconds: 30
serviceAccountName: nginx-gateway
shareProcessNamespace: true
Expand All @@ -176,3 +189,8 @@ spec:
- name: nginx-includes-bootstrap
configMap:
name: nginx-includes-bootstrap
- name: nginx-lib
emptyDir: {}
- name: nginx-plus-license
secret:
secretName: nplus-license
14 changes: 6 additions & 8 deletions internal/mode/static/state/graph/route_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,17 @@ func getListenerHostPortMap(listeners []*Listener) map[string]hostPort {

// isolateL7RouteListeners ensures listener isolation for all L7Routes.
func isolateL7RouteListeners(routes []*L7Route, listenerHostPortMap map[string]hostPort) {
isL4Route := false
for _, route := range routes {
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, false)
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, isL4Route)
}
}

// isolateL4RouteListeners ensures listener isolation for all L4Routes.
func isolateL4RouteListeners(routes []*L4Route, listenerHostPortMap map[string]hostPort) {
isL4Route := true
for _, route := range routes {
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, true)
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, isL4Route)
}
}

Expand Down Expand Up @@ -421,12 +423,8 @@ func isolateHostnamesForParentRefs(parentRef []ParentRef, listenerHostnameMap ma
// for L4Routes, we only compare the hostname and listener name combination
// because we do not allow l4Routes to attach to the same listener
// if they share the same port and hostname.
if isL4Route {
if h == lHostPort.hostname && listenerName != lName {
hostnamesToRemoves[h] = struct{}{}
}
} else {
if h == lHostPort.hostname && listenerName != lName && lHostPort.port == ref.Attachment.ListenerPort {
if h == lHostPort.hostname && listenerName != lName {
if isL4Route || lHostPort.port == ref.Attachment.ListenerPort {
hostnamesToRemoves[h] = struct{}{}
}
}
Expand Down

0 comments on commit 9d41a66

Please sign in to comment.