Skip to content

Commit 9d41a66

Browse files
salonichf5sjberman
andcommitted
Update internal/mode/static/state/graph/route_common.go
Co-authored-by: Saylor Berman <[email protected]>
1 parent 45651cb commit 9d41a66

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

config/tests/static-deployment.yaml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ metadata:
66
name: nginx-gateway
77
namespace: nginx-gateway
88
labels:
9+
helm.sh/chart: nginx-gateway-fabric-1.6.1
910
app.kubernetes.io/name: nginx-gateway
1011
app.kubernetes.io/instance: nginx-gateway
1112
app.kubernetes.io/version: "edge"
13+
app.kubernetes.io/managed-by: Helm
1214
spec:
1315
replicas: 1
1416
selector:
@@ -23,13 +25,16 @@ spec:
2325
spec:
2426
initContainers:
2527
- name: init
26-
image: ghcr.io/nginx/nginx-gateway-fabric:edge
27-
imagePullPolicy: Always
28+
image: nginx-gateway-fabric:sa.choudhary
29+
imagePullPolicy: Never
2830
command:
2931
- /usr/bin/gateway
3032
- initialize
3133
- --source
3234
- /includes/main.conf
35+
- --source
36+
- /includes/mgmt.conf
37+
- --nginx-plus
3338
- --destination
3439
- /etc/nginx/main-includes
3540
env:
@@ -60,6 +65,9 @@ spec:
6065
- --gatewayclass=nginx
6166
- --config=nginx-gateway-config
6267
- --service=nginx-gateway
68+
- --nginx-plus
69+
- --usage-report-secret=nplus-license
70+
- --usage-report-endpoint=product.connect.nginxlab.net
6371
- --metrics-disable
6472
- --health-port=8081
6573
- --leader-election-lock-name=nginx-gateway-leader-election
@@ -81,8 +89,8 @@ spec:
8189
valueFrom:
8290
fieldRef:
8391
fieldPath: metadata.uid
84-
image: ghcr.io/nginx/nginx-gateway-fabric:edge
85-
imagePullPolicy: Always
92+
image: nginx-gateway-fabric:sa.choudhary
93+
imagePullPolicy: Never
8694
name: nginx-gateway
8795
ports:
8896
- name: health
@@ -118,8 +126,8 @@ spec:
118126
mountPath: /var/run/nginx
119127
- name: nginx-includes
120128
mountPath: /etc/nginx/includes
121-
- image: ghcr.io/nginx/nginx-gateway-fabric/nginx:edge
122-
imagePullPolicy: Always
129+
- image: nginx-gateway-fabric/nginx-plus:sa.choudhary
130+
imagePullPolicy: Never
123131
name: nginx
124132
ports:
125133
- containerPort: 80
@@ -152,6 +160,11 @@ spec:
152160
mountPath: /var/cache/nginx
153161
- name: nginx-includes
154162
mountPath: /etc/nginx/includes
163+
- name: nginx-lib
164+
mountPath: /var/lib/nginx/state
165+
- name: nginx-plus-license
166+
mountPath: /etc/nginx/license.jwt
167+
subPath: license.jwt
155168
terminationGracePeriodSeconds: 30
156169
serviceAccountName: nginx-gateway
157170
shareProcessNamespace: true
@@ -176,3 +189,8 @@ spec:
176189
- name: nginx-includes-bootstrap
177190
configMap:
178191
name: nginx-includes-bootstrap
192+
- name: nginx-lib
193+
emptyDir: {}
194+
- name: nginx-plus-license
195+
secret:
196+
secretName: nplus-license

internal/mode/static/state/graph/route_common.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,17 @@ func getListenerHostPortMap(listeners []*Listener) map[string]hostPort {
383383

384384
// isolateL7RouteListeners ensures listener isolation for all L7Routes.
385385
func isolateL7RouteListeners(routes []*L7Route, listenerHostPortMap map[string]hostPort) {
386+
isL4Route := false
386387
for _, route := range routes {
387-
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, false)
388+
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, isL4Route)
388389
}
389390
}
390391

391392
// isolateL4RouteListeners ensures listener isolation for all L4Routes.
392393
func isolateL4RouteListeners(routes []*L4Route, listenerHostPortMap map[string]hostPort) {
394+
isL4Route := true
393395
for _, route := range routes {
394-
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, true)
396+
isolateHostnamesForParentRefs(route.ParentRefs, listenerHostPortMap, isL4Route)
395397
}
396398
}
397399

@@ -421,12 +423,8 @@ func isolateHostnamesForParentRefs(parentRef []ParentRef, listenerHostnameMap ma
421423
// for L4Routes, we only compare the hostname and listener name combination
422424
// because we do not allow l4Routes to attach to the same listener
423425
// if they share the same port and hostname.
424-
if isL4Route {
425-
if h == lHostPort.hostname && listenerName != lName {
426-
hostnamesToRemoves[h] = struct{}{}
427-
}
428-
} else {
429-
if h == lHostPort.hostname && listenerName != lName && lHostPort.port == ref.Attachment.ListenerPort {
426+
if h == lHostPort.hostname && listenerName != lName {
427+
if isL4Route || lHostPort.port == ref.Attachment.ListenerPort {
430428
hostnamesToRemoves[h] = struct{}{}
431429
}
432430
}

0 commit comments

Comments
 (0)