Skip to content

Commit 6fcf774

Browse files
typeidmjlshen
andcommitted
fix: delayed MHC replacement of unreachable nodes
Co-authored-by: Michael Shen <[email protected]>
1 parent 0539a29 commit 6fcf774

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

internal/controllers/machine/machine_controller.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,19 @@ func (r *Reconciler) drainNode(ctx context.Context, cluster *clusterv1.Cluster,
670670
}
671671

672672
if noderefutil.IsNodeUnreachable(node) {
673-
// When the node is unreachable and some pods are not evicted for as long as this timeout, we ignore them.
674-
drainer.SkipWaitForDeleteTimeoutSeconds = 60 * 5 // 5 minutes
673+
// Kubelet is unreachable, pods will never disappear.
674+
675+
// SkipWaitForDeleteTimeoutSeconds ensures the drain completes
676+
// even if pod objects are not deleted.
677+
drainer.SkipWaitForDeleteTimeoutSeconds = 1
678+
679+
// We don't need to wait for the grace period specified by pods
680+
// as we know this won't happen.
681+
// The grace period generally won't change anything here as
682+
// the kubelet should not be reachable, but it doesn't hurt setting it.
683+
drainer.GracePeriodSeconds = 1
684+
685+
log.V(5).Info("Node is unreachable, draining will ignore gracePeriod. PDBs are still honored.")
675686
}
676687

677688
if err := kubedrain.RunCordonOrUncordon(drainer, node, true); err != nil {

0 commit comments

Comments
 (0)