Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Machine: sort list of pre-drain hooks for stable condition messages #11624

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q:what about adding a test with more than one hook validating that hooks are sorted?

Copy link
Member Author

@sbueringer sbueringer Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are not executing the fixed/affected code

(I only updated them because I did a search/replace on the changed condition message)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have no code coverage on the pre-drain code path (this PR) or the pre-terminate code path (fixed in the previous PR: #11487).

I can open a follow-up issue if you want, but I wouldn't want to block this PR because of that if possible

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
Loading