Skip to content
This repository was archived by the owner on May 3, 2023. It is now read-only.

Commit fdde08f

Browse files
authored
Merge pull request #4 from pwillie/timeout
Add --drain-timeout command option
2 parents 99a40e5 + 8b5f1d4 commit fdde08f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Usage: eks-node-rollout [OPTIONS]
2929
3030
Options:
3131
--cluster-name TEXT Cluster name to discover ASGs from [required]
32+
--drain-timeout TEXT Timeout for draining worker nodes
3233
--dry-run / --no-dry-run Run with read-only API calls
3334
--debug / --no-debug Enable debug logging
3435
--help Show this message and exit.

eks_node_rollout/eks_node_rollout.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)