@@ -185,64 +185,67 @@ func (h *eventHandlerImpl) sendNginxConfig(
185
185
return
186
186
}
187
187
188
- if gr .Gateway == nil {
189
- // still need to update GatewayClass status
190
- obj := & status.QueueObject {
191
- UpdateType : status .UpdateAll ,
188
+ for _ , gw := range gr .Gateways {
189
+ if gw == nil {
190
+ // still need to update GatewayClass status
191
+ obj := & status.QueueObject {
192
+ UpdateType : status .UpdateAll ,
193
+ }
194
+ h .cfg .statusQueue .Enqueue (obj )
195
+ return
192
196
}
193
- h .cfg .statusQueue .Enqueue (obj )
194
- return
195
- }
196
197
197
- go func () {
198
- if err := h .cfg .nginxProvisioner .RegisterGateway (ctx , gr . Gateway , gr .DeploymentName .Name ); err != nil {
199
- logger .Error (err , "error from provisioner" )
200
- }
201
- }()
198
+ go func () {
199
+ if err := h .cfg .nginxProvisioner .RegisterGateway (ctx , gw , gw .DeploymentName .Name ); err != nil {
200
+ logger .Error (err , "error from provisioner" )
201
+ }
202
+ }()
202
203
203
- if ! gr .Gateway .Valid {
204
- obj := & status.QueueObject {
205
- Deployment : gr .DeploymentName ,
206
- UpdateType : status .UpdateAll ,
204
+ if ! gw .Valid {
205
+ obj := & status.QueueObject {
206
+ Deployment : gw .DeploymentName ,
207
+ UpdateType : status .UpdateAll ,
208
+ }
209
+ h .cfg .statusQueue .Enqueue (obj )
210
+ return
207
211
}
208
- h .cfg .statusQueue .Enqueue (obj )
209
- return
210
- }
211
212
212
- stopCh := make (chan struct {})
213
- deployment := h .cfg .nginxDeployments .GetOrStore (ctx , gr .DeploymentName , stopCh )
214
- if deployment == nil {
215
- panic ("expected deployment, got nil" )
216
- }
213
+ stopCh := make (chan struct {})
214
+ deployment := h .cfg .nginxDeployments .GetOrStore (ctx , gw .DeploymentName , stopCh )
215
+ if deployment == nil {
216
+ panic ("expected deployment, got nil" )
217
+ }
217
218
218
- configApplied := h .processStateAndBuildConfig (ctx , logger , gr , changeType , deployment )
219
+ configApplied := h .processStateAndBuildConfig (ctx , logger , gr , gw , changeType , deployment )
219
220
220
- configErr := deployment .GetLatestConfigError ()
221
- upstreamErr := deployment .GetLatestUpstreamError ()
222
- err := errors .Join (configErr , upstreamErr )
221
+ configErr := deployment .GetLatestConfigError ()
222
+ upstreamErr := deployment .GetLatestUpstreamError ()
223
+ err := errors .Join (configErr , upstreamErr )
223
224
224
- if configApplied || err != nil {
225
- obj := & status.QueueObject {
226
- UpdateType : status .UpdateAll ,
227
- Error : err ,
228
- Deployment : gr .DeploymentName ,
225
+ if configApplied || err != nil {
226
+ obj := & status.QueueObject {
227
+ UpdateType : status .UpdateAll ,
228
+ Error : err ,
229
+ Deployment : gw .DeploymentName ,
230
+ }
231
+ h .cfg .statusQueue .Enqueue (obj )
229
232
}
230
- h .cfg .statusQueue .Enqueue (obj )
231
233
}
232
234
}
233
235
234
236
func (h * eventHandlerImpl ) processStateAndBuildConfig (
235
237
ctx context.Context ,
236
238
logger logr.Logger ,
237
239
gr * graph.Graph ,
240
+ currentGateway * graph.Gateway ,
238
241
changeType state.ChangeType ,
239
242
deployment * agent.Deployment ,
240
243
) bool {
241
244
var configApplied bool
242
245
switch changeType {
243
246
case state .EndpointsOnlyChange :
244
247
h .version ++
245
- cfg := dataplane .BuildConfiguration (ctx , gr , h .cfg .serviceResolver , h .version , h .cfg .plus )
248
+ cfg := dataplane .BuildConfiguration (ctx , gr , currentGateway , h .cfg .serviceResolver , h .version , h .cfg .plus )
246
249
depCtx , getErr := h .getDeploymentContext (ctx )
247
250
if getErr != nil {
248
251
logger .Error (getErr , "error getting deployment context for usage reporting" )
@@ -260,7 +263,7 @@ func (h *eventHandlerImpl) processStateAndBuildConfig(
260
263
deployment .FileLock .Unlock ()
261
264
case state .ClusterStateChange :
262
265
h .version ++
263
- cfg := dataplane .BuildConfiguration (ctx , gr , h .cfg .serviceResolver , h .version , h .cfg .plus )
266
+ cfg := dataplane .BuildConfiguration (ctx , gr , currentGateway , h .cfg .serviceResolver , h .version , h .cfg .plus )
264
267
depCtx , getErr := h .getDeploymentContext (ctx )
265
268
if getErr != nil {
266
269
logger .Error (getErr , "error getting deployment context for usage reporting" )
@@ -292,56 +295,58 @@ func (h *eventHandlerImpl) waitForStatusUpdates(ctx context.Context) {
292
295
}
293
296
294
297
var nginxReloadRes graph.NginxReloadResult
295
- switch {
296
- case item .Error != nil :
297
- h .cfg .logger .Error (item .Error , "Failed to update NGINX configuration" )
298
- nginxReloadRes .Error = item .Error
299
- case gr .Gateway != nil :
300
- h .cfg .logger .Info ("NGINX configuration was successfully updated" )
301
- }
302
- gr .LatestReloadResult = nginxReloadRes
303
-
304
- switch item .UpdateType {
305
- case status .UpdateAll :
306
- h .updateStatuses (ctx , gr )
307
- case status .UpdateGateway :
308
- gwAddresses , err := getGatewayAddresses (
309
- ctx ,
310
- h .cfg .k8sClient ,
311
- item .GatewayService ,
312
- gr .Gateway ,
313
- h .cfg .gatewayClassName ,
314
- )
315
- if err != nil {
316
- msg := "error getting Gateway Service IP address"
317
- h .cfg .logger .Error (err , msg )
318
- h .cfg .eventRecorder .Eventf (
298
+ for _ , gw := range gr .Gateways {
299
+ switch {
300
+ case item .Error != nil :
301
+ h .cfg .logger .Error (item .Error , "Failed to update NGINX configuration" )
302
+ nginxReloadRes .Error = item .Error
303
+ case gw != nil :
304
+ h .cfg .logger .Info ("NGINX configuration was successfully updated" )
305
+ }
306
+ gr .LatestReloadResult = nginxReloadRes
307
+
308
+ switch item .UpdateType {
309
+ case status .UpdateAll :
310
+ h .updateStatuses (ctx , gr , gw )
311
+ case status .UpdateGateway :
312
+ gwAddresses , err := getGatewayAddresses (
313
+ ctx ,
314
+ h .cfg .k8sClient ,
319
315
item .GatewayService ,
320
- v1 .EventTypeWarning ,
321
- "GetServiceIPFailed" ,
322
- msg + ": %s" ,
323
- err .Error (),
316
+ gw ,
317
+ h .cfg .gatewayClassName ,
324
318
)
325
- continue
319
+ if err != nil {
320
+ msg := "error getting Gateway Service IP address"
321
+ h .cfg .logger .Error (err , msg )
322
+ h .cfg .eventRecorder .Eventf (
323
+ item .GatewayService ,
324
+ v1 .EventTypeWarning ,
325
+ "GetServiceIPFailed" ,
326
+ msg + ": %s" ,
327
+ err .Error (),
328
+ )
329
+ continue
330
+ }
331
+
332
+ transitionTime := metav1 .Now ()
333
+
334
+ gatewayStatuses := status .PrepareGatewayRequests (
335
+ gw ,
336
+ transitionTime ,
337
+ gwAddresses ,
338
+ gr .LatestReloadResult ,
339
+ )
340
+ h .cfg .statusUpdater .UpdateGroup (ctx , groupGateways , gatewayStatuses ... )
341
+ default :
342
+ panic (fmt .Sprintf ("unknown event type %T" , item .UpdateType ))
326
343
}
327
-
328
- transitionTime := metav1 .Now ()
329
- gatewayStatuses := status .PrepareGatewayRequests (
330
- gr .Gateway ,
331
- gr .IgnoredGateways ,
332
- transitionTime ,
333
- gwAddresses ,
334
- gr .LatestReloadResult ,
335
- )
336
- h .cfg .statusUpdater .UpdateGroup (ctx , groupGateways , gatewayStatuses ... )
337
- default :
338
- panic (fmt .Sprintf ("unknown event type %T" , item .UpdateType ))
339
344
}
340
345
}
341
346
}
342
347
343
- func (h * eventHandlerImpl ) updateStatuses (ctx context.Context , gr * graph.Graph ) {
344
- gwAddresses , err := getGatewayAddresses (ctx , h .cfg .k8sClient , nil , gr . Gateway , h .cfg .gatewayClassName )
348
+ func (h * eventHandlerImpl ) updateStatuses (ctx context.Context , gr * graph.Graph , gw * graph. Gateway ) {
349
+ gwAddresses , err := getGatewayAddresses (ctx , h .cfg .k8sClient , nil , gw , h .cfg .gatewayClassName )
345
350
if err != nil {
346
351
msg := "error getting Gateway Service IP address"
347
352
h .cfg .logger .Error (err , msg )
@@ -392,8 +397,7 @@ func (h *eventHandlerImpl) updateStatuses(ctx context.Context, gr *graph.Graph)
392
397
// We put Gateway status updates separately from the rest of the statuses because we want to be able
393
398
// to update them separately from the rest of the graph whenever the public IP of NGF changes.
394
399
gwReqs := status .PrepareGatewayRequests (
395
- gr .Gateway ,
396
- gr .IgnoredGateways ,
400
+ gw ,
397
401
transitionTime ,
398
402
gwAddresses ,
399
403
gr .LatestReloadResult ,
0 commit comments