]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add --preserve-queue to teuthology-kill
authorZack Cerza <zack@cerza.org>
Tue, 25 Mar 2014 15:15:41 +0000 (10:15 -0500)
committerZack Cerza <zack@cerza.org>
Tue, 25 Mar 2014 15:18:33 +0000 (10:18 -0500)
For any cases where we just want to kill the running jobs and not delete
any scheduled jobs. This only applies to killing entire runs and is not
the default.

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
scripts/kill.py
teuthology/kill.py

index deec8511b168a187d689369c3a4c4af4a8e31e17..cef3e0ca84a2bbff62dbacdf26f052e03d66f228 100644 (file)
@@ -4,10 +4,11 @@ import teuthology.config
 import teuthology.kill
 
 doc = """
-usage: teuthology-kill [-h] [-a ARCHIVE] -r RUN
-       teuthology-kill [-h] [-a ARCHIVE] -m MACHINE_TYPE -r RUN
-       teuthology-kill [-h] [-a ARCHIVE] -r RUN -j JOB ...
-       teuthology-kill [-h] -o OWNER -m MACHINE_TYPE -r RUN
+usage: teuthology-kill -h
+       teuthology-kill [-a ARCHIVE] [-p] -r RUN
+       teuthology-kill [-a ARCHIVE] [-p] -m MACHINE_TYPE -r RUN
+       teuthology-kill [-a ARCHIVE] -r RUN -j JOB ...
+       teuthology-kill [-p] -o OWNER -m MACHINE_TYPE -r RUN
 
 Kill running teuthology jobs:
 1. Removes any queued jobs from the beanstalk queue
@@ -19,6 +20,7 @@ optional arguments:
   -a ARCHIVE, --archive ARCHIVE
                         The base archive directory
                         [default: {archive_base}]
+  -p, --preserve-queue  Preserve the queue - do not delete queued jobs
   -r, --run RUN         The name(s) of the run(s) to kill
   -j, --job JOB         The job_id of the job to kill
   -o, --owner OWNER     The owner of the job(s)
index 698ef5614f6cca255864585ff38d42255da24830..849069bd9de7f80df1f3665dcb17c19c8d1bcc37 100755 (executable)
@@ -19,15 +19,18 @@ def main(args):
     archive_base = args['--archive']
     owner = args['--owner']
     machine_type = args['--machine_type']
+    preserve_queue = args['--preserve-queue']
 
     if job:
         for job_id in job:
             kill_job(run_name, job_id, archive_base, owner, machine_type)
     else:
-        kill_run(run_name, archive_base, owner, machine_type)
+        kill_run(run_name, archive_base, owner, machine_type,
+                 preserve_queue=preserve_queue)
 
 
-def kill_run(run_name, archive_base=None, owner=None, machine_type=None):
+def kill_run(run_name, archive_base=None, owner=None, machine_type=None,
+             preserve_queue=False):
     run_info = {}
     if archive_base:
         run_archive_dir = os.path.join(archive_base, run_name)
@@ -39,7 +42,8 @@ def kill_run(run_name, archive_base=None, owner=None, machine_type=None):
             raise RuntimeError("The run is still entirely enqueued; " +
                                "you must also pass --machine-type")
 
-    remove_beanstalk_jobs(run_name, machine_type)
+    if not preserve_queue:
+        remove_beanstalk_jobs(run_name, machine_type)
     kill_processes(run_name, run_info.get('pids'))
     if owner is not None:
         targets = find_targets(run_name, owner)