Skip to content

Commit e0080f1

Browse files
arkodgmelsal13
authored andcommitted
fix: process remaining gatewayClasses after encountering an err (#5953)
fix: process all gatewayClasses after encountering an err * instead of returning from Reconcile after encountering an err which processing a `GatewayClass`, `continue` instead to process all GatewayClasses Fixes: envoyproxy/gateway#5618 Signed-off-by: Arko Dasgupta <[email protected]> Signed-off-by: melsal13 <[email protected]>
1 parent fddd0ff commit e0080f1

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

internal/provider/kubernetes/controller.go

+27-18
Original file line numberDiff line numberDiff line change
@@ -228,63 +228,72 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, _ reconcile.Reques
228228
string(gwapiv1.GatewayClassReasonInvalidParameters),
229229
msg)
230230
r.resources.GatewayClassStatuses.Store(utils.NamespacedName(gc), &gc.Status)
231-
return reconcile.Result{}, nil
231+
continue
232232
}
233233
}
234234

235235
// Add all Gateways, their associated Routes, and referenced resources to the resourceTree
236236
if err = r.processGateways(ctx, managedGC, resourceMappings, gwcResource); err != nil {
237-
return reconcile.Result{}, err
237+
r.log.Error(err, fmt.Sprintf("failed processGateways for gatewayClass %s, skipping it", managedGC.Name))
238+
continue
238239
}
239240

240241
if r.eppCRDExists {
241242
// Add all EnvoyPatchPolicies to the resourceTree
242243
if err = r.processEnvoyPatchPolicies(ctx, gwcResource, resourceMappings); err != nil {
243-
return reconcile.Result{}, err
244+
r.log.Error(err, fmt.Sprintf("failed processEnvoyPatchPolicies for gatewayClass %s, skipping it", managedGC.Name))
245+
continue
244246
}
245247
}
246248
if r.ctpCRDExists {
247249
// Add all ClientTrafficPolicies and their referenced resources to the resourceTree
248250
if err = r.processClientTrafficPolicies(ctx, gwcResource, resourceMappings); err != nil {
249-
return reconcile.Result{}, err
251+
r.log.Error(err, fmt.Sprintf("failed processClientTrafficPolicies for gatewayClass %s, skipping it", managedGC.Name))
252+
continue
250253
}
251254
}
252255

253256
if r.btpCRDExists {
254257
// Add all BackendTrafficPolicies to the resourceTree
255258
if err = r.processBackendTrafficPolicies(ctx, gwcResource, resourceMappings); err != nil {
256-
return reconcile.Result{}, err
259+
r.log.Error(err, fmt.Sprintf("failed processBackendTrafficPolicies for gatewayClass %s, skipping it", managedGC.Name))
260+
continue
257261
}
258262
}
259263

260264
if r.spCRDExists {
261265
// Add all SecurityPolicies and their referenced resources to the resourceTree
262266
if err = r.processSecurityPolicies(ctx, gwcResource, resourceMappings); err != nil {
263-
return reconcile.Result{}, err
267+
r.log.Error(err, fmt.Sprintf("failed processSecurityPolicies for gatewayClass %s, skipping it", managedGC.Name))
268+
continue
264269
}
265270
}
266271

267272
if r.bTLSPolicyCRDExists {
268273
// Add all BackendTLSPolies to the resourceTree
269274
if err = r.processBackendTLSPolicies(ctx, gwcResource, resourceMappings); err != nil {
270-
return reconcile.Result{}, err
275+
r.log.Error(err, fmt.Sprintf("failed processBackendTLSPolicies for gatewayClass %s, skipping it", managedGC.Name))
276+
continue
271277
}
272278
}
273279

274280
if r.eepCRDExists {
275281
// Add all EnvoyExtensionPolicies and their referenced resources to the resourceTree
276282
if err = r.processEnvoyExtensionPolicies(ctx, gwcResource, resourceMappings); err != nil {
277-
return reconcile.Result{}, err
283+
r.log.Error(err, fmt.Sprintf("failed processEnvoyExtensionPolicies for gatewayClass %s, skipping it", managedGC.Name))
284+
continue
278285
}
279286
}
280287

281288
if err = r.processExtensionServerPolicies(ctx, gwcResource); err != nil {
282-
return reconcile.Result{}, err
289+
r.log.Error(err, fmt.Sprintf("failed processExtensionServerPolicies for gatewayClass %s, skipping it", managedGC.Name))
290+
continue
283291
}
284292

285293
if r.backendCRDExists {
286294
if err = r.processBackends(ctx, gwcResource); err != nil {
287-
return reconcile.Result{}, err
295+
r.log.Error(err, fmt.Sprintf("failed processBackends for gatewayClass %s, skipping it", managedGC.Name))
296+
continue
288297
}
289298
}
290299

@@ -300,9 +309,9 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, _ reconcile.Reques
300309
if err != nil {
301310
r.log.Error(err, "unable to find the namespace")
302311
if kerrors.IsNotFound(err) {
303-
return reconcile.Result{}, nil
312+
continue
304313
}
305-
return reconcile.Result{}, err
314+
continue
306315
}
307316

308317
gwcResource.Namespaces = append(gwcResource.Namespaces, namespace)
@@ -326,20 +335,20 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, _ reconcile.Reques
326335
r.resources.GatewayClassStatuses.Store(utils.NamespacedName(gc), &gc.Status)
327336

328337
if len(gwcResource.Gateways) == 0 {
329-
r.log.Info("No gateways found for accepted gatewayclass")
338+
r.log.Info("No gateways found for accepted gatewayClass")
330339

331340
// If needed, remove the finalizer from the accepted GatewayClass.
332341
if err := r.removeFinalizer(ctx, managedGC); err != nil {
333-
r.log.Error(err, fmt.Sprintf("failed to remove finalizer from gatewayclass %s",
342+
r.log.Error(err, fmt.Sprintf("failed to remove finalizer from gatewayClass %s",
334343
managedGC.Name))
335-
return reconcile.Result{}, err
344+
continue
336345
}
337346
} else {
338347
// finalize the accepted GatewayClass.
339348
if err := r.addFinalizer(ctx, managedGC); err != nil {
340-
r.log.Error(err, fmt.Sprintf("failed adding finalizer to gatewayclass %s",
349+
r.log.Error(err, fmt.Sprintf("failed adding finalizer to gatewayClass %s",
341350
managedGC.Name))
342-
return reconcile.Result{}, err
351+
continue
343352
}
344353
}
345354
}
@@ -1046,7 +1055,7 @@ func (r *gatewayAPIReconciler) processGateways(ctx context.Context, managedGC *g
10461055
if err := r.client.List(ctx, gatewayList, &client.ListOptions{
10471056
FieldSelector: fields.OneTermEqualSelector(classGatewayIndex, managedGC.Name),
10481057
}); err != nil {
1049-
r.log.Info("no associated Gateways found for GatewayClass", "name", managedGC.Name)
1058+
r.log.Error(err, "failed to list gateways for gatewayClass %s", managedGC.Name)
10501059
return err
10511060
}
10521061

0 commit comments

Comments
 (0)