@@ -357,14 +357,10 @@ func (r vmReconciler) reconcileDelete(ctx context.Context, vmCtx *capvcontext.VM
357357 }
358358
359359 // Attempt to delete the node corresponding to the vsphere VM
360- result , err = r .deleteNode (ctx , vmCtx , vm .Name )
360+ err = r .deleteNode (ctx , vmCtx , vm .Name )
361361 if err != nil {
362362 log .Error (err , "Failed to delete Node (best-effort)" )
363363 }
364- if ! result .IsZero () {
365- // a non-zero value means we need to requeue the request before proceed.
366- return result , nil
367- }
368364
369365 if err := r .deleteIPAddressClaims (ctx , vmCtx ); err != nil {
370366 return reconcile.Result {}, err
@@ -382,26 +378,27 @@ func (r vmReconciler) reconcileDelete(ctx context.Context, vmCtx *capvcontext.VM
382378// This is necessary since CAPI does not surface the nodeRef field on the owner Machine object
383379// until the node moves to Ready state. Hence, on Machine deletion it is unable to delete
384380// the kubernetes node corresponding to the VM.
385- func (r vmReconciler ) deleteNode (ctx context.Context , vmCtx * capvcontext.VMContext , name string ) (reconcile.Result , error ) {
381+ // Note: If this fails, CPI normally cleans up orphaned nodes.
382+ func (r vmReconciler ) deleteNode (ctx context.Context , vmCtx * capvcontext.VMContext , name string ) error {
386383 log := ctrl .LoggerFrom (ctx )
387384 // Fetching the cluster object from the VSphereVM object to create a remote client to the cluster
388385 cluster , err := clusterutilv1 .GetClusterFromMetadata (ctx , r .Client , vmCtx .VSphereVM .ObjectMeta )
389386 if err != nil {
390- return ctrl. Result {}, err
387+ return err
391388 }
392389
393390 // Skip deleting the Node if the cluster is being deleted.
394391 if ! cluster .DeletionTimestamp .IsZero () {
395- return ctrl. Result {}, nil
392+ return nil
396393 }
397394
398395 clusterClient , err := r .clusterCache .GetClient (ctx , ctrlclient .ObjectKeyFromObject (cluster ))
399396 if err != nil {
400397 if errors .Is (err , clustercache .ErrClusterNotConnected ) {
401- log .V (5 ).Info ("Requeuing because connection to the workload cluster is down" )
402- return ctrl. Result { RequeueAfter : time . Minute }, nil
398+ log .V (2 ).Info ("Skipping node deletion because connection to the workload cluster is down" )
399+ return nil
403400 }
404- return ctrl. Result {}, err
401+ return err
405402 }
406403
407404 // Attempt to delete the corresponding node
@@ -410,7 +407,7 @@ func (r vmReconciler) deleteNode(ctx context.Context, vmCtx *capvcontext.VMConte
410407 Name : name ,
411408 },
412409 }
413- return ctrl. Result {}, clusterClient .Delete (ctx , node )
410+ return clusterClient .Delete (ctx , node )
414411}
415412
416413func (r vmReconciler ) reconcileNormal (ctx context.Context , vmCtx * capvcontext.VMContext ) (reconcile.Result , error ) {
0 commit comments