]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
dispatcher: Optionally exit when queue is empty
authorZack Cerza <zack@redhat.com>
Tue, 22 Mar 2022 01:38:04 +0000 (19:38 -0600)
committerZack Cerza <zack@redhat.com>
Mon, 28 Mar 2022 21:31:40 +0000 (15:31 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
scripts/dispatcher.py
teuthology/dispatcher/__init__.py

index 8d955e48c3a1c952f84013405a212e54bc0e624e..4cb1abdea665803c62ecc5d0ef19fd2fa77f1e07 100644 (file)
@@ -1,7 +1,7 @@
 """
 usage: teuthology-dispatcher --help
        teuthology-dispatcher --supervisor [-v] --bin-path BIN_PATH --job-config COFNFIG --archive-dir DIR
-       teuthology-dispatcher [-v] [--archive-dir DIR] --log-dir LOG_DIR --tube TUBE
+       teuthology-dispatcher [-v] [--archive-dir DIR] [--exit-on-empty-queue] --log-dir LOG_DIR --tube TUBE
 
 Start a dispatcher for the specified tube. Grab jobs from a beanstalk
 queue and run the teuthology tests they describe as subprocesses. The
@@ -21,6 +21,7 @@ standard arguments:
   --supervisor                   run dispatcher in job supervisor mode
   --bin-path BIN_PATH            teuthology bin path
   --job-config CONFIG            file descriptor of job's config file
+  --exit-on-empty-queue          if the queue is empty, exit
 """
 
 import docopt
index 5902f40353398224d7e174bbf5f78c3339edc032..9f7fa257e40ea2519cb698c6ce8bdc3ba7dbe255 100644 (file)
@@ -64,6 +64,7 @@ def main(args):
     tube = args["--tube"]
     log_dir = args["--log-dir"]
     archive_dir = args["--archive-dir"]
+    exit_on_empty_queue = args["--exit-on-empty-queue"]
 
     if archive_dir is None:
         archive_dir = teuth_config.archive_base
@@ -103,13 +104,14 @@ def main(args):
             stop()
 
         load_config()
-
+        job_procs = set(filter(lambda p: p.poll() is None, job_procs))
         job = connection.reserve(timeout=60)
         if job is None:
+            if exit_on_empty_queue and not job_procs:
+                log.info("Queue is empty and no supervisor processes running; exiting!")
+                break
             continue
 
-        job_procs = set(filter(lambda p: p.poll() is None, job_procs))
-
         # bury the job so it won't be re-run if it fails
         job.bury()
         job_id = job.jid