Skip to content

Commit

Permalink
Merge pull request #11624 from sbueringer/pr-pre-drain-hook-determini…
Browse files Browse the repository at this point in the history
…stic

🐛 Machine: sort list of pre-drain hooks for stable condition messages
  • Loading branch information
k8s-ci-robot authored Dec 27, 2024
2 parents 00efbff + 61dfbfb commit 44360af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,11 @@ func (r *Reconciler) reconcileDelete(ctx context.Context, s *scope) (ctrl.Result
hooks = append(hooks, key)
}
}
slices.Sort(hooks)
log.Info("Waiting for pre-drain hooks to succeed", "hooks", strings.Join(hooks, ","))
conditions.MarkFalse(m, clusterv1.PreDrainDeleteHookSucceededCondition, clusterv1.WaitingExternalHookReason, clusterv1.ConditionSeverityInfo, "")
s.deletingReason = clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason
s.deletingMessage = fmt.Sprintf("Waiting for pre-drain hooks to complete (hooks: %s)", strings.Join(hooks, ","))
s.deletingMessage = fmt.Sprintf("Waiting for pre-drain hooks to succeed (hooks: %s)", strings.Join(hooks, ","))
return ctrl.Result{}, nil
}
conditions.MarkTrue(m, clusterv1.PreDrainDeleteHookSucceededCondition)
Expand Down
12 changes: 6 additions & 6 deletions internal/controllers/machine/machine_controller_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,12 +1128,12 @@ func TestDeletingCondition(t *testing.T) {
},
reconcileDeleteExecuted: true,
deletingReason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason,
deletingMessage: "Waiting for pre-drain hooks to complete (hooks: test-hook)",
deletingMessage: "Waiting for pre-drain hooks to succeed (hooks: test-hook)",
expectCondition: metav1.Condition{
Type: clusterv1.MachineDeletingV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason,
Message: "Waiting for pre-drain hooks to complete (hooks: test-hook)",
Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)",
},
},
{
Expand Down Expand Up @@ -1186,7 +1186,7 @@ func TestDeletingCondition(t *testing.T) {
Type: clusterv1.MachineDeletingV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason,
Message: "Waiting for pre-drain hooks to complete (hooks: test-hook)",
Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)",
},
},
},
Expand All @@ -1200,7 +1200,7 @@ func TestDeletingCondition(t *testing.T) {
Type: clusterv1.MachineDeletingV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason,
Message: "Waiting for pre-drain hooks to complete (hooks: test-hook)",
Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)",
},
},
}
Expand Down Expand Up @@ -1409,7 +1409,7 @@ func TestSetReadyCondition(t *testing.T) {
Type: clusterv1.MachineDeletingV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason,
Message: "Waiting for pre-drain hooks to complete (hooks: test-hook)",
Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)",
},
},
},
Expand Down Expand Up @@ -1788,7 +1788,7 @@ After above Pods have been removed from the Node, the following Pods will be evi
Type: clusterv1.MachineDeletingV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason,
Message: "Waiting for pre-drain hooks to complete (hooks: test-hook)",
Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)",
},
},
},
Expand Down

0 comments on commit 44360af

Please sign in to comment.