Skip to content

Commit

Permalink
Improve Machine remediation logs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Jan 16, 2025
1 parent 07d97c6 commit 516eedc
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,11 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
// mark for remediation
errList := []error{}
for _, t := range unhealthy {
logger := logger.WithValues("Machine", klog.KObj(t.Machine), "Node", klog.KObj(t.Node))
condition := conditions.Get(t.Machine, clusterv1.MachineHealthCheckSucceededCondition)

if annotations.IsPaused(cluster, t.Machine) {
logger.Info("Machine has failed health check, but machine is paused so skipping remediation", "target", t.string(), "reason", condition.Reason, "message", condition.Message)
logger.Info("Machine has failed health check, but machine is paused so skipping remediation", "reason", condition.Reason, "message", condition.Message)
} else {
if m.Spec.RemediationTemplate != nil {
// If external remediation request already exists,
Expand Down Expand Up @@ -482,7 +483,7 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
// the same Machine, users are in charge of setting health checks and remediation properly.
to.SetName(t.Machine.Name)

logger.Info("Target has failed health check, creating an external remediation request", "remediation request name", to.GetName(), "target", t.string(), "reason", condition.Reason, "message", condition.Message)
logger.Info("Machine has failed health check, creating an external remediation request", "remediation request name", to.GetName(), condition.Reason, "message", condition.Message)

Check failure on line 486 in internal/controllers/machinehealthcheck/machinehealthcheck_controller.go

View workflow job for this annotation

GitHub Actions / lint

odd number of arguments passed as key-value pairs for logging (loggercheck)

Check failure on line 486 in internal/controllers/machinehealthcheck/machinehealthcheck_controller.go

View workflow job for this annotation

GitHub Actions / lint

odd number of arguments passed as key-value pairs for logging (loggercheck)
// Create the external clone.
if err := r.Client.Create(ctx, to); err != nil {
conditions.MarkFalse(m, clusterv1.ExternalRemediationRequestAvailableCondition, clusterv1.ExternalRemediationRequestCreationFailedReason, clusterv1.ConditionSeverityError, err.Error())
Expand All @@ -503,7 +504,7 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
Reason: clusterv1.MachineExternallyRemediatedWaitingForRemediationV1Beta2Reason,
})
} else if t.Machine.DeletionTimestamp.IsZero() { // Only setting the OwnerRemediated conditions when machine is not already in deletion.
logger.Info("Target has failed health check, marking for remediation", "target", t.string(), "reason", condition.Reason, "message", condition.Message)
logger.Info("Machine has failed health check, marking for remediation", "reason", condition.Reason, "message", condition.Message)
// NOTE: MHC is responsible for creating MachineOwnerRemediatedCondition if missing or to trigger another remediation if the previous one is completed;
// instead, if a remediation is in already progress, the remediation owner is responsible for completing the process and MHC should not overwrite the condition.
if !conditions.Has(t.Machine, clusterv1.MachineOwnerRemediatedCondition) || conditions.IsTrue(t.Machine, clusterv1.MachineOwnerRemediatedCondition) {
Expand Down

0 comments on commit 516eedc

Please sign in to comment.