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

[OSSTEST PATCH 75/82] host reuse: New protocol between sg-run-job and ts-host-reuse



From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

Abolish post-test-ok (which runs only if successful) and replace it
with final (which sets the runvar to indicate finality, and runs
regardless).

This allows a subsequent job which reuses the host to see that this
job had finished using the host.  This is relevant for builds, where a
host can be reused even after a failed job.

"Lies", where we claim the use of the host was done, are
avoided (barring unlikely races) because selecthost de-finalises the
runvar.

Signed-off-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
---
 sg-run-job    |  8 +++++++-
 ts-host-reuse | 25 ++++++++++++++++---------
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 2feb67d9..dd76d4f2 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -124,7 +124,13 @@ proc run-job {job} {
        set ok 0
     }
 
-    if {$ok} { per-host-ts .  =            { ts-host-reuse post-test-ok } }
+    if {[llength $need_build_host]} {
+       run-ts !broken =                  ts-host-reuse final host
+    }
+    set reuse {}
+    if {$ok} { lappend reuse --post-test-ok }
+    eval [list per-host-ts !broken  = { ts-host-reuse final }] $reuse
+
     if {$ok} { setstatus pass                                             }
 
     if {[llength $need_build_host] && $ok} { jobdb::preserve-task 90 }
diff --git a/ts-host-reuse b/ts-host-reuse
index 21d77500..ae967304 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -154,15 +154,22 @@ sub act_start_test () {
     host_shared_mark_ready($ho, $sharetype, \%oldstate, 'mid-test');
 }
 
-sub act_post_test_ok () {
-    die if @ARGV;
-    compute_test_sharetype();
-    $ho = selecthost($whhost);
-    return unless $ho->{Shared};
-    die unless $ho->{Shared}{State} eq 'mid-test';
-    post_test_cleanup();
-    host_update_lifecycle_info($ho, 'final');
-    host_shared_mark_ready($ho, $sharetype, 'mid-test', 'ready');
+sub act_final () {
+    if (!@ARGV) {
+       $ho = selecthost($whhost);
+       return unless $ho;
+       host_update_lifecycle_info($ho, 'final');
+    } elsif ("@ARGV" eq "--post-test-ok") {
+       compute_test_sharetype();
+       $ho = selecthost($whhost);
+       return unless $ho->{Shared};
+       die unless $ho->{Shared}{State} eq 'mid-test';
+       post_test_cleanup();
+       host_update_lifecycle_info($ho, 'final');
+       host_shared_mark_ready($ho, $sharetype, 'mid-test', 'ready');
+    } else {
+       die;
+    }
 }
 
 $action =~ y/-/_/;
-- 
2.20.1




 


Rackspace

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