Skip to content

Commit

Permalink
fix: CNS should ignore NNCs that are being deleted (#2798) (#2850)
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Baker <[email protected]>
  • Loading branch information
rbtr authored Jul 17, 2024
1 parent 5ab954c commit a91dcf5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cns/kubecontroller/nodenetworkconfig/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,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")
Expand Down
3 changes: 3 additions & 0 deletions cns/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,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 {
Expand Down

0 comments on commit a91dcf5

Please sign in to comment.