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

🌱 Deprioritize unknown NodeHealthy conditions for deletion #10763

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/machineset/machineset_delete_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ func isMachineHealthy(machine *clusterv1.Machine) bool {
if machine.Status.FailureReason != nil || machine.Status.FailureMessage != nil {
return false
}
// Note: for the sake of prioritization, we are not making any assumption about Health when ConditionUnknown.
nodeHealthyCondition := conditions.Get(machine, clusterv1.MachineNodeHealthyCondition)
if nodeHealthyCondition != nil && nodeHealthyCondition.Status != corev1.ConditionTrue {
if nodeHealthyCondition != nil && nodeHealthyCondition.Status == corev1.ConditionFalse {
return false
}
healthCheckCondition := conditions.Get(machine, clusterv1.MachineHealthCheckSucceededCondition)
Expand Down
41 changes: 33 additions & 8 deletions internal/controllers/machineset/machineset_delete_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestMachineToDelete(t *testing.T) {
},
},
}
healthyCheckConditionFalseMachine := &clusterv1.Machine{
healthCheckSucceededConditionFalseMachine := &clusterv1.Machine{
Status: clusterv1.MachineStatus{
NodeRef: nodeRef,
Conditions: clusterv1.Conditions{
Expand All @@ -79,6 +79,17 @@ func TestMachineToDelete(t *testing.T) {
},
},
}
healthCheckSucceededConditionUnknownMachine := &clusterv1.Machine{
Status: clusterv1.MachineStatus{
NodeRef: nodeRef,
Conditions: clusterv1.Conditions{
{
Type: clusterv1.MachineHealthCheckSucceededCondition,
Status: corev1.ConditionUnknown,
},
},
},
}

tests := []struct {
desc string
Expand Down Expand Up @@ -230,19 +241,31 @@ func TestMachineToDelete(t *testing.T) {
healthyMachine,
},
expect: []*clusterv1.Machine{
nodeHealthyConditionUnknownMachine,
healthyMachine,
},
},
{
desc: "func=randomDeletePolicy, NodeHealthyConditionFalseMachine, diff=1",
desc: "func=randomDeletePolicy, HealthCheckSucceededConditionFalseMachine, diff=1",
diff: 1,
machines: []*clusterv1.Machine{
healthyMachine,
healthyCheckConditionFalseMachine,
healthCheckSucceededConditionFalseMachine,
healthyMachine,
},
expect: []*clusterv1.Machine{
healthyCheckConditionFalseMachine,
healthCheckSucceededConditionFalseMachine,
},
},
{
desc: "func=randomDeletePolicy, HealthCheckSucceededConditionUnknownMachine, diff=1",
diff: 1,
machines: []*clusterv1.Machine{
healthyMachine,
healthCheckSucceededConditionUnknownMachine,
healthyMachine,
},
expect: []*clusterv1.Machine{
healthyMachine,
},
},
}
Expand Down Expand Up @@ -383,9 +406,10 @@ func TestMachineNewestDelete(t *testing.T) {
desc: "func=newestDeletePriority, diff=1 (nodeHealthyConditionUnknownMachine)",
diff: 1,
machines: []*clusterv1.Machine{
// nodeHealthyConditionUnknownMachine is not considered unhealthy with unknown condition.
secondNewest, oldest, secondOldest, newest, nodeHealthyConditionUnknownMachine,
},
expect: []*clusterv1.Machine{nodeHealthyConditionUnknownMachine},
expect: []*clusterv1.Machine{newest},
},
}

Expand Down Expand Up @@ -546,7 +570,8 @@ func TestMachineOldestDelete(t *testing.T) {
machines: []*clusterv1.Machine{
empty, secondNewest, oldest, secondOldest, newest, nodeHealthyConditionUnknownMachine,
},
expect: []*clusterv1.Machine{nodeHealthyConditionUnknownMachine},
// nodeHealthyConditionUnknownMachine is not considered unhealthy with unknown condition.
expect: []*clusterv1.Machine{oldest},
},
// these two cases ensures the mustDeleteMachine is always picked regardless of the machine names.
{
Expand Down Expand Up @@ -726,7 +751,7 @@ func TestIsMachineHealthy(t *testing.T) {
},
},
},
expect: false,
expect: true,
},
{
desc: "when all requirements are met for node to be healthy",
Expand Down
Loading