Skip to content

Commit

Permalink
More comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Oct 16, 2024
1 parent 145c050 commit 9656771
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions api/v1beta1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ const (
// machine has been deleted while the Machine is still running.
MachineHealthCheckNodeDeletedV1Beta2Reason = "NodeDeleted"

// MachineHealthCheckHasRemediateMachineAnnotationV1Beta2Reason surfaces a MachineHealthCheck detects a machine manually remediated
// MachineHealthCheckHasRemediateAnnotationV1Beta2Reason surfaces a MachineHealthCheck detects a machine manually remediated
// via the remediate-machine annotation.
MachineHealthCheckHasRemediateMachineAnnotationV1Beta2Reason = "HasRemediateAnnotation"
MachineHealthCheckHasRemediateAnnotationV1Beta2Reason = "HasRemediateAnnotation"
)

// Machine's OwnerRemediated conditions and corresponding reasons that will be used in v1Beta2 API version.
Expand All @@ -241,9 +241,9 @@ const (
// determine that the controller owning this machine should perform remediation.
MachineOwnerRemediatedV1Beta2Condition = "OwnerRemediated"

// MachineOwnerRemediatedWaitingForOwnerRemediationV1Beta2Reason surfaces the machine is waiting for the owner controller
// MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason surfaces the machine is waiting for the owner controller
// to start remediation.
MachineOwnerRemediatedWaitingForOwnerRemediationV1Beta2Reason = "WaitingForRemediation"
MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason = "WaitingForRemediation"
)

// Machine's ExternallyRemediated conditions and corresponding reasons that will be used in v1Beta2 API version.
Expand All @@ -254,17 +254,17 @@ const (
// determine that an external controller should perform remediation.
MachineExternallyRemediatedV1Beta2Condition = "ExternallyRemediated"

// MachineExternallyRemediatedWaitingForExternalRemediationV1Beta2Reason surfaces the machine is waiting for the
// MachineExternallyRemediatedWaitingForRemediationV1Beta2Reason surfaces the machine is waiting for the
// external remediation controller to start remediation.
MachineExternallyRemediatedWaitingForExternalRemediationV1Beta2Reason = "WaitingForRemediation"
MachineExternallyRemediatedWaitingForRemediationV1Beta2Reason = "WaitingForRemediation"

// MachineExternallyRemediatedTemplateNotFoundV1Beta2Reason surfaces that the MachineHealthCheck cannot
// MachineExternallyRemediatedRemediationTemplateNotFoundV1Beta2Reason surfaces that the MachineHealthCheck cannot
// find the template for a external remediation request.
MachineExternallyRemediatedTemplateNotFoundV1Beta2Reason = "RemediationTemplateNotFound"
MachineExternallyRemediatedRemediationTemplateNotFoundV1Beta2Reason = "RemediationTemplateNotFound"

// MachineExternallyRemediatedRequestCreationFailedV1Beta2Reason surfaces that the MachineHealthCheck cannot
// MachineExternallyRemediatedRemediationRequestCreationFailedV1Beta2Reason surfaces that the MachineHealthCheck cannot
// create a request for the external remediation controller.
MachineExternallyRemediatedRequestCreationFailedV1Beta2Reason = "RemediationRequestCreationFailed"
MachineExternallyRemediatedRemediationRequestCreationFailedV1Beta2Reason = "RemediationRequestCreationFailed"
)

// Machine's Deleting condition and corresponding reasons that will be used in v1Beta2 API version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
v1beta2conditions.Set(t.Machine, metav1.Condition{
Type: clusterv1.MachineExternallyRemediatedV1Beta2Condition,
Status: metav1.ConditionFalse,
Reason: clusterv1.MachineExternallyRemediatedTemplateNotFoundV1Beta2Reason,
Reason: clusterv1.MachineExternallyRemediatedRemediationTemplateNotFoundV1Beta2Reason,
Message: fmt.Sprintf("error retrieving remediation template %s %s", m.Spec.RemediationTemplate.Kind, klog.KRef(t.Machine.Namespace, m.Spec.RemediationTemplate.Name)),
})
errList = append(errList, errors.Wrapf(err, "error retrieving remediation template %v %q for machine %q in namespace %q within cluster %q", m.Spec.RemediationTemplate.GroupVersionKind(), m.Spec.RemediationTemplate.Name, t.Machine.Name, t.Machine.Namespace, m.Spec.ClusterName))
Expand Down Expand Up @@ -453,8 +453,8 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
v1beta2conditions.Set(t.Machine, metav1.Condition{
Type: clusterv1.MachineExternallyRemediatedV1Beta2Condition,
Status: metav1.ConditionFalse,
Reason: clusterv1.MachineExternallyRemediatedRequestCreationFailedV1Beta2Reason,
Message: "take a look at the controller logs",
Reason: clusterv1.MachineExternallyRemediatedRemediationRequestCreationFailedV1Beta2Reason,
Message: "Please check controller logs for errors",
})
errList = append(errList, errors.Wrapf(err, "error creating remediation request for machine %q in namespace %q within cluster %q", t.Machine.Name, t.Machine.Namespace, t.Machine.Spec.ClusterName))
return errList
Expand All @@ -463,7 +463,7 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
v1beta2conditions.Set(t.Machine, metav1.Condition{
Type: clusterv1.MachineExternallyRemediatedV1Beta2Condition,
Status: metav1.ConditionFalse,
Reason: clusterv1.MachineExternallyRemediatedWaitingForExternalRemediationV1Beta2Reason,
Reason: clusterv1.MachineExternallyRemediatedWaitingForRemediationV1Beta2Reason,
})
} else {
logger.Info("Target has failed health check, marking for remediation", "target", t.string(), "reason", condition.Reason, "message", condition.Message)
Expand All @@ -477,7 +477,7 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
v1beta2conditions.Set(t.Machine, metav1.Condition{
Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition,
Status: metav1.ConditionFalse,
Reason: clusterv1.MachineOwnerRemediatedWaitingForOwnerRemediationV1Beta2Reason,
Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason,
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (t *healthCheckTarget) needsRemediation(logger logr.Logger, timeoutForMachi
v1beta2conditions.Set(t.Machine, metav1.Condition{
Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition,
Status: metav1.ConditionFalse,
Reason: clusterv1.MachineHealthCheckHasRemediateMachineAnnotationV1Beta2Reason,
Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason,
Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation",
})
return true, time.Duration(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func TestHealthCheckTargets(t *testing.T) {
Node: nil,
}
machineAnnotationRemediationCondition := newFailedHealthCheckCondition(clusterv1.HasRemediateMachineAnnotationReason, annotationRemediationMsg)
machineAnnotationRemediationV1Beta2Condition := newFailedHealthCheckV1Beta2Condition(clusterv1.MachineHealthCheckHasRemediateMachineAnnotationV1Beta2Reason, annotationRemediationV1Beta2Msg)
machineAnnotationRemediationV1Beta2Condition := newFailedHealthCheckV1Beta2Condition(clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, annotationRemediationV1Beta2Msg)

testCases := []struct {
desc string
Expand Down

0 comments on commit 9656771

Please sign in to comment.