]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
nuke: add option to preserve logs on remote machines
authorJosh Durgin <jdurgin@redhat.com>
Tue, 9 Feb 2021 18:54:28 +0000 (18:54 +0000)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 9 Feb 2021 18:54:30 +0000 (18:54 +0000)
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 <jdurgin@redhat.com>
scripts/nuke.py
teuthology/nuke/__init__.py

index 876312f9b41762f74d38325c46d425ea55fa2be9..078d743f07898b407299d90738b3f73a461a566b 100644 (file)
@@ -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
index 7d05592772056d624d06335b07e3da4bc2478fa0..785c211ab6a0eb4d4b7a8602b9796796d06d56d6 100644 (file)
@@ -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)