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

🐛 Perform draining and volume detachment once until completion #11590

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,10 @@ func (r *Reconciler) isNodeDrainAllowed(m *clusterv1.Machine) bool {
return false
}

if conditions.Get(m, clusterv1.PreTerminateDeleteHookSucceededCondition) != nil {
return false
}

return true
}

Expand All @@ -677,6 +681,10 @@ func (r *Reconciler) isNodeVolumeDetachingAllowed(m *clusterv1.Machine) bool {
return false
}

if conditions.Get(m, clusterv1.PreTerminateDeleteHookSucceededCondition) != nil {
return false
}

return true
}

Expand Down
44 changes: 44 additions & 0 deletions internal/controllers/machine/machine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,28 @@ func TestIsNodeDrainedAllowed(t *testing.T) {
},
expected: false,
},
{
name: "Node draining succeeded",
machine: &clusterv1.Machine{
ObjectMeta: metav1.ObjectMeta{
Name: "test-machine",
Namespace: metav1.NamespaceDefault,
Finalizers: []string{clusterv1.MachineFinalizer},
},
Spec: clusterv1.MachineSpec{
ClusterName: "test-cluster",
InfrastructureRef: corev1.ObjectReference{},
Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")},
},
Status: clusterv1.MachineStatus{
Conditions: clusterv1.Conditions{{
Type: clusterv1.PreTerminateDeleteHookSucceededCondition,
Status: corev1.ConditionFalse,
}},
},
},
expected: false,
},
{
name: "Node draining timeout is not yet over",
machine: &clusterv1.Machine{
Expand Down Expand Up @@ -1989,6 +2011,28 @@ func TestIsNodeVolumeDetachingAllowed(t *testing.T) {
},
expected: false,
},
{
name: "Volume detach completed",
machine: &clusterv1.Machine{
ObjectMeta: metav1.ObjectMeta{
Name: "test-machine",
Namespace: metav1.NamespaceDefault,
Finalizers: []string{clusterv1.MachineFinalizer},
},
Spec: clusterv1.MachineSpec{
ClusterName: "test-cluster",
InfrastructureRef: corev1.ObjectReference{},
Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")},
},
Status: clusterv1.MachineStatus{
Conditions: clusterv1.Conditions{{
Type: clusterv1.PreTerminateDeleteHookSucceededCondition,
Status: corev1.ConditionFalse,
}},
},
},
expected: false,
},
{
name: "Volume detach timeout is not yet over",
machine: &clusterv1.Machine{
Expand Down
Loading