From: Zack Cerza Date: Tue, 22 Mar 2022 01:38:04 +0000 (-0600) Subject: dispatcher: Optionally exit when queue is empty X-Git-Tag: 1.2.0~190^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=11df10f6f613a77c17262179ae3ce3c5c7246119;p=teuthology.git dispatcher: Optionally exit when queue is empty Signed-off-by: Zack Cerza --- diff --git a/scripts/dispatcher.py b/scripts/dispatcher.py index 8d955e48c..4cb1abdea 100644 --- a/scripts/dispatcher.py +++ b/scripts/dispatcher.py @@ -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 diff --git a/teuthology/dispatcher/__init__.py b/teuthology/dispatcher/__init__.py index 5902f4035..9f7fa257e 100644 --- a/teuthology/dispatcher/__init__.py +++ b/teuthology/dispatcher/__init__.py @@ -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