Skip to content

Commit

Permalink
Retry Node delete when CCT is locked
Browse files Browse the repository at this point in the history
Signed-off-by: killianmuldoon <[email protected]>
  • Loading branch information
killianmuldoon authored and k8s-infra-cherrypick-robot committed Oct 19, 2023
1 parent 99dc50f commit a22a763
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,11 @@ func (r *Reconciler) drainNode(ctx context.Context, cluster *clusterv1.Cluster,

restConfig, err := remote.RESTConfig(ctx, controllerName, r.Client, util.ObjectKey(cluster))
if err != nil {
log.Error(err, "Error creating a remote client while deleting Machine, won't retry")
if errors.Is(err, remote.ErrClusterLocked) {
log.V(5).Info("Requeuing drain Node because another worker has the lock on the ClusterCacheTracker")
return ctrl.Result{Requeue: true}, nil
}
log.Error(err, "Error creating a remote client for cluster while draining Node, won't retry")
return ctrl.Result{}, nil
}
kubeClient, err := kubernetes.NewForConfig(restConfig)
Expand Down Expand Up @@ -676,7 +680,10 @@ func (r *Reconciler) deleteNode(ctx context.Context, cluster *clusterv1.Cluster,

remoteClient, err := r.Tracker.GetClient(ctx, util.ObjectKey(cluster))
if err != nil {
log.Error(err, "Error creating a remote client for cluster while deleting Machine, won't retry")
if errors.Is(err, remote.ErrClusterLocked) {
return errors.Wrapf(err, "failed deleting Node because another worker has the lock on the ClusterCacheTracker")
}
log.Error(err, "Error creating a remote client for cluster while deleting Node, won't retry")
return nil
}

Expand Down

0 comments on commit a22a763

Please sign in to comment.