]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
supervisor: Return job's return code
authorZack Cerza <zack@redhat.com>
Mon, 21 Mar 2022 23:44:34 +0000 (17:44 -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
teuthology/dispatcher/supervisor.py

index 669f1251110e8fd5b41be2d774222ce57556acd7..8d955e48c3a1c952f84013405a212e54bc0e624e 100644 (file)
@@ -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))
index f6eea469d971d3a0a3a9a712019923deca987598..5902f40353398224d7e174bbf5f78c3339edc032 100644 (file)
@@ -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'))
index 3036d0335c08b9f00bb34cfd36ffb25bd203122b..f52e37938f297de6fa3d5df17b4956ad82b67a3c 100644 (file)
@@ -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: