All the watchers and also the main autoqa script should return non-zero
exit code when job scheduling fails. This patch fixes that.
---
 autoqa                                          |    8 ++++++--
 hooks/post-bodhi-update/watch-bodhi-requests.py |   12 +++++++++---
 hooks/post-koji-build/watch-koji-builds.py      |    9 ++++++++-
 hooks/post-repo-update/watch-repos.py           |    7 ++++++-
 hooks/post-tree-compose/watch-composes.py       |    7 ++++++-
 5 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/autoqa b/autoqa
index a4261ec..cb2d737 100755
--- a/autoqa
+++ b/autoqa
@@ -281,13 +281,13 @@ if opts.listtests:
     sys.exit(0)
 
 # We're ready to run/queue tests now.
+exit_status = 0
 for test in testlist:
     try:
         template = os.path.join(conf['testdir'], test, 'control')
         control = prep_controlfile(template, test_vars[test]['autoqa_args'])
     except IOError, e:
-        print "WARNING: could not process control file for %s: %s" % (test,
-                                                                     str(e))
+        print "WARNING: could not process control file for %s: %s" % (test, 
str(e))
         continue
 
     for arch in test_vars[test]['archs']:
@@ -303,8 +303,12 @@ for test in testlist:
                                   labels=test_vars[test]['labels'])
             if retval != 0:
                 print "ERROR: failed to schedule job %s" % testname
+                exit_status = 10
 
     if opts.keep_control_file or opts.dryrun:
         print "keeping %s at user request" % control
     else:
         os.remove(control)
+
+sys.exit(exit_status)
+
diff --git a/hooks/post-bodhi-update/watch-bodhi-requests.py 
b/hooks/post-bodhi-update/watch-bodhi-requests.py
index 593ba9d..1c5b3f4 100755
--- a/hooks/post-bodhi-update/watch-bodhi-requests.py
+++ b/hooks/post-bodhi-update/watch-bodhi-requests.py
@@ -53,7 +53,7 @@
 import fedora.client
 import optparse
 import time
-import os
+import os, sys
 import subprocess
 from autoqa.repoinfo import repoinfo
 from autoqa.bodhi_utils import bodhitime, parse_bodhitime, bodhi_list
@@ -247,15 +247,21 @@ when new requests are filed in bodhi')
         for u in updates['testing']:
             add_update_to_arglist(u, '-updates-testing')
 
+    exit_status = 0
     for a in arglist:
         harnesscall = ['autoqa', 'post-bodhi-update'] + a
         if opts.dryrun:
             print " ".join(harnesscall)
         else:
-            subprocess.call(harnesscall)
+            retval = subprocess.call(harnesscall)
+            if retval != 0:
+                exit_status = 10
+
+    sys.exit(exit_status)
 
 if __name__ == '__main__':
     try:
         main()
     except KeyboardInterrupt:
-        print
+        print 'Exiting on keyboard interrupt...'
+        sys.exit(1)
diff --git a/hooks/post-koji-build/watch-koji-builds.py 
b/hooks/post-koji-build/watch-koji-builds.py
index 56a093f..4cc2d7f 100755
--- a/hooks/post-koji-build/watch-koji-builds.py
+++ b/hooks/post-koji-build/watch-koji-builds.py
@@ -129,6 +129,7 @@ tags for new builds and kick off tests when new 
builds/packages are found.')
     session = koji_utils.SimpleKojiClientSession(kojiserver, kojiopts)
     untagged_builds = []
     tagged_builds = []
+    exit_status = 0
     try:
         session.ensure_connection()
         (tagged_builds, untagged_builds) = new_builds_since(session,
@@ -156,6 +157,12 @@ tags for new builds and kick off tests when new 
builds/packages are found.')
                 if opts.dryrun:
                     print " ".join(harnesscall)
                     continue
-                subprocess.call(harnesscall)
+                retval = subprocess.call(harnesscall)
+                if retval != 0:
+                    exit_status = 10
+
     except KeyboardInterrupt:
         print "Exiting on keyboard interrupt."
+        sys.exit(1)
+
+    sys.exit(exit_status)
diff --git a/hooks/post-repo-update/watch-repos.py 
b/hooks/post-repo-update/watch-repos.py
index d5e6d8f..0d3ce8f 100755
--- a/hooks/post-repo-update/watch-repos.py
+++ b/hooks/post-repo-update/watch-repos.py
@@ -76,6 +76,7 @@ for reponame in repoinfo.repos():
             testable[reponame].append(arch)
 
 # Cycle through the testable repos and update the cache and launch harness
+exit_status = 0
 for reponame, arches in sorted(testable.items()):
     for arch in arches:
         repo = repodict[reponame]
@@ -102,4 +103,8 @@ for reponame, arches in sorted(testable.items()):
         urlgrabber.urlgrab(urlpath, filename=output)
 
         # Call the autoqa tool for the post-repo-update harness
-        subprocess.call(harnesscall)
+        retval = subprocess.call(harnesscall)
+        if retval != 0:
+            exit_status = 10
+
+sys.exit(exit_status)
diff --git a/hooks/post-tree-compose/watch-composes.py 
b/hooks/post-tree-compose/watch-composes.py
index 8966fc7..64a7fd3 100755
--- a/hooks/post-tree-compose/watch-composes.py
+++ b/hooks/post-tree-compose/watch-composes.py
@@ -81,6 +81,7 @@ for reponame in watchcomposes:
             testable[reponame].append(arch)
 
 # Cycle through the testable repos and update the cache and launch harness
+exit_status = 0
 for reponame, arches in sorted(testable.items()):
     for arch in arches:
         repo = repodict[reponame]
@@ -102,4 +103,8 @@ for reponame, arches in sorted(testable.items()):
         urlgrabber.urlgrab(urlpath, filename=output)
 
         # launch tests
-        subprocess.call(harnesscall)
+        retval = subprocess.call(harnesscall)
+        if retval != 0:
+            exit_status = 10
+
+sys.exit(exit_status)
-- 
1.7.3.2

_______________________________________________
autoqa-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/autoqa-devel

Reply via email to