Skip to content

Commit 1a5c13c

Browse files
authored
Merge pull request #8108 from schrej/machine-deletion-logging
🌱 improve logging during Machine deletion
2 parents 9c5fdae + 088d4af commit 1a5c13c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

internal/controllers/machine/machine_controller.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ func (r *Reconciler) reconcileDelete(ctx context.Context, cluster *clusterv1.Clu
368368
// After node draining is completed, and if isNodeVolumeDetachingAllowed returns True, make sure all
369369
// volumes are detached before proceeding to delete the Node.
370370
if r.isNodeVolumeDetachingAllowed(m) {
371-
log.Info("Waiting for node volumes to be detached", "Node", klog.KRef("", m.Status.NodeRef.Name))
372-
373371
// The VolumeDetachSucceededCondition never exists before we wait for volume detachment for the first time,
374372
// so its transition time can be used to record the first time we wait for volume detachment.
375373
// This `if` condition prevents the transition time to be changed more than once.
@@ -411,13 +409,23 @@ func (r *Reconciler) reconcileDelete(ctx context.Context, cluster *clusterv1.Clu
411409
return ctrl.Result{}, errors.Wrap(err, "failed to patch Machine")
412410
}
413411

414-
if ok, err := r.reconcileDeleteInfrastructure(ctx, m); !ok || err != nil {
412+
infrastructureDeleted, err := r.reconcileDeleteInfrastructure(ctx, m)
413+
if err != nil {
415414
return ctrl.Result{}, err
416415
}
416+
if !infrastructureDeleted {
417+
log.Info("Waiting for infrastructure to be deleted", m.Spec.InfrastructureRef.Kind, klog.KRef(m.Spec.InfrastructureRef.Namespace, m.Spec.InfrastructureRef.Name))
418+
return ctrl.Result{}, nil
419+
}
417420

418-
if ok, err := r.reconcileDeleteBootstrap(ctx, m); !ok || err != nil {
421+
bootstrapDeleted, err := r.reconcileDeleteBootstrap(ctx, m)
422+
if err != nil {
419423
return ctrl.Result{}, err
420424
}
425+
if !bootstrapDeleted {
426+
log.Info("Waiting for bootstrap to be deleted", m.Spec.Bootstrap.ConfigRef.Kind, klog.KRef(m.Spec.Bootstrap.ConfigRef.Namespace, m.Spec.Bootstrap.ConfigRef.Name))
427+
return ctrl.Result{}, nil
428+
}
421429

422430
// We only delete the node after the underlying infrastructure is gone.
423431
// https://github.com/kubernetes-sigs/cluster-api/issues/2565

0 commit comments

Comments
 (0)