Skip to content

Commit

Permalink
Merge pull request #8108 from schrej/machine-deletion-logging
Browse files Browse the repository at this point in the history
🌱 improve logging during Machine deletion
  • Loading branch information
k8s-ci-robot authored Feb 15, 2023
2 parents 9c5fdae + 088d4af commit 1a5c13c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ func (r *Reconciler) reconcileDelete(ctx context.Context, cluster *clusterv1.Clu
// After node draining is completed, and if isNodeVolumeDetachingAllowed returns True, make sure all
// volumes are detached before proceeding to delete the Node.
if r.isNodeVolumeDetachingAllowed(m) {
log.Info("Waiting for node volumes to be detached", "Node", klog.KRef("", m.Status.NodeRef.Name))

// The VolumeDetachSucceededCondition never exists before we wait for volume detachment for the first time,
// so its transition time can be used to record the first time we wait for volume detachment.
// This `if` condition prevents the transition time to be changed more than once.
Expand Down Expand Up @@ -411,13 +409,23 @@ func (r *Reconciler) reconcileDelete(ctx context.Context, cluster *clusterv1.Clu
return ctrl.Result{}, errors.Wrap(err, "failed to patch Machine")
}

if ok, err := r.reconcileDeleteInfrastructure(ctx, m); !ok || err != nil {
infrastructureDeleted, err := r.reconcileDeleteInfrastructure(ctx, m)
if err != nil {
return ctrl.Result{}, err
}
if !infrastructureDeleted {
log.Info("Waiting for infrastructure to be deleted", m.Spec.InfrastructureRef.Kind, klog.KRef(m.Spec.InfrastructureRef.Namespace, m.Spec.InfrastructureRef.Name))
return ctrl.Result{}, nil
}

if ok, err := r.reconcileDeleteBootstrap(ctx, m); !ok || err != nil {
bootstrapDeleted, err := r.reconcileDeleteBootstrap(ctx, m)
if err != nil {
return ctrl.Result{}, err
}
if !bootstrapDeleted {
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))
return ctrl.Result{}, nil
}

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

0 comments on commit 1a5c13c

Please sign in to comment.