Skip to content

Commit 516eedc

Browse files
Improve Machine remediation logs
1 parent 07d97c6 commit 516eedc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/controllers/machinehealthcheck/machinehealthcheck_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,11 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
428428
// mark for remediation
429429
errList := []error{}
430430
for _, t := range unhealthy {
431+
logger := logger.WithValues("Machine", klog.KObj(t.Machine), "Node", klog.KObj(t.Node))
431432
condition := conditions.Get(t.Machine, clusterv1.MachineHealthCheckSucceededCondition)
432433

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

485-
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)
486+
logger.Info("Machine has failed health check, creating an external remediation request", "remediation request name", to.GetName(), condition.Reason, "message", condition.Message)
486487
// Create the external clone.
487488
if err := r.Client.Create(ctx, to); err != nil {
488489
conditions.MarkFalse(m, clusterv1.ExternalRemediationRequestAvailableCondition, clusterv1.ExternalRemediationRequestCreationFailedReason, clusterv1.ConditionSeverityError, err.Error())
@@ -503,7 +504,7 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
503504
Reason: clusterv1.MachineExternallyRemediatedWaitingForRemediationV1Beta2Reason,
504505
})
505506
} else if t.Machine.DeletionTimestamp.IsZero() { // Only setting the OwnerRemediated conditions when machine is not already in deletion.
506-
logger.Info("Target has failed health check, marking for remediation", "target", t.string(), "reason", condition.Reason, "message", condition.Message)
507+
logger.Info("Machine has failed health check, marking for remediation", "reason", condition.Reason, "message", condition.Message)
507508
// NOTE: MHC is responsible for creating MachineOwnerRemediatedCondition if missing or to trigger another remediation if the previous one is completed;
508509
// instead, if a remediation is in already progress, the remediation owner is responsible for completing the process and MHC should not overwrite the condition.
509510
if !conditions.Has(t.Machine, clusterv1.MachineOwnerRemediatedCondition) || conditions.IsTrue(t.Machine, clusterv1.MachineOwnerRemediatedCondition) {

0 commit comments

Comments
 (0)