From 5588a3d13795175d539356d3f318ba21b5377c85 Mon Sep 17 00:00:00 2001 From: toby cabot Date: Tue, 12 Jul 2022 09:49:39 -0400 Subject: [PATCH] Tolerate missing GWProxies when reconciling slices The Gateway is very loosely coupled so it's probably a mistake to treat missing GWProxies as an error when reconciling slices. There are many cases where it's a temporary condition so we don't want the controller to retry in a loop over and over. --- api/v1/gwendpointslice_types.go | 10 ++++++++-- controllers/gwendpointslice_controller.go | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/v1/gwendpointslice_types.go b/api/v1/gwendpointslice_types.go index 462e3e0..de639c6 100644 --- a/api/v1/gwendpointslice_types.go +++ b/api/v1/gwendpointslice_types.go @@ -84,9 +84,15 @@ func (slice *GWEndpointSlice) ReferencingProxies(ctx context.Context, cl client. proxy := GWProxy{} proxyName := types.NamespacedName{Namespace: slice.Namespace, Name: string(parent.Name)} if err := cl.Get(ctx, proxyName, &proxy); err != nil { - return refs, err + // If there's an error other than "not found" then bail + // out and report it. If we can't find the Proxy that's + // probably because it was deleted which isn't an error. + if client.IgnoreNotFound(err) != nil { + return refs, err + } + } else { + refs = append(refs, &proxy) } - refs = append(refs, &proxy) } } } diff --git a/controllers/gwendpointslice_controller.go b/controllers/gwendpointslice_controller.go index 0433543..b2a4172 100644 --- a/controllers/gwendpointslice_controller.go +++ b/controllers/gwendpointslice_controller.go @@ -48,6 +48,7 @@ func (r *GWEndpointSliceReconciler) Reconcile(ctx context.Context, req ctrl.Requ // and we can get them on deleted requests. return done, client.IgnoreNotFound(err) } + l = l.WithValues("clientName", slice.Spec.ClientRef.Name) if !slice.ObjectMeta.DeletionTimestamp.IsZero() { // This rep is marked for deletion. We need to clean up where