From 6f751efe557d2dfdb9a50b646321c84a9790d2bb Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 9 Feb 2021 19:24:02 +0000 Subject: [PATCH] nuke: allow not rebooting again The default behavior was changed to always reboot in 1d47a121b385e2656e9314e9d63faf68a8e865e4 but the --reboot-all option remained. Keep the original option around for compatibility with existing scripts. Signed-off-by: Josh Durgin --- scripts/nuke.py | 5 +++-- teuthology/nuke/__init__.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/nuke.py b/scripts/nuke.py index 078d743f07..0b1644c3e7 100644 --- a/scripts/nuke.py +++ b/scripts/nuke.py @@ -5,7 +5,7 @@ import teuthology.nuke doc = """ usage: teuthology-nuke --help - teuthology-nuke [-v] [--owner OWNER] [-n NAME] [-u] [-i] [-r] [-s] [-k] + teuthology-nuke [-v] [--owner OWNER] [-n NAME] [-u] [-i] [-r|-R] [-s] [-k] [-p PID] [--dry-run] (-t CONFIG... | -a DIR) teuthology-nuke [-v] [-u] [-i] [-r] [-s] [--dry-run] --owner OWNER --stale teuthology-nuke [-v] [--dry-run] --stale-openstack @@ -27,7 +27,8 @@ optional arguments: targets that would be nuked --owner OWNER job owner -p PID, --pid PID pid of the process to be killed - -r, --reboot-all reboot all machines + -r, --reboot-all reboot all machines (default) + -R, --no-reboot do not reboot the machines -s, --synch-clocks synchronize clocks on all machines -u, --unlock Unlock each successfully nuked machine, and output targets thatcould not be nuked. diff --git a/teuthology/nuke/__init__.py b/teuthology/nuke/__init__.py index 785c211ab6..91b9f35dc4 100644 --- a/teuthology/nuke/__init__.py +++ b/teuthology/nuke/__init__.py @@ -232,10 +232,10 @@ def main(args): else: subprocess.check_call(["kill", "-9", str(ctx.pid)]) - nuke(ctx, ctx.unlock, ctx.synch_clocks, ctx.reboot_all, ctx.noipmi) + nuke(ctx, ctx.unlock, ctx.synch_clocks, ctx.noipmi) -def nuke(ctx, should_unlock, sync_clocks=True, reboot_all=True, noipmi=False): +def nuke(ctx, should_unlock, sync_clocks=True, noipmi=False): if 'targets' not in ctx.config: return total_unnuked = {} @@ -260,7 +260,6 @@ def nuke(ctx, should_unlock, sync_clocks=True, reboot_all=True, noipmi=False): {target: hostkey}, should_unlock, sync_clocks, - reboot_all, ctx.config.get('check-locks', True), noipmi, ) @@ -275,22 +274,22 @@ def nuke(ctx, should_unlock, sync_clocks=True, reboot_all=True, noipmi=False): default_flow_style=False).splitlines())) -def nuke_one(ctx, target, should_unlock, synch_clocks, reboot_all, +def nuke_one(ctx, target, should_unlock, synch_clocks, check_locks, noipmi): ret = None keep_logs = ctx.keep_logs + should_reboot = not ctx.no_reboot ctx = argparse.Namespace( config=dict(targets=target), owner=ctx.owner, check_locks=check_locks, synch_clocks=synch_clocks, - reboot_all=reboot_all, teuthology_config=config.to_dict(), name=ctx.name, noipmi=noipmi, ) try: - nuke_helper(ctx, should_unlock, keep_logs) + nuke_helper(ctx, should_unlock, keep_logs, should_reboot) except Exception: log.exception('Could not nuke %s' % target) # not re-raising the so that parallel calls aren't killed @@ -301,7 +300,7 @@ def nuke_one(ctx, target, should_unlock, synch_clocks, reboot_all, return ret -def nuke_helper(ctx, should_unlock, keep_logs): +def nuke_helper(ctx, should_unlock, keep_logs, should_reboot): # ensure node is up with ipmi (target,) = ctx.config['targets'].keys() host = target.split('@')[-1] @@ -340,7 +339,8 @@ def nuke_helper(ctx, should_unlock, keep_logs): # Try to remove packages before reboot remove_installed_packages(ctx) remotes = ctx.cluster.remotes.keys() - reboot(ctx, remotes) + if should_reboot: + reboot(ctx, remotes) # shutdown daemons again incase of startup shutdown_daemons(ctx) remove_osd_mounts(ctx) -- 2.39.5