Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Improve MachineSet create and delete logs #11751

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ func (r *Reconciler) reconcileDelete(ctx context.Context, s *scope) error {
// else delete owned machinesets.
for _, ms := range s.machineSets {
if ms.DeletionTimestamp.IsZero() {
log.Info("Deleting MachineSet", "MachineSet", klog.KObj(ms))
if err := r.Client.Delete(ctx, ms); err != nil && !apierrors.IsNotFound(err) {
return errors.Wrapf(err, "failed to delete MachineSet %s", klog.KObj(ms))
}
// Note: We intentionally log after Delete because we want this log line to show up only after DeletionTimestamp has been set.
// Also, setting DeletionTimestamp doesn't mean the MachineSet is actually deleted (deletion takes some time).
log.Info("Deleting MachineSet (MachineDeployment deleted)", "MachineSet", klog.KObj(ms))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,12 @@ func (r *Reconciler) createMachineSetAndWait(ctx context.Context, deployment *cl
log = log.WithValues("MachineSet", klog.KObj(newMS))
ctx = ctrl.LoggerInto(ctx, log)

log.Info(fmt.Sprintf("Creating new MachineSet, %s", createReason))

// Create the MachineSet.
if err := ssa.Patch(ctx, r.Client, machineDeploymentManagerName, newMS); err != nil {
r.recorder.Eventf(deployment, corev1.EventTypeWarning, "FailedCreate", "Failed to create MachineSet %s: %v", klog.KObj(newMS), err)
return nil, errors.Wrapf(err, "failed to create new MachineSet %s", klog.KObj(newMS))
}
log.V(4).Info("Created new MachineSet")
log.Info(fmt.Sprintf("MachineSet created (%s)", createReason))
r.recorder.Eventf(deployment, corev1.EventTypeNormal, "SuccessfulCreate", "Created MachineSet %s", klog.KObj(newMS))

// Keep trying to get the MachineSet. This will force the cache to update and prevent any future reconciliation of
Expand Down Expand Up @@ -647,6 +645,8 @@ func (r *Reconciler) cleanupDeployment(ctx context.Context, oldMSs []*clusterv1.
r.recorder.Eventf(deployment, corev1.EventTypeWarning, "FailedDelete", "Failed to delete MachineSet %q: %v", ms.Name, err)
return err
}
// Note: We intentionally log after Delete because we want this log line to show up only after DeletionTimestamp has been set.
log.Info("Deleting MachineSet (cleanup of old MachineSet)", "MachineSet", klog.KObj(ms))
r.recorder.Eventf(deployment, corev1.EventTypeNormal, "SuccessfulDelete", "Deleted MachineSet %q", ms.Name)
}

Expand Down
Loading