@@ -82,7 +82,19 @@ func (c *Controller) Reconcile(ctx context.Context, node *corev1.Node) (reconcil
82
82
}
83
83
ctx = log .IntoContext (ctx , log .FromContext (ctx ).WithValues ("NodeClaim" , klog .KObj (nodeClaim )))
84
84
85
- // If a nodeclaim does has a nodepool label, validate the nodeclaims inside the nodepool are healthy (i.e bellow the allowed threshold)
85
+ unhealthyNodeCondition , policyTerminationDuration := c .findUnhealthyConditions (node )
86
+ if unhealthyNodeCondition == nil {
87
+ return reconcile.Result {}, nil
88
+ }
89
+
90
+ // If the Node is unhealthy, but has not reached its full toleration disruption
91
+ // requeue at the termination time of the unhealthy node
92
+ terminationTime := unhealthyNodeCondition .LastTransitionTime .Add (policyTerminationDuration )
93
+ if c .clock .Now ().Before (terminationTime ) {
94
+ return reconcile.Result {RequeueAfter : terminationTime .Sub (c .clock .Now ())}, nil
95
+ }
96
+
97
+ // If a nodeclaim does have a nodepool label, validate the nodeclaims inside the nodepool are healthy (i.e bellow the allowed threshold)
86
98
// In the case of standalone nodeclaim, validate the nodes inside the cluster are healthy before proceeding
87
99
// to repair the nodes
88
100
nodePoolName , found := nodeClaim .Labels [v1 .NodePoolLabelKey ]
@@ -104,24 +116,10 @@ func (c *Controller) Reconcile(ctx context.Context, node *corev1.Node) (reconcil
104
116
return reconcile.Result {}, nil
105
117
}
106
118
}
107
-
108
- unhealthyNodeCondition , policyTerminationDuration := c .findUnhealthyConditions (node )
109
- if unhealthyNodeCondition == nil {
110
- return reconcile.Result {}, nil
111
- }
112
-
113
- // If the Node is unhealthy, but has not reached it's full toleration disruption
114
- // requeue at the termination time of the unhealthy node
115
- terminationTime := unhealthyNodeCondition .LastTransitionTime .Add (policyTerminationDuration )
116
- if c .clock .Now ().Before (terminationTime ) {
117
- return reconcile.Result {RequeueAfter : terminationTime .Sub (c .clock .Now ())}, nil
118
- }
119
-
120
119
// For unhealthy past the tolerationDisruption window we can forcefully terminate the node
121
120
if err := c .annotateTerminationGracePeriod (ctx , nodeClaim ); err != nil {
122
121
return reconcile.Result {}, client .IgnoreNotFound (err )
123
122
}
124
-
125
123
return c .deleteNodeClaim (ctx , nodeClaim , node , unhealthyNodeCondition )
126
124
}
127
125
@@ -176,7 +174,6 @@ func (c *Controller) annotateTerminationGracePeriod(ctx context.Context, nodeCla
176
174
return nil
177
175
}
178
176
}
179
-
180
177
stored := nodeClaim .DeepCopy ()
181
178
terminationTime := c .clock .Now ().Format (time .RFC3339 )
182
179
nodeClaim .ObjectMeta .Annotations = lo .Assign (nodeClaim .ObjectMeta .Annotations , map [string ]string {v1 .NodeClaimTerminationTimestampAnnotationKey : terminationTime })
@@ -187,7 +184,6 @@ func (c *Controller) annotateTerminationGracePeriod(ctx context.Context, nodeCla
187
184
}
188
185
log .FromContext (ctx ).WithValues (v1 .NodeClaimTerminationTimestampAnnotationKey , terminationTime ).Info ("annotated nodeclaim" )
189
186
}
190
-
191
187
return nil
192
188
}
193
189
0 commit comments