Skip to content

Commit f0ac8d1

Browse files
Fix MS tests + make mirror Node Ready more robust
1 parent 1deece7 commit f0ac8d1

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

internal/controllers/machine/machine_controller_noderef.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ func (r *Reconciler) reconcileNode(ctx context.Context, s *scope) (ctrl.Result,
153153
r.recorder.Event(machine, corev1.EventTypeNormal, "SuccessfulSetInterruptibleNodeLabel", s.node.Name)
154154
}
155155

156-
// Do the remaining node health checks, then set the node health to true if all checks pass.
157156
if s.infraMachine == nil || !s.infraMachine.GetDeletionTimestamp().IsZero() {
158157
conditions.MarkFalse(s.machine, clusterv1.MachineNodeHealthyCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
159158
return ctrl.Result{}, nil
160159
}
161160

161+
// Do the remaining node health checks, then set the node health to true if all checks pass.
162162
status, message := summarizeNodeConditions(s.node)
163163
if status == corev1.ConditionFalse {
164164
conditions.MarkFalse(machine, clusterv1.MachineNodeHealthyCondition, clusterv1.NodeConditionsFailedReason, clusterv1.ConditionSeverityWarning, message)

internal/controllers/machine/machine_controller_status.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,15 @@ func setNodeHealthyAndReadyConditions(ctx context.Context, machine *clusterv1.Ma
230230
if condition.Message != "" {
231231
message = fmt.Sprintf("%s (from Node)", condition.Message)
232232
}
233+
reason := condition.Reason
234+
if reason == "" {
235+
reason = clusterv1.NoV1Beta2ReasonReported
236+
}
233237
nodeReady = &metav1.Condition{
234238
Type: clusterv1.MachineNodeReadyV1Beta2Condition,
235239
Status: metav1.ConditionStatus(condition.Status),
236240
LastTransitionTime: condition.LastTransitionTime,
237-
Reason: condition.Reason,
241+
Reason: reason,
238242
Message: message,
239243
}
240244
}

internal/controllers/machineset/suite_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func fakeMachineNodeRef(m *clusterv1.Machine, pid string, g *WithT) {
182182

183183
// Patch the node and make it look like ready.
184184
patchNode := client.MergeFrom(node.DeepCopy())
185-
node.Status.Conditions = append(node.Status.Conditions, corev1.NodeCondition{Type: corev1.NodeReady, Status: corev1.ConditionTrue})
185+
node.Status.Conditions = append(node.Status.Conditions, corev1.NodeCondition{Type: corev1.NodeReady, Status: corev1.ConditionTrue, Reason: "SomeReason"})
186186
g.Expect(env.Status().Patch(ctx, node, patchNode)).To(Succeed())
187187

188188
// Patch the Machine.

0 commit comments

Comments
 (0)