@@ -227,9 +227,10 @@ def enable_autoscaling(asg_client, asg_name, dry_run=True):
227227
228228@click .command ()
229229@click .option ('--cluster-name' , envvar = 'EKS_NODE_ROLLOUT_CLUSTER_NAME' , required = True , help = "Cluster name to discover ASGs from" )
230+ @click .option ('--drain-timeout' , envvar = 'EKS_NODE_ROLLOUT_DRAIN_TIMEOUT' , default = "120s" , help = "Timeout for draining worker node (eg. 1s, 2m, 3h)" )
230231@click .option ('--dry-run/--no-dry-run' , envvar = 'EKS_NODE_ROLLOUT_DRY_RUN' , default = False , help = "Run with read-only API calls" )
231232@click .option ('--debug/--no-debug' , envvar = 'EKS_NODE_ROLLOUT_DEBUG' , default = False , help = "Enable debug logging" )
232- def rollout_nodes (cluster_name , dry_run , debug ):
233+ def rollout_nodes (cluster_name , drain_timeout , dry_run , debug ):
233234 """Retrieve all outdated workers and perform a rolling update on them."""
234235
235236 if debug :
@@ -286,8 +287,8 @@ def rollout_nodes(cluster_name, dry_run, debug):
286287 assert after_instance_count > before_instance_count
287288
288289 node_name = instance ["PrivateDnsName" ]
289- logging .info (f'Draining node { node_name } (--dry-run={ dry_run } )' )
290- output = kubectl .drain (node_name , "--force" , "--delete-local-data=true" , "--ignore-daemonsets=true" , "--timeout=120s " , f"--dry-run={ dry_run } " )
290+ logging .info (f'Draining node { node_name } (--timeout= { drain_timeout } -- dry-run={ dry_run } )' )
291+ output = kubectl .drain (node_name , "--force" , "--delete-local-data=true" , "--ignore-daemonsets=true" , "--timeout={drain_timeout} " , f"--dry-run={ dry_run } " )
291292 print (output .stdout .decode ().rstrip ())
292293
293294 terminate_node (asg_client , instance ["InstanceId" ], dry_run )
0 commit comments