From 70ab6e031522a94db7f1352b98466d58cf41c539 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 25 Mar 2014 10:15:41 -0500 Subject: [PATCH] Add --preserve-queue to teuthology-kill 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 --- scripts/kill.py | 10 ++++++---- teuthology/kill.py | 10 +++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/kill.py b/scripts/kill.py index deec8511b168a..cef3e0ca84a2b 100644 --- a/scripts/kill.py +++ b/scripts/kill.py @@ -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) diff --git a/teuthology/kill.py b/teuthology/kill.py index 698ef5614f6cc..849069bd9de7f 100755 --- a/teuthology/kill.py +++ b/teuthology/kill.py @@ -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) -- 2.39.5