From 4896d23ca73521f47f1391b3620dcc1b62b952f5 Mon Sep 17 00:00:00 2001 From: Evan Baker Date: Fri, 21 Jun 2024 12:18:38 -0700 Subject: [PATCH] fix: CNS should ignore NNCs that are being deleted (#2798) Signed-off-by: Evan Baker --- cns/kubecontroller/nodenetworkconfig/reconciler.go | 4 ++++ cns/service/main.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cns/kubecontroller/nodenetworkconfig/reconciler.go b/cns/kubecontroller/nodenetworkconfig/reconciler.go index 1f859d0e1b..fdc0d6f7c4 100644 --- a/cns/kubecontroller/nodenetworkconfig/reconciler.go +++ b/cns/kubecontroller/nodenetworkconfig/reconciler.go @@ -175,6 +175,10 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager, node *v1.Node) error { return ue.ObjectOld.GetGeneration() == ue.ObjectNew.GetGeneration() }, }). + WithEventFilter(predicate.NewPredicateFuncs(func(object client.Object) bool { + // only process events on objects that are not being deleted. + return object.GetDeletionTimestamp().IsZero() + })). Complete(r) if err != nil { return errors.Wrap(err, "failed to set up reconciler with manager") diff --git a/cns/service/main.go b/cns/service/main.go index 561cafe515..d70fa654cb 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -1058,6 +1058,9 @@ func reconcileInitialCNSState(ctx context.Context, cli nodeNetworkConfigGetter, } logger.Printf("Retrieved NNC: %+v", nnc) + if !nnc.DeletionTimestamp.IsZero() { + return errors.New("failed to init CNS state: NNC is being deleted") + } // If there are no NCs, we can't initialize our state and we should fail out. if len(nnc.Status.NetworkContainers) == 0 {