From 59a2f8b1c2d2b6ff72fdc0d8dd3e2c8cf1ec11ae Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 9 Feb 2021 18:54:28 +0000 Subject: [PATCH] nuke: add option to preserve logs on remote machines This will be helpful for killing jobs that hit the max_job_timeout while still being able to collect logs from them. Signed-off-by: Josh Durgin --- scripts/nuke.py | 3 ++- teuthology/nuke/__init__.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/nuke.py b/scripts/nuke.py index 876312f9b4..078d743f07 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] + teuthology-nuke [-v] [--owner OWNER] [-n NAME] [-u] [-i] [-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 @@ -33,6 +33,7 @@ optional arguments: targets thatcould not be nuked. -n NAME, --name NAME Name of run to cleanup -i, --noipmi Skip ipmi checking + -k, --keep-logs Preserve test directories and logs on the machines Examples: teuthology-nuke -t target.yaml --unlock --owner user@host diff --git a/teuthology/nuke/__init__.py b/teuthology/nuke/__init__.py index 7d05592772..785c211ab6 100644 --- a/teuthology/nuke/__init__.py +++ b/teuthology/nuke/__init__.py @@ -278,6 +278,7 @@ def nuke(ctx, should_unlock, sync_clocks=True, reboot_all=True, noipmi=False): def nuke_one(ctx, target, should_unlock, synch_clocks, reboot_all, check_locks, noipmi): ret = None + keep_logs = ctx.keep_logs ctx = argparse.Namespace( config=dict(targets=target), owner=ctx.owner, @@ -289,7 +290,7 @@ def nuke_one(ctx, target, should_unlock, synch_clocks, reboot_all, noipmi=noipmi, ) try: - nuke_helper(ctx, should_unlock) + nuke_helper(ctx, should_unlock, keep_logs) except Exception: log.exception('Could not nuke %s' % target) # not re-raising the so that parallel calls aren't killed @@ -300,7 +301,7 @@ def nuke_one(ctx, target, should_unlock, synch_clocks, reboot_all, return ret -def nuke_helper(ctx, should_unlock): +def nuke_helper(ctx, should_unlock, keep_logs): # ensure node is up with ipmi (target,) = ctx.config['targets'].keys() host = target.split('@')[-1] @@ -352,7 +353,8 @@ def nuke_helper(ctx, should_unlock): undo_multipath(ctx) reset_syslog_dir(ctx) remove_ceph_data(ctx) - remove_testing_tree(ctx) + if not keep_logs: + remove_testing_tree(ctx) remove_yum_timedhosts(ctx) # Once again remove packages after reboot remove_installed_packages(ctx) -- 2.39.5