feat: add drain delay (#852)

Signed-off-by: Daniel Malon <daniel.malon@me.com>
This commit is contained in:
Daniel Malon
2023-12-11 10:58:29 -08:00
committed by GitHub
parent 61309b9a73
commit d51258ffde
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -44,6 +44,7 @@ var (
// Command line flags
forceReboot bool
drainDelay time.Duration
drainTimeout time.Duration
rebootDelay time.Duration
period time.Duration
@@ -139,6 +140,8 @@ func NewRootCommand() *cobra.Command {
"only drain pods with labels matching the selector (default: '', all pods)")
rootCmd.PersistentFlags().IntVar(&skipWaitForDeleteTimeoutSeconds, "skip-wait-for-delete-timeout", 0,
"when seconds is greater than zero, skip waiting for the pods whose deletion timestamp is older than N seconds while draining a node")
rootCmd.PersistentFlags().DurationVar(&drainDelay, "drain-delay", 0,
"delay drain for this duration (default: 0, disabled)")
rootCmd.PersistentFlags().DurationVar(&drainTimeout, "drain-timeout", 0,
"timeout after which the drain is aborted (default: 0, infinite time)")
rootCmd.PersistentFlags().DurationVar(&rebootDelay, "reboot-delay", 0,
@@ -497,6 +500,11 @@ func drain(client *kubernetes.Clientset, node *v1.Node) error {
updateNodeLabels(client, node, preRebootNodeLabels)
}
if drainDelay > 0 {
log.Infof("Delaying drain for %v", drainDelay)
time.Sleep(drainDelay)
}
log.Infof("Draining node %s", nodename)
if notifyURL != "" {
+1
View File
@@ -53,6 +53,7 @@ spec:
# - --force-reboot=false
# - --drain-grace-period=-1
# - --skip-wait-for-delete-timeout=0
# - --drain-delay=0
# - --drain-timeout=0
# - --drain-pod-selector=""
# - --period=1h