From: Zack Cerza Date: Mon, 21 Mar 2022 23:44:34 +0000 (-0600) Subject: supervisor: Return job's return code X-Git-Tag: 1.2.0~190^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=78304b776f69af384b72e895aa95180529030950;p=teuthology.git supervisor: Return job's return code Signed-off-by: Zack Cerza --- diff --git a/scripts/dispatcher.py b/scripts/dispatcher.py index 669f12511..8d955e48c 100644 --- a/scripts/dispatcher.py +++ b/scripts/dispatcher.py @@ -24,10 +24,11 @@ standard arguments: """ import docopt +import sys import teuthology.dispatcher def main(): args = docopt.docopt(__doc__) - teuthology.dispatcher.main(args) + sys.exit(teuthology.dispatcher.main(args)) diff --git a/teuthology/dispatcher/__init__.py b/teuthology/dispatcher/__init__.py index f6eea469d..5902f4035 100644 --- a/teuthology/dispatcher/__init__.py +++ b/teuthology/dispatcher/__init__.py @@ -88,6 +88,7 @@ def main(args): fetch_qa_suite('master') keep_running = True + job_procs = set() 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. @@ -107,6 +108,8 @@ def main(args): if job is None: 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 @@ -154,6 +157,7 @@ def main(args): try: job_proc = subprocess.Popen(run_args) + job_procs.add(job_proc) log.info('Job supervisor PID: %s', job_proc.pid) except Exception: error_message = "Saw error while trying to spawn supervisor." @@ -171,6 +175,12 @@ def main(args): except Exception: log.exception("Saw exception while trying to delete job") + returncodes = set([0]) + for proc in job_procs: + if proc.returncode is not None: + returncodes.add(proc.returncode) + return max(returncodes) + def lock_machines(job_config): report.try_push_job_info(job_config, dict(status='running')) diff --git a/teuthology/dispatcher/supervisor.py b/teuthology/dispatcher/supervisor.py index 3036d0335..f52e37938 100644 --- a/teuthology/dispatcher/supervisor.py +++ b/teuthology/dispatcher/supervisor.py @@ -54,14 +54,14 @@ def main(args): yaml.safe_dump(job_config, f, default_flow_style=False) try: - run_job( + return run_job( job_config, teuth_bin_path, archive_dir, verbose ) except SkipJob: - return + return 0 def run_job(job_config, teuth_bin_path, archive_dir, verbose): @@ -152,6 +152,7 @@ def run_job(job_config, teuth_bin_path, archive_dir, verbose): log.info('Success!') if 'targets' in job_config: unlock_targets(job_config) + return p.returncode def failure_is_reimage(failure_reason): if not failure_reason: