Skip to content

Commit 0eab29e

Browse files
committed
šŸ› Align random deletion policy behavior with the rest regarding deletion annotations
Right now, the `oldest` and `newest` deletion policies prioritize machines that have the `cluster.x-k8s.io/delete-machine` annotation over unhealthy machines when deciding which machines need to be deleted. This wasn't the case with the `random` deletion policy. This change aligns the latter to the rest, making it honor the deletion annotation.
1 parent b12ad96 commit 0eab29e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ā€Žinternal/controllers/machineset/machineset_delete_policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func randomDeletePolicy(machine *clusterv1.Machine) deletePriority {
8282
return mustDelete
8383
}
8484
if _, ok := machine.ObjectMeta.Annotations[clusterv1.DeleteMachineAnnotation]; ok {
85-
return betterDelete
85+
return shouldDelete
8686
}
8787
if !isMachineHealthy(machine) {
8888
return betterDelete

ā€Žinternal/controllers/machineset/machineset_delete_policy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ func TestMachineToDelete(t *testing.T) {
200200
desc: "func=randomDeletePolicy, DeleteMachineAnnotation, diff=1",
201201
diff: 1,
202202
machines: []*clusterv1.Machine{
203-
healthyMachine,
203+
betterDeleteMachine,
204204
deleteMachineWithMachineAnnotation,
205-
healthyMachine,
205+
betterDeleteMachine,
206206
},
207207
expect: []*clusterv1.Machine{
208208
deleteMachineWithMachineAnnotation,

0 commit comments

Comments
Ā (0)