Skip to content

Commit

Permalink
feat: add drain delay (#852)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Malon <[email protected]>
  • Loading branch information
MerlinDMC authored Dec 11, 2023
1 parent 61309b9 commit d51258f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/kured/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (

// Command line flags
forceReboot bool
drainDelay time.Duration
drainTimeout time.Duration
rebootDelay time.Duration
period time.Duration
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 != "" {
Expand Down
1 change: 1 addition & 0 deletions kured-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d51258f

Please sign in to comment.