@@ -357,14 +357,10 @@ func (r vmReconciler) reconcileDelete(ctx context.Context, vmCtx *capvcontext.VM
357
357
}
358
358
359
359
// 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 )
361
361
if err != nil {
362
362
log .Error (err , "Failed to delete Node (best-effort)" )
363
363
}
364
- if ! result .IsZero () {
365
- // a non-zero value means we need to requeue the request before proceed.
366
- return result , nil
367
- }
368
364
369
365
if err := r .deleteIPAddressClaims (ctx , vmCtx ); err != nil {
370
366
return reconcile.Result {}, err
@@ -382,26 +378,27 @@ func (r vmReconciler) reconcileDelete(ctx context.Context, vmCtx *capvcontext.VM
382
378
// This is necessary since CAPI does not surface the nodeRef field on the owner Machine object
383
379
// until the node moves to Ready state. Hence, on Machine deletion it is unable to delete
384
380
// 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 {
386
383
log := ctrl .LoggerFrom (ctx )
387
384
// Fetching the cluster object from the VSphereVM object to create a remote client to the cluster
388
385
cluster , err := clusterutilv1 .GetClusterFromMetadata (ctx , r .Client , vmCtx .VSphereVM .ObjectMeta )
389
386
if err != nil {
390
- return ctrl. Result {}, err
387
+ return err
391
388
}
392
389
393
390
// Skip deleting the Node if the cluster is being deleted.
394
391
if ! cluster .DeletionTimestamp .IsZero () {
395
- return ctrl. Result {}, nil
392
+ return nil
396
393
}
397
394
398
395
clusterClient , err := r .clusterCache .GetClient (ctx , ctrlclient .ObjectKeyFromObject (cluster ))
399
396
if err != nil {
400
397
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
403
400
}
404
- return ctrl. Result {}, err
401
+ return err
405
402
}
406
403
407
404
// Attempt to delete the corresponding node
@@ -410,7 +407,7 @@ func (r vmReconciler) deleteNode(ctx context.Context, vmCtx *capvcontext.VMConte
410
407
Name : name ,
411
408
},
412
409
}
413
- return ctrl. Result {}, clusterClient .Delete (ctx , node )
410
+ return clusterClient .Delete (ctx , node )
414
411
}
415
412
416
413
func (r vmReconciler ) reconcileNormal (ctx context.Context , vmCtx * capvcontext.VMContext ) (reconcile.Result , error ) {
0 commit comments