From 181256f3d7a62efa927e2ef0f605464b186041d3 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Mon, 29 Jun 2015 16:28:48 +0200 Subject: [PATCH] add stop_worker: as a mean to shutdown the worker It is convenient for integration tests as a way for the worker to be instructed to shutdown cleanly. Signed-off-by: Loic Dachary --- teuthology/worker.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/teuthology/worker.py b/teuthology/worker.py index 0e2bf7c6d7..200f34395a 100644 --- a/teuthology/worker.py +++ b/teuthology/worker.py @@ -82,7 +82,8 @@ def main(ctx): fetch_teuthology('master') fetch_qa_suite('master') - while True: + keep_running = True + while keep_running: # Check to see if we have a teuthology-results process hanging around # and if so, read its return code so that it can exit. if result_proc is not None and result_proc.poll() is not None: @@ -103,6 +104,9 @@ def main(ctx): log.info('Config is: %s', job.body) job_config = yaml.safe_load(job.body) + if job_config.get('stop_worker'): + keep_running = False + job_config['job_id'] = str(job.jid) safe_archive = safepath.munge(job_config['name']) job_config['worker_log'] = log_file_path @@ -161,8 +165,9 @@ def main(ctx): else: log.info('Creating archive dir %s', archive_path_full) safepath.makedirs(ctx.archive_dir, safe_archive) - log.info('Running job %d', job.jid) - run_job(job_config, teuth_bin_path, ctx.verbose) + if 'roles' in job_config: + log.info('Running job %d', job.jid) + run_job(job_config, teuth_bin_path, ctx.verbose) job.delete() -- 2.39.5