Skip to content

Commit 85671a5

Browse files
arkodgguydc
authored andcommitted
fix: process remaining gatewayClasses after encountering an err (envoyproxy#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#5618 Signed-off-by: Arko Dasgupta <[email protected]> (cherry picked from commit 64845fe) Signed-off-by: Guy Daich <[email protected]>
1 parent 7c9f0d9 commit 85671a5

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
@@ -215,63 +215,72 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, _ reconcile.Reques
215215
string(gwapiv1.GatewayClassReasonInvalidParameters),
216216
msg)
217217
r.resources.GatewayClassStatuses.Store(utils.NamespacedName(gc), &gc.Status)
218-
return reconcile.Result{}, nil
218+
continue
219219
}
220220
}
221221

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

227228
if r.eppCRDExists {
228229
// Add all EnvoyPatchPolicies to the resourceTree
229230
if err = r.processEnvoyPatchPolicies(ctx, gwcResource, resourceMappings); err != nil {
230-
return reconcile.Result{}, err
231+
r.log.Error(err, fmt.Sprintf("failed processEnvoyPatchPolicies for gatewayClass %s, skipping it", managedGC.Name))
232+
continue
231233
}
232234
}
233235
if r.ctpCRDExists {
234236
// Add all ClientTrafficPolicies and their referenced resources to the resourceTree
235237
if err = r.processClientTrafficPolicies(ctx, gwcResource, resourceMappings); err != nil {
236-
return reconcile.Result{}, err
238+
r.log.Error(err, fmt.Sprintf("failed processClientTrafficPolicies for gatewayClass %s, skipping it", managedGC.Name))
239+
continue
237240
}
238241
}
239242

240243
if r.btpCRDExists {
241244
// Add all BackendTrafficPolicies to the resourceTree
242245
if err = r.processBackendTrafficPolicies(ctx, gwcResource, resourceMappings); err != nil {
243-
return reconcile.Result{}, err
246+
r.log.Error(err, fmt.Sprintf("failed processBackendTrafficPolicies for gatewayClass %s, skipping it", managedGC.Name))
247+
continue
244248
}
245249
}
246250

247251
if r.spCRDExists {
248252
// Add all SecurityPolicies and their referenced resources to the resourceTree
249253
if err = r.processSecurityPolicies(ctx, gwcResource, resourceMappings); err != nil {
250-
return reconcile.Result{}, err
254+
r.log.Error(err, fmt.Sprintf("failed processSecurityPolicies for gatewayClass %s, skipping it", managedGC.Name))
255+
continue
251256
}
252257
}
253258

254259
if r.bTLSPolicyCRDExists {
255260
// Add all BackendTLSPolies to the resourceTree
256261
if err = r.processBackendTLSPolicies(ctx, gwcResource, resourceMappings); err != nil {
257-
return reconcile.Result{}, err
262+
r.log.Error(err, fmt.Sprintf("failed processBackendTLSPolicies for gatewayClass %s, skipping it", managedGC.Name))
263+
continue
258264
}
259265
}
260266

261267
if r.eepCRDExists {
262268
// Add all EnvoyExtensionPolicies and their referenced resources to the resourceTree
263269
if err = r.processEnvoyExtensionPolicies(ctx, gwcResource, resourceMappings); err != nil {
264-
return reconcile.Result{}, err
270+
r.log.Error(err, fmt.Sprintf("failed processEnvoyExtensionPolicies for gatewayClass %s, skipping it", managedGC.Name))
271+
continue
265272
}
266273
}
267274

268275
if err = r.processExtensionServerPolicies(ctx, gwcResource); err != nil {
269-
return reconcile.Result{}, err
276+
r.log.Error(err, fmt.Sprintf("failed processExtensionServerPolicies for gatewayClass %s, skipping it", managedGC.Name))
277+
continue
270278
}
271279

272280
if r.backendCRDExists {
273281
if err = r.processBackends(ctx, gwcResource); err != nil {
274-
return reconcile.Result{}, err
282+
r.log.Error(err, fmt.Sprintf("failed processBackends for gatewayClass %s, skipping it", managedGC.Name))
283+
continue
275284
}
276285
}
277286

@@ -287,9 +296,9 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, _ reconcile.Reques
287296
if err != nil {
288297
r.log.Error(err, "unable to find the namespace")
289298
if kerrors.IsNotFound(err) {
290-
return reconcile.Result{}, nil
299+
continue
291300
}
292-
return reconcile.Result{}, err
301+
continue
293302
}
294303

295304
gwcResource.Namespaces = append(gwcResource.Namespaces, namespace)
@@ -313,20 +322,20 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, _ reconcile.Reques
313322
r.resources.GatewayClassStatuses.Store(utils.NamespacedName(gc), &gc.Status)
314323

315324
if len(gwcResource.Gateways) == 0 {
316-
r.log.Info("No gateways found for accepted gatewayclass")
325+
r.log.Info("No gateways found for accepted gatewayClass")
317326

318327
// If needed, remove the finalizer from the accepted GatewayClass.
319328
if err := r.removeFinalizer(ctx, managedGC); err != nil {
320-
r.log.Error(err, fmt.Sprintf("failed to remove finalizer from gatewayclass %s",
329+
r.log.Error(err, fmt.Sprintf("failed to remove finalizer from gatewayClass %s",
321330
managedGC.Name))
322-
return reconcile.Result{}, err
331+
continue
323332
}
324333
} else {
325334
// finalize the accepted GatewayClass.
326335
if err := r.addFinalizer(ctx, managedGC); err != nil {
327-
r.log.Error(err, fmt.Sprintf("failed adding finalizer to gatewayclass %s",
336+
r.log.Error(err, fmt.Sprintf("failed adding finalizer to gatewayClass %s",
328337
managedGC.Name))
329-
return reconcile.Result{}, err
338+
continue
330339
}
331340
}
332341
}
@@ -952,7 +961,7 @@ func (r *gatewayAPIReconciler) processGateways(ctx context.Context, managedGC *g
952961
if err := r.client.List(ctx, gatewayList, &client.ListOptions{
953962
FieldSelector: fields.OneTermEqualSelector(classGatewayIndex, managedGC.Name),
954963
}); err != nil {
955-
r.log.Info("no associated Gateways found for GatewayClass", "name", managedGC.Name)
964+
r.log.Error(err, "failed to list gateways for gatewayClass %s", managedGC.Name)
956965
return err
957966
}
958967

0 commit comments

Comments
 (0)