Skip to content

Commit dde1388

Browse files
committed
treat cordoned nodes as failover unavailable
1 parent 1483cbf commit dde1388

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ metadata:
101101
simple-volume.shipstuff.io/failover-grace-period: "1m"
102102
```
103103

104-
When no healthy pod using the claim is running on a Ready node for the grace
105-
period, the controller selects a ready replica node, patches the Deployment's
106-
`kubernetes.io/hostname` node selector, and deletes stale pods using the claim.
104+
When no healthy pod using the claim is running on a Ready, schedulable node for
105+
the grace period, the controller selects a ready replica node, patches the
106+
Deployment's `kubernetes.io/hostname` node selector, and deletes stale pods
107+
using the claim.
107108

108109
## Development
109110

‎internal/controller/failover_controller.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ func failoverGracePeriod(pvc *corev1.PersistentVolumeClaim) time.Duration {
183183
func readyNodeSet(nodes []corev1.Node) map[string]bool {
184184
out := make(map[string]bool)
185185
for _, node := range nodes {
186+
if node.Spec.Unschedulable {
187+
continue
188+
}
186189
for _, condition := range node.Status.Conditions {
187190
if condition.Type == corev1.NodeReady && condition.Status == corev1.ConditionTrue {
188191
out[node.Name] = true

‎internal/controller/failover_controller_test.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ func TestFailoverControllerPatchesDeploymentAndDeletesStalePod(t *testing.T) {
7171
}
7272
}
7373

74+
func TestReadyNodeSetExcludesUnschedulableNodes(t *testing.T) {
75+
node := readyNode("kapolei-pacific-1", true)
76+
node.Spec.Unschedulable = true
77+
nodes := readyNodeSet([]corev1.Node{*node, *readyNode("sf-west-1", true)})
78+
if nodes["kapolei-pacific-1"] {
79+
t.Fatal("unschedulable ready node should be excluded")
80+
}
81+
if !nodes["sf-west-1"] {
82+
t.Fatal("schedulable ready node should be included")
83+
}
84+
}
85+
7486
func deployment(name, namespace, node string) *appsv1.Deployment {
7587
return &appsv1.Deployment{
7688
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},

0 commit comments

Comments
 (0)