[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 11/15] sg-run-job: Make catching-otherwise honour $ok



This is more regular and abolishes a number of explicit $ok tests in
run-job.

Of the call sites:
 * "catching-otherwise blocked check-not-blocked" near the top of
   run-job is soon after $ok is set, so NFC.
 * The other call sites in run-job all test $ok explicitly, so NFC.
 * The one call site outside run-job (in examine-host-examine)
   contains only calls to run-ts, and to examine-host-install-* which
   itself only contains similar calls.  These all therefore honour $ok
   already.  So NFC.

While we are here:
 * Add a doc comment.
 * Do some slight whitespace fixups.

Overall, no functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 sg-run-job | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 66c2c19..654ba83 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -62,7 +62,7 @@ proc run-job {job} {
     }
     set nested_layers_hosts {}
 
-    catching-otherwise blocked            check-not-blocked
+    catching-otherwise blocked check-not-blocked
     if {!$ok} return
 
     if {[llength $need_xen_hosts]} {
@@ -73,19 +73,18 @@ proc run-job {job} {
 
     if {$ok} { setstatus running                                          }
 
-    if {$ok && ![catch { info args prep-job/$jobinfo(recipe) }]} \
-        {      catching-otherwise fail     prep-job/$jobinfo(recipe)      }
+    if {![catch { info args prep-job/$jobinfo(recipe) }]} \
+        { catching-otherwise fail prep-job/$jobinfo(recipe) }
 
     if {$ok} { set syslog [spawn-ts broken = | ts-syslog-server]          }
 
-    if {$ok && $need_build_host} \
-        { catching-otherwise broken prepare-build-host }
+    if {$need_build_host} { catching-otherwise broken prepare-build-host }
 
     per-host-ts broken  host-install/@(*) ts-host-install-twice
 
     per-host-prep
 
-    if {$ok} { catching-otherwise fail      run-job/$jobinfo(recipe)      }
+    catching-otherwise fail run-job/$jobinfo(recipe)
 
     while 1 {
        per-host-finish
@@ -126,8 +125,15 @@ proc run-job {job} {
 }
 
 proc catching-otherwise {failst script} {
+    # Executes $script.
+    # If job is already a failure (ie not $ok), skips it (ie does nothing).
+    # If any Tcl exception is thrown, declares the job a failure.
+    # (ie sets job status to $failst, and sets anyfailed to 1 and ok to 0)
+
     global anyfailed flight jobinfo ok
 
+    if {!$ok} return
+
     if {[catch {
         uplevel 1 $script
     } emsg]} {
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.