]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
add stop_worker: as a mean to shutdown the worker 546/head
authorLoic Dachary <ldachary@redhat.com>
Mon, 29 Jun 2015 14:28:48 +0000 (16:28 +0200)
committerLoic Dachary <ldachary@redhat.com>
Tue, 21 Jul 2015 16:15:23 +0000 (18:15 +0200)
It is convenient for integration tests as a way for the worker to be
instructed to shutdown cleanly.

Signed-off-by: Loic Dachary <loic@dachary.org>
teuthology/worker.py

index 0e2bf7c6d74ca97abb01a1fd218d8990015eaa80..200f34395a803c3755b7ff864fb96f53485c42c3 100644 (file)
@@ -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()