All of lore.kernel.org
 help / color / mirror / Atom feed
* [OSSTEST PATCH 00/82] Reuse test hosts
@ 2020-10-07 17:59 Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 01/82] ms-queuedaemon: Update for newer Tcl's socket channel ids Ian Jackson
                   ` (82 more replies)
  0 siblings, 83 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

This series arranges to save on host setup by reusing a test host, if
the previous test passed.  Care is taken to make sure that a host is
only reused in this way if the new test would have set it up
identically.

I have had this branch in preparation since November 2017...

-- 
2.20.1



^ permalink raw reply	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 01/82] ms-queuedaemon: Update for newer Tcl's socket channel ids
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 02/82] Executive.pm planner: fix typo Ian Jackson
                   ` (81 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Now we have things like "sock55599edaf050" where previously we had
something like "sock142".  So the output is misaligned.

Bump the sizes.  And with these longer names, when showing the front
of the queue only print the full first entry and the start of the next
one.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ms-queuedaemon | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ms-queuedaemon b/ms-queuedaemon
index a3a009ca..dc858863 100755
--- a/ms-queuedaemon
+++ b/ms-queuedaemon
@@ -91,7 +91,7 @@ proc log-event {m} {
 proc log-state {m} {
     global need_queue_run queue
 
-    set lhs [format "N=%d Q=%d (%-15.15s) " \
+    set lhs [format "N=%d Q=%d (%-20.20s) " \
                  $need_queue_run [llength $queue] $queue]
 
     foreach-walker w {
@@ -99,13 +99,13 @@ proc log-state {m} {
 	if {[info exists queue_running]} {
 	    append lhs [format "R=%-3d " [llength $queue_running]]
 	    if {[info exists thinking]} {
-		append lhs [format "T=%-7s " $thinking]
+		append lhs [format "T=%-16s " $thinking]
 	    } else {
-		append lhs [format "          "]
+		append lhs [format "                   "]
 	    }
-	    append lhs [format "(%-15.15s) " $queue_running]
+	    append lhs [format "(%-20.20s) " $queue_running]
 	} else {
-	    append lhs "                                  "
+	    append lhs "                                                "
 	}
     }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 02/82] Executive.pm planner: fix typo
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 01/82] ms-queuedaemon: Update for newer Tcl's socket channel ids Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 03/82] README.planner: Document magic job hostflags Ian Jackson
                   ` (80 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index a0d9f81e..f17e7b70 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -702,7 +702,7 @@ sub plan_search ($$$$) {
 
 	    next PERIOD if $endevt->{Time} <= $try_time;
             # this period is entirely before the proposed slot;
-            # it doesn't overlap, but most check subsequent periods
+            # it doesn't overlap, but must check subsequent periods
 
 	  CHECK:
 	    {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 03/82] README.planner: Document magic job hostflags
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 01/82] ms-queuedaemon: Update for newer Tcl's socket channel ids Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 02/82] Executive.pm planner: fix typo Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 04/82] sg-run-job: Minor whitespace (formatting) changes Ian Jackson
                   ` (79 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 README.planner | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/README.planner b/README.planner
index c33aae11..f134d716 100644
--- a/README.planner
+++ b/README.planner
@@ -203,6 +203,66 @@ that shared systems get regrooved occasionally even if nothing decides
 to unshare them.
 
 
+ts-hosts-allocate-Executive and hostflags
+----------------------------------------
+
+Within a job, the allocations are actually done by
+ts-hosts-allocate-Executive.  It is told what to do by its command
+line arguments, which are (usually) simply IDENTs.
+
+The IDENTs provide the key for runvars which control the host
+allocation algorithm.  Principally, these are the runvars which define
+the job's hostflags
+    all_hostflags
+    IDENT_hostflags
+    runtime_IDENT_hostflags
+(all of these are comma-separated lists).
+
+Each such hostflag must, in general, be set for a particular host, for
+that host to be eligible.  But there are some special forms of job
+hostflag:
+
+  share-SHARING
+
+    The host may be shared with other jobs.  Typically used for
+    builds.  SHARING is a string which denotes the "scope" of the
+    sharing - jobs with the same SHARING should set the host up
+    identically.  The osstest test harness revision is automatically
+    appended and therefore does not need to be included.
+
+  equiv-FORMALTOKEN
+
+    For each equiv-FORMALTOKEN job flag set on one or more IDENTs, a
+    corresponding equiv-ACTUALTOKEN host flag must be set on the
+    corresponding hosts.  So, for example, if the IDENTs src_host and
+    dst_host both have equiv-1 specified, then the two hosts chosen
+    for src_host and dst_host will have an actual hostflag in common
+    which matches the pattern equiv-*.
+
+  diverse-FORMATLTOKEN
+
+    For each diverse-FORMALTOKEN flag, the selected host will *not* be
+    the same as any other allocation with the same diverse-FORMALTOKEN
+    flag in the same *flight*.
+
+  CONDNAME:CONDARGS...
+
+    Looks up CONDNAME as Osstest::ResourceCondition::PROPNAME.
+    The selected host must match the appropriate condition.
+    CONDNAMEs are:
+
+  PropEq:HOSTPROP:VAL
+
+    Require the host property HOSTPROP to be equal to VAL,
+    according to string comparison.  (Unset properties are
+    match an empty VAL.)
+
+  PropMinVer:HOSTPROP:VAL
+
+    Require the host property HOSTPROP to be at least VAL, according
+    to version number comparison (as implemented by dpkg and
+    coreutils).
+
 Flights
 -------
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 04/82] sg-run-job: Minor whitespace (formatting) changes
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (2 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 03/82] README.planner: Document magic job hostflags Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 05/82] sg-run-job: Improve some internal API docs Ian Jackson
                   ` (78 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index df3d08d0..3db05b34 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -30,12 +30,12 @@ proc per-host-prep {} {
     per-host-ts .       xen-boot/@        ts-host-reboot
 
     per-host-ts .       host-ping-check-xen/@ ts-host-ping-check
-    per-host-ts .       =(*)             {ts-leak-check basis}
+    per-host-ts .       =(*)            { ts-leak-check basis }
 }
 
 proc per-host-finish {} {
     if {[nested-hosts-p]} { set broken fail } { set broken broken }
-    per-host-ts .       =                {ts-leak-check check}
+    per-host-ts .       =               { ts-leak-check check }
     per-host-ts !$broken capture-logs/@(*) ts-logs-capture
 }
 
@@ -96,7 +96,7 @@ proc run-job {job} {
 	
 	if {![nested-hosts-p]} break
 
-	per-host-ts . final-poweroff {ts-host-powercycle --power=0}
+	per-host-ts . final-poweroff { ts-host-powercycle --power=0 }
 
         set need_xen_hosts [lunappend nested_layers_hosts]
     }
@@ -549,7 +549,7 @@ proc setup-test-pair {} {
     run-ts . =              ts-debian-install      dst_host
     run-ts . =              ts-debian-fixup        dst_host          + debian
     run-ts . =              ts-guests-nbd-mirror + dst_host src_host + debian
-    per-host-ts . =(*)     {ts-leak-check basis}
+    per-host-ts . =(*)    { ts-leak-check basis }
     run-ts . =              ts-guest-start       + src_host          + debian
 }
 proc need-hosts/test-pair {} { return {src_host dst_host} }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 05/82] sg-run-job: Improve some internal API docs
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (3 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 04/82] sg-run-job: Minor whitespace (formatting) changes Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 06/82] show_abs_time: Represent undef $timet as <undef> Ian Jackson
                   ` (77 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-run-job | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 3db05b34..702ed558 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -206,12 +206,12 @@ proc recipe-flag {flagname {def 0}} {
 #                    general steps from running)
 #               The job status is set to IFFAIL.
 #
-#   per-host-ts IFFAIL TESTID SCRIPT-ARGS...
+#   per-host-ts IFFAIL TESTID SCRIPT-ARGS-LIST MORE-ARGS...
 #
 #       Runs the script (as a separate step) for each test host ident.
-#       The host ident is appended to SCRIPT-ARGS.  (SCRIPT-ARGS
-#       should contain an even number of + items for proper testid
-#       generation.)
+#       The host ident is appended to SCRIPT-ARGS-LIST.
+#       (SCRIPT-ARGS-LIST should contain an even number of + items for
+#       proper testid generation.)
 #
 #       The scripts are run in parallel for all host idents.
 #
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 06/82] show_abs_time: Represent undef $timet as <undef>
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (4 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 05/82] sg-run-job: Improve some internal API docs Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 07/82] ts-hosts-allocate-Executive: Add a comment about a warning Ian Jackson
                   ` (76 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This can happen, for example, if a badly broken flight has steps which
are STARTING and have NULL in the start time column, and is then
reported using sg-report-flight.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Osstest.pm b/Osstest.pm
index b2b6b741..734c0ef6 100644
--- a/Osstest.pm
+++ b/Osstest.pm
@@ -457,6 +457,7 @@ sub visible_undef ($) {
 
 sub show_abs_time ($) {
     my ($timet) = @_;
+    return '<undef>' unless defined $timet;
     return strftime "%Y-%m-%d %H:%M:%S Z", gmtime $timet;
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 07/82] ts-hosts-allocate-Executive: Add a comment about a warning
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (5 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 06/82] show_abs_time: Represent undef $timet as <undef> Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 08/82] host reuse: ms-planner: Bring some variables forward Ian Jackson
                   ` (75 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 58d2a389..78b94c6d 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -1039,6 +1039,10 @@ sub actual_allocation ($) {
 	    if ($shared->{ntasks}) {
 		warn "resource $shrestype $shared->{resname} allegedly".
                     " available but wrong state $shared->{state} and tasks";
+		# This can happen if following a failed prep by
+		# another job, the other shares are still owned by the
+		# now-dead task.  If so that share will become allocatable
+		# (and therefore not be counted in `ntasks') in due course.
 		return undef;
 
                 # someone was preparing it but they aren't any more
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 08/82] host reuse: ms-planner: Bring some variables forward
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (6 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 07/82] ts-hosts-allocate-Executive: Add a comment about a warning Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 09/82] host reuse: ms-planner: Do not show reuse as shared in the plan Ian Jackson
                   ` (74 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Move the scope of $share earlier in cmd_show_html, and also introduce
$shared in the colour computation.  This makes the next changes easier.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ms-planner | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ms-planner b/ms-planner
index 11423404..d9f3db91 100755
--- a/ms-planner
+++ b/ms-planner
@@ -677,6 +677,7 @@ sub cmd_show_html () {
 	my $shares;
 	foreach my $evt (@{ $plan->{Events}{$reso} }) {
 	    my $type= $evt->{Type};
+	    my $share= $evt->{Share};
 	    my $show=
 		$type eq End ? ($evt->{Share} ? "End $evt->{Info}" : "") :
                 $type eq Unshare ? "$type [".showsharetype($evt->{Info})."]" :
@@ -685,7 +686,6 @@ sub cmd_show_html () {
 		(!$evt->{Allocated} ? Booking :
                  ($evt->{Allocated}{Live} ? Allocation : Completed).
                  " $evt->{Allocated}{Task}")." ".$evt->{Info};
-	    my $share= $evt->{Share};
 	    if ($share) {
 		$show .= sprintf(" [%s %d/%d %d]",
 				 showsharetype($share->{Type}),
@@ -789,15 +789,16 @@ sub cmd_show_html () {
                     $content->{Avail} ||
                     $content->{Type} eq After ||
                     ($content->{Allocated} && !$content->{Allocated}{Live});
+                my $shared = $content->{Share};
                 my $bgcolour=
                     $avail ?
-                    ($content->{Share} ? "#ccccff" : "#ffffff") :
+                    ($shared ? "#ccccff" : "#ffffff") :
                     $content->{Type} eq Overrun ?
-                    ($content->{Share} ? "#443344" : "#442222") :
+                    ($shared ? "#443344" : "#442222") :
                     $content->{Allocated} ?
-                    ($content->{Share} ? "#882288" : "#882222")
+                    ($shared ? "#882288" : "#882222")
                     :
-                    ($content->{Share} ? "#005555" : "#448844");
+                    ($shared ? "#005555" : "#448844");
                 my $fgcolour=
                     $avail ? "#000000" : "#ffffff";
 		printf "<td valign=top rowspan=%d".
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 09/82] host reuse: ms-planner: Do not show reuse as shared in the plan
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (7 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 08/82] host reuse: ms-planner: Bring some variables forward Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 10/82] hsot reuse: ms-planner: Abbreviate reporting of test shares Ian Jackson
                   ` (73 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

If the number of shares is 1, do not show it as shared, and also
ignore the Unshare events.

This clarifies the display, especially when used with forthcoming test
host reuse work.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ms-planner | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ms-planner b/ms-planner
index d9f3db91..4e38e4e3 100755
--- a/ms-planner
+++ b/ms-planner
@@ -249,6 +249,7 @@ sub launder_check_plan () {
 			Avail => 1,
 			Info => $cshare->{Type},
 			PreviousShare => $cshare,
+                        Shares => $cshare->{Shares},
 		    };
 		    $cshare= undef;
 		}
@@ -678,6 +679,7 @@ sub cmd_show_html () {
 	foreach my $evt (@{ $plan->{Events}{$reso} }) {
 	    my $type= $evt->{Type};
 	    my $share= $evt->{Share};
+	    next if $type eq 'Unshare' && $evt->{Shares} == 1;
 	    my $show=
 		$type eq End ? ($evt->{Share} ? "End $evt->{Info}" : "") :
                 $type eq Unshare ? "$type [".showsharetype($evt->{Info})."]" :
@@ -686,7 +688,7 @@ sub cmd_show_html () {
 		(!$evt->{Allocated} ? Booking :
                  ($evt->{Allocated}{Live} ? Allocation : Completed).
                  " $evt->{Allocated}{Task}")." ".$evt->{Info};
-	    if ($share) {
+	    if ($share && $share->{Shares} != 1) {
 		$show .= sprintf(" [%s %d/%d %d]",
 				 showsharetype($share->{Type}),
 				 $share->{Shares} - $evt->{Avail},
@@ -789,7 +791,8 @@ sub cmd_show_html () {
                     $content->{Avail} ||
                     $content->{Type} eq After ||
                     ($content->{Allocated} && !$content->{Allocated}{Live});
-                my $shared = $content->{Share};
+                my $shared = $content->{Share}
+		          && $content->{Share}{Shares} != 1;
                 my $bgcolour=
                     $avail ?
                     ($shared ? "#ccccff" : "#ffffff") :
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 10/82] hsot reuse: ms-planner: Abbreviate reporting of test shares
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (8 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 09/82] host reuse: ms-planner: Do not show reuse as shared in the plan Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 11/82] cr-publish-flight-logs: Fix abs_time calls Ian Jackson
                   ` (72 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ms-planner | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ms-planner b/ms-planner
index 4e38e4e3..78d27b2f 100755
--- a/ms-planner
+++ b/ms-planner
@@ -414,11 +414,13 @@ END
 	next if $plan->{Events}{$reskey};
 	print DEBUG "document existing quiescent sharing $reskey".
 	    " share.Type $cshare->{Type}\n";
+	my $type = $cshare->{Type};
+	$type = "$&..." if $type =~ m{^test-\d+(?=\-)};
 	my $evt = {
             Time => $plan->{Start},
             Type => Unshare,
 	    Avail => 1,
-            Info => "recently shared $cshare->{Type}",
+            Info => "recently $type",
             PreviousShare => { %$cshare },
 	};
 	delete $evt->{PreviousShare}{OnlyPreparing};
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 11/82] cr-publish-flight-logs: Fix abs_time calls
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (9 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 10/82] hsot reuse: ms-planner: Abbreviate reporting of test shares Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 12/82] target setup refactoring: Move target_kernkind_check Ian Jackson
                   ` (71 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

There was a missing space in these messages, since they were
introduced in 31b7cae19fe1
  timing traces: cr-publish-flight-logs: Report more progress

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 cr-publish-flight-logs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cr-publish-flight-logs b/cr-publish-flight-logs
index 63c47d9f..c570dfaf 100755
--- a/cr-publish-flight-logs
+++ b/cr-publish-flight-logs
@@ -43,7 +43,7 @@ die unless $flight =~ m/^\d*$/;
 
 die "usage: ./cr-publish-flight-logs [flight]" unless @ARGV==0;
 
-sub progress { print +(show_abs_time time), @_, "\n" }
+sub progress { print +(show_abs_time time), " ", @_, "\n" }
 
 progress("acquiring publish-lock...");
 open LOCK, "> $c{GlobalLockDir}/publish-lock" or die $!;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 12/82] target setup refactoring: Move target_kernkind_check
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (10 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 11/82] cr-publish-flight-logs: Fix abs_time calls Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 13/82] target setup refactoring: Move target_kernkind_console_inittab Ian Jackson
                   ` (70 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This is OK because nothing in access() looks at the rootdev or console
runvars, which are what target_kernkind_check sets.

No functional change other than perhaps to log output.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-debian-fixup | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ts-debian-fixup b/ts-debian-fixup
index 528fb03b..34051137 100755
--- a/ts-debian-fixup
+++ b/ts-debian-fixup
@@ -209,8 +209,8 @@ sub writecfg () {
 
 savecfg();
 ether();
-target_kernkind_check($gho);
 access();
+target_kernkind_check($gho);
 
 debian_overlays($ho, \&overlay);
 target_cmd_root($ho, <<END.debian_overlays_fixup_cmd($ho, $mountpoint));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 13/82] target setup refactoring: Move target_kernkind_console_inittab
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (11 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 12/82] target setup refactoring: Move target_kernkind_check Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 14/82] target setup refactoring: Merge target_kernkind_* Ian Jackson
                   ` (69 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

We move this earlier.  This is OK because it depends only on the
console runvar (inside the sub; this is set by target_kernkind_check),
$ho and $gho (which are set by this point); and $mountpoint$ (which is
set by access().

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-debian-fixup | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ts-debian-fixup b/ts-debian-fixup
index 34051137..2184212b 100755
--- a/ts-debian-fixup
+++ b/ts-debian-fixup
@@ -79,10 +79,9 @@ END
 }
 
 our $extra;
+our $console;
 
 sub console () {
-    my $console=
-        target_kernkind_console_inittab($ho,$gho,"$mountpoint");
     return unless length $console;
     
     my $xextra= "console=$console earlyprintk=xen";
@@ -211,6 +210,7 @@ savecfg();
 ether();
 access();
 target_kernkind_check($gho);
+$console = target_kernkind_console_inittab($ho,$gho,"$mountpoint");
 
 debian_overlays($ho, \&overlay);
 target_cmd_root($ho, <<END.debian_overlays_fixup_cmd($ho, $mountpoint));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 14/82] target setup refactoring: Merge target_kernkind_*
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (12 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 13/82] target setup refactoring: Move target_kernkind_console_inittab Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 15/82] target setup refactoring: Add a doc comment Ian Jackson
                   ` (68 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Combine these two functions.  Rename them to a name which doesn't
mention "kernkind".

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm      |  3 +--
 Osstest/TestSupport.pm | 11 ++++-------
 ts-debian-fixup        |  3 +--
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index b140ede2..85fd16da 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -68,8 +68,7 @@ sub debian_boot_setup ($$$$$;$) {
     # $xenhopt==undef => is actually a guest, do not set up a hypervisor
     my ($ho, $want_kernver, $want_xsm, $xenhopt, $distpath, $hooks) = @_;
 
-    target_kernkind_check($ho);
-    target_kernkind_console_inittab($ho,$ho,"/");
+    target_setup_rootdev_console_inittab($ho,$ho,"/");
 
     my $kopt;
     my $console= target_var($ho,'console');
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index faac106f..fd7b238b 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -105,7 +105,7 @@ BEGIN {
                       host_get_free_memory
 
                       target_ping_check_down target_ping_check_up
-                      target_kernkind_check target_kernkind_console_inittab
+                      target_setup_rootdev_console_inittab
                       target_var target_var_prefix
                       selectguest prepareguest more_prepareguest_hvm
 		      guest_template
@@ -2562,8 +2562,9 @@ sub target_var ($$) {
     return undef;
 }
 
-sub target_kernkind_check ($) {
-    my ($gho) = @_;
+sub target_setup_rootdev_console_inittab ($$$) {
+    my ($ho, $gho, $root) = @_;
+
     my $pfx= target_var_prefix($gho);
     my $kernkind= $r{$pfx."kernkind"} // 'pvops';
     my $isguest= exists $gho->{Guest};
@@ -2573,10 +2574,6 @@ sub target_kernkind_check ($) {
     } elsif ($kernkind !~ m/2618/) {
         store_runvar($pfx."console", 'xvc0') if $isguest;
     }
-}
-
-sub target_kernkind_console_inittab ($$$) {
-    my ($ho, $gho, $root) = @_;
 
     my $inittabpath= "$root/etc/inittab";
     my $console= target_var($gho,'console');
diff --git a/ts-debian-fixup b/ts-debian-fixup
index 2184212b..a878fe50 100755
--- a/ts-debian-fixup
+++ b/ts-debian-fixup
@@ -209,8 +209,7 @@ sub writecfg () {
 savecfg();
 ether();
 access();
-target_kernkind_check($gho);
-$console = target_kernkind_console_inittab($ho,$gho,"$mountpoint");
+$console = target_setup_rootdev_console_inittab($ho,$gho,"$mountpoint");
 
 debian_overlays($ho, \&overlay);
 target_cmd_root($ho, <<END.debian_overlays_fixup_cmd($ho, $mountpoint));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 15/82] target setup refactoring: Add a doc comment
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (13 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 14/82] target setup refactoring: Merge target_kernkind_* Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 16/82] abolish "kernkind"; desupport non-pvops kernels Ian Jackson
                   ` (67 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index fd7b238b..d9bb2585 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -2563,6 +2563,9 @@ sub target_var ($$) {
 }
 
 sub target_setup_rootdev_console_inittab ($$$) {
+    # Operators on $gho.
+    # $gho's filesystem is accessed via $ho and $mountpoint;
+    # so maybe $gho is $ho and $mountpoint is "/".
     my ($ho, $gho, $root) = @_;
 
     my $pfx= target_var_prefix($gho);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 16/82] abolish "kernkind"; desupport non-pvops kernels
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (14 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 15/82] target setup refactoring: Add a doc comment Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-13  9:29   ` Wei Liu
  2020-10-07 17:59 ` [OSSTEST PATCH 17/82] Debian: osstest-erase-other-disks: Slightly guard against races Ian Jackson
                   ` (66 subsequent siblings)
  82 siblings, 1 reply; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel
  Cc: Ian Jackson, Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Konrad Rzeszutek Wilk, Roger Pau Monné,
	Wei Liu, Paul Durrant, Oleksandr Andrushchenko, Andrew Cooper,
	Olivier Lambert

From: Ian Jackson <ian.jackson@eu.citrix.com>

This was for distinguishing the old-style Xenolinux kernels from pvops
kernels.

We have not actually tested any non-pvops kernels for a very very long
time.  Delete this now because the runvar is slightly in the way of
test host reuse.

(Sorry for the wide CC but it seems better to make sure anyone who
might object can do so.)

All this machinery exists just to configure the guest console
device (Xenolinux used "xvc" rather than "hvc") and the guest root
block device (Xenolinux stole "hda"/"sda" rather than using "xvda").

Specifically, in this commit:
 * In what is now target_setup_rootdev_console_inittab, do not
   look at any kernkind runvar and simply do what we would if
   it were "pvops" or unset, as it is in all current jobs.
 * Remove the runvar from all jobs creation and example runes.
   (This has no functional change even for jobs running with
   the previous osstest code because we have defaulted to "pvops"
   for a very long time.)

We retain the setting of the shell variable "kernbuild", because that
ends up in build jobs' names.  All our kernel build jobs now end in
-pvops and I intend to retain that name component since abolishing it
is nontrivial.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
CC: Juergen Gross <jgross@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wei.liu@kernel.org>
CC: Paul Durrant <paul@xen.org>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Juergen Gross <jgross@suse.com>
CC: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
CC: Andrew Cooper <Andrew.Cooper3@citrix.com>
CC: Olivier Lambert <olivier.lambert@vates.fr>
---
 Osstest/TestSupport.pm | 9 ++-------
 README                 | 2 +-
 make-hosts-flight      | 1 -
 mfi-common             | 7 ++-----
 4 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index d9bb2585..99c7654d 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -2569,14 +2569,9 @@ sub target_setup_rootdev_console_inittab ($$$) {
     my ($ho, $gho, $root) = @_;
 
     my $pfx= target_var_prefix($gho);
-    my $kernkind= $r{$pfx."kernkind"} // 'pvops';
     my $isguest= exists $gho->{Guest};
-    if ($kernkind eq 'pvops') {
-        store_runvar($pfx."rootdev", 'xvda') if $isguest;
-        store_runvar($pfx."console", 'hvc0');
-    } elsif ($kernkind !~ m/2618/) {
-        store_runvar($pfx."console", 'xvc0') if $isguest;
-    }
+    store_runvar($pfx."rootdev", 'xvda') if $isguest;
+    store_runvar($pfx."console", 'hvc0');
 
     my $inittabpath= "$root/etc/inittab";
     my $console= target_var($gho,'console');
diff --git a/README b/README
index 2804ecf3..ba4bea1d 100644
--- a/README
+++ b/README
@@ -861,7 +861,7 @@ echo $flight
 job=play-amd64-amd64-xen-boot
 ./cs-job-create $flight $job play-xen-boot-x5 \
     all_hostflags=arch-amd64,arch-xen-amd64,suite-wheezy,purpose-test \
-    arch=amd64 toolstack=xl enable_xsm=false kernkind=pvops \
+    arch=amd64 toolstack=xl enable_xsm=false \
     host=$host
 
 # Reuse the binaries from the Xen template job for both the hypervisor
diff --git a/make-hosts-flight b/make-hosts-flight
index e2c3776a..63ac7b71 100755
--- a/make-hosts-flight
+++ b/make-hosts-flight
@@ -73,7 +73,6 @@ hosts_iterate () {
         local freebsd_runvars
         set_freebsd_runvars true
         runvars+=" 
-                   kernkind=pvops
                    all_host_di_version=$di_version
                    all_host_suite=$suite
                    $freebsd_runvars
diff --git a/mfi-common b/mfi-common
index e577449f..34b0c116 100644
--- a/mfi-common
+++ b/mfi-common
@@ -619,9 +619,8 @@ test_matrix_iterate () {
       case $kern in
       '')
                   kernbuild=pvops
-                  kernkind=pvops
                   ;;
-      *)          echo >&2 "kernkind ?  $kern"; exit 1 ;;
+      *)          echo >&2 "kernbuild ?  $kern"; exit 1 ;;
       esac
 
       for dom0arch in i386 amd64 armhf arm64; do
@@ -639,8 +638,7 @@ test_matrix_iterate () {
             arch_runvars=\"\$ARCH_RUNVARS_$dom0arch\"
         "
 
-        debian_runvars="debian_kernkind=$kernkind \
-                        debian_arch=$dom0arch \
+        debian_runvars="debian_arch=$dom0arch \
                         debian_suite=$guestsuite \
                         "
 
@@ -659,7 +657,6 @@ test_matrix_iterate () {
         most_runvars="
                   arch=$dom0arch                                  \
                   kernbuildjob=${bfi}build-$dom0arch-$kernbuild   \
-                  kernkind=$kernkind                              \
                   $arch_runvars $hostos_runvars
                   "
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 17/82] Debian: osstest-erase-other-disks: Slightly guard against races
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (15 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 16/82] abolish "kernkind"; desupport non-pvops kernels Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 18/82] host allocation: Remove some unnecessary definedness tests Ian Jackson
                   ` (65 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Apparently it can happen that something decides to rescan a partition
table, removing a partition block device, while it is being zeroed:

 osstest-erase-other-disks-6081: hd devices present after: /dev/hd*
 osstest-erase-other-disks-6081: Erasing /dev/sda
 osstest-erase-other-disks-6081: Erasing /dev/sda1
 osstest-erase-other-disks-6081: /dev/sda1 is no longer a block device!

To try to narrow the window during which this race occurs, do not care
if the thing we just zeroed no longer exists after we zeroed it.

We still bomb out if it exists but is not a block device - that would
probably mean we had written it out as a file.

This is all quite unfortunate.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 85fd16da..3fa26e45 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -1211,8 +1211,8 @@ zero () {
     if test -b \$dev; then
         log "Erasing \$dev"
         dd if=/dev/zero of=\$dev count=64 ||:
-        if ! test -b \$dev; then
-            log "\$dev is no longer a block device!"
+        if test -e \$dev && ! test -b \$dev; then
+            log "\$dev still exists but is no longer a block device!"
             exit 1
         fi
     else
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 18/82] host allocation: Remove some unnecessary definedness tests
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (16 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 17/82] Debian: osstest-erase-other-disks: Slightly guard against races Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 19/82] host allocation: Executive: Honour $xparams{InfraPriority} Ian Jackson
                   ` (64 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

$set_info->() already checkes for undef, and returns immediately in
that case.  So there is no point checking at the call site.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index f17e7b70..5d71d08c 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -849,15 +849,8 @@ sub alloc_resources {
                 $set_info->('sub-priority',$ENV{OSSTEST_RESOURCE_SUBPRIORITY});
                 $set_info->('preinfo',     $ENV{OSSTEST_RESOURCE_PREINFO});
 		$set_info->('feature-noalloc', 1);
-
-                if (defined $waitstart) {
-                    $set_info->('wait-start',$waitstart);
-                }
-
-                my $adjust= $xparams{WaitStartAdjust};
-                if (defined $adjust) {
-                    $set_info->('wait-start-adjust',$adjust);
-                }
+		$set_info->('wait-start',$waitstart);
+		$set_info->('wait-start-adjust',$xparams{WaitStartAdjust});
 
                 my $jobinfo= $xparams{JobInfo};
                 if (!defined $jobinfo and defined $flight and defined $job) {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 19/82] host allocation: Executive: Honour $xparams{InfraPriority}
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (17 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 18/82] host allocation: Remove some unnecessary definedness tests Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 20/82] ts-hosts-allocate-Executive: Fix handling of failed preps for same sharing Ian Jackson
                   ` (63 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

And pass it to ms-queuedaemon.  No functional change with existing
callers since no-one sets this yet.

Forthcoming test host sharing machinery uses this.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 5d71d08c..703f3d85 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -851,6 +851,7 @@ sub alloc_resources {
 		$set_info->('feature-noalloc', 1);
 		$set_info->('wait-start',$waitstart);
 		$set_info->('wait-start-adjust',$xparams{WaitStartAdjust});
+		$set_info->('infra-priority',$xparams{InfraPriority});
 
                 my $jobinfo= $xparams{JobInfo};
                 if (!defined $jobinfo and defined $flight and defined $job) {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 20/82] ts-hosts-allocate-Executive: Fix handling of failed preps for same sharing
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (18 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 19/82] host allocation: Executive: Honour $xparams{InfraPriority} Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 21/82] sg-run-job: support +! for *only* adding things to TESTID Ian Jackson
                   ` (62 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This code was previously unreachable.  It ought to be executed when
all the shares are allocatable or prep: in that case, we can unshare
and re-share the host.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 78b94c6d..2c18a739 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -1044,12 +1044,11 @@ sub actual_allocation ($) {
 		# now-dead task.  If so that share will become allocatable
 		# (and therefore not be counted in `ntasks') in due course.
 		return undef;
-
-                # someone was preparing it but they aren't any more
-                push @allocwarnings,
-                    "previous preparation apparently abandoned";
-                $allocatable= 1;
-            }
+	    }
+	    # someone was preparing it but they aren't any more
+	    push @allocwarnings,
+		"previous preparation apparently abandoned";
+	    $allocatable= 1;
         }
     }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 21/82] sg-run-job: support +! for *only* adding things to TESTID
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (19 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 20/82] ts-hosts-allocate-Executive: Fix handling of failed preps for same sharing Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 22/82] sg-run-job: Use +! in per-host-ts implementation Ian Jackson
                   ` (61 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sg-run-job b/sg-run-job
index 702ed558..3ca725e7 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -277,6 +277,10 @@ proc recipe-flag {flagname {def 0}} {
 #       subsequent items in SCRIPT-ARGS are added to the expansion of
 #       /@ in TESTID.  (The "+" itself is not added to the arguments
 #       or the testid.)
+#
+#       An argument which is precisely "+!" specifies that the
+#       subsequent items in SCRIPT-ARGS are to be _only_ added to
+#       the expansion of /@ in TESTID, until the next "+".
 
 proc run-ts {iffail args} {
     set wantstatus pass
@@ -343,7 +347,11 @@ proc spawn-ts {iffail testid args} {
             set adding [expr {!$adding}]
             continue
         }
-        lappend real_args $arg
+	if {![string compare +! $arg]} {
+	    set adding -1
+	    continue
+	}
+        if {$adding>=0} { lappend real_args $arg }
         if {$adding} { lappend testid_args $arg }
     }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 22/82] sg-run-job: Use +! in per-host-ts implementation
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (20 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 21/82] sg-run-job: support +! for *only* adding things to TESTID Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 23/82] db_retry: Make the sleeps random and increasing Ian Jackson
                   ` (60 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This makes this slightly clearer, even more so in a moment.

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 3ca725e7..3f44cae7 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -458,11 +458,10 @@ proc per-host-ts {iffail ident script args} {
     set awaitl {}
     foreach host $need_xen_hosts {
         set hostargs {}
-        if {![string compare $host host]} {
-            lappend hostargs + $host
-        } else {
-            lappend hostargs $host +
-        }
+	if {[string compare $host host]} {
+	    lappend hostargs +! $host
+	}
+	lappend hostargs + $host
         lappend awaitl [eval spawn-ts $iffail $ident $script $hostargs $args]
     }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 23/82] db_retry: Make the sleeps random and increasing
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (21 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 22/82] sg-run-job: Use +! in per-host-ts implementation Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 24/82] host allocation: *_shared_mark_ready: Allow other states Ian Jackson
                   ` (59 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

When there's a thundering herd, this can run out of retries.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Osstest.pm b/Osstest.pm
index 734c0ef6..809194f0 100644
--- a/Osstest.pm
+++ b/Osstest.pm
@@ -311,7 +311,8 @@ sub db_retry ($$$;$$) {
     my ($pre,$body) =
         (ref $code eq 'ARRAY') ? @$code : (sub { }, $code);
 
-    my $retries= 100;
+    my $max_retries= 100;
+    my $retry_count= 0;
     my $r;
     local $db_retry_stop;
     for (;;) {
@@ -339,10 +340,12 @@ sub db_retry ($$$;$$) {
 	};
 	last if !length $@;
 	die $@ unless $mjobdb->need_retry($dbh, $committing);
-        die "$dbh $body $@ ?" unless $retries-- > 0;
+        die "$dbh $body $@ GIVING UP ?" if ++$retry_count >= $max_retries;
 	eval { $dbh->rollback(); };
-	print STDERR "DB conflict (messages above may refer); retrying...\n";
-        sleep(1);
+	my $delay = rand $retry_count;
+	print STDERR "DB conflict (messages above may refer);".
+	    " retrying after $delay...\n";
+        sleep($delay);
     }
     return $r;
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 24/82] host allocation: *_shared_mark_ready: Allow other states
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (22 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 23/82] db_retry: Make the sleeps random and increasing Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 25/82] host allocation: *_shared_mark_ready: Make $sharetype check optional Ian Jackson
                   ` (58 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Generalise these functions so they can set the state to something
other than `ready', and so that they can expect a state other than
`prep'.

No functional change with existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm       | 19 +++++++++++--------
 Osstest/JobDB/Executive.pm |  5 +++--
 Osstest/TestSupport.pm     |  6 +++---
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 703f3d85..f0038f6b 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -1050,11 +1050,14 @@ END
     return $shared;
 }
 
-sub executive_resource_shared_mark_ready ($$$) {
-    my ($restype, $resname, $sharetype) = @_;
+sub executive_resource_shared_mark_ready ($$$;$$) {
+    my ($restype, $resname, $sharetype, $oldstate, $newstate) = @_;
     # must run outside transaction
 
     my $oldshr;
+    $oldstate //= 'prep';
+    $newstate //= 'ready';
+
     my $what= "resource $restype $resname";
     $sharetype .= ' '.get_harness_rev();
 
@@ -1063,11 +1066,11 @@ sub executive_resource_shared_mark_ready ($$$) {
         if (defined $oldshr) {
             die "$what shared $oldshr->{Type} not $sharetype"
                 unless $oldshr->{Type} eq $sharetype;
-            die "$what shared state $oldshr->{State} not prep"
-                unless $oldshr->{State} eq 'prep';
-            my $nrows= $dbh_tests->do(<<END,{}, $restype,$resname,$sharetype);
+            die "$what shared state $oldshr->{State} not $oldstate"
+                unless $oldshr->{State} eq $oldstate;
+            my $nrows= $dbh_tests->do(<<END,{}, $newstate, $restype,$resname,$sharetype);
                 UPDATE resource_sharing
-                   SET state='ready'
+                   SET state=?
                  WHERE restype=? AND resname=? AND sharetype=?
 END
             die "unexpected not updated state $what $sharetype $nrows"
@@ -1092,9 +1095,9 @@ END
        logm("post-mark-ready queue daemon prod failed: $@");
     }
     if ($oldshr) {
-	logm("$restype $resname shared $sharetype marked ready");
+	logm("$restype $resname shared $sharetype marked $newstate");
     } else {
-	logm("$restype $resname (not shared, $sharetype) is ready");
+	logm("$restype $resname (not shared, $sharetype) is $newstate");
     }
 }
 
diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index 39deb8a2..30629572 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -352,8 +352,9 @@ sub gen_ether_offset ($$) { #method
 }
 
 sub jobdb_resource_shared_mark_ready { #method
-    my ($mo, $restype, $resname, $sharetype) = @_;
-    executive_resource_shared_mark_ready($restype, $resname, $sharetype);
+    my ($mo, $restype, $resname, $sharetype, $oldstate, $newstate) = @_;
+    executive_resource_shared_mark_ready
+	($restype, $resname, $sharetype, $oldstate,$newstate);
 }
 
 sub jobdb_check_other_job { #method
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 99c7654d..7292a329 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -3106,11 +3106,11 @@ sub sha256file ($;$) {
     return $truncate ? substr($digest, 0, $truncate) : $digest;
 }
 
-sub host_shared_mark_ready($$) {
-    my ($ho,$sharetype) = @_;
+sub host_shared_mark_ready($$;$$) {
+    my ($ho,$sharetype, $oldstate, $newstate) = @_;
 
     $mjobdb->jobdb_resource_shared_mark_ready('host', $ho->{Name},
-                                              $sharetype);
+        $sharetype, $oldstate, $newstate);
 }
 
 sub gitcache_setup ($) {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 25/82] host allocation: *_shared_mark_ready: Make $sharetype check optional
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (23 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 24/82] host allocation: *_shared_mark_ready: Allow other states Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 26/82] host allocation: selecthost: allow sort-of-selection of prospective hosts Ian Jackson
                   ` (57 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

We are going to want to be able to set shares to other than ready,
without double-checking the sharetype.

The change to the UPDATE statement makes no difference because
resource_check_allocated_core has just got that sharetype out of the
db.  (This does remove one safety check against bugs, sadly.)

No functional change for existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index f0038f6b..fd975590 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -1059,21 +1059,25 @@ sub executive_resource_shared_mark_ready ($$$;$$) {
     $newstate //= 'ready';
 
     my $what= "resource $restype $resname";
-    $sharetype .= ' '.get_harness_rev();
+    if (defined $sharetype) {
+	$sharetype .= ' '.get_harness_rev();
+    } else {
+	die if $newstate eq 'ready';
+    }
 
     db_retry($dbh_tests, [qw(resources)], sub {
         $oldshr= resource_check_allocated_core($restype, $resname);
         if (defined $oldshr) {
             die "$what shared $oldshr->{Type} not $sharetype"
-                unless $oldshr->{Type} eq $sharetype;
+                unless !defined $sharetype or $oldshr->{Type} eq $sharetype;
             die "$what shared state $oldshr->{State} not $oldstate"
                 unless $oldshr->{State} eq $oldstate;
-            my $nrows= $dbh_tests->do(<<END,{}, $newstate, $restype,$resname,$sharetype);
+            my $nrows= $dbh_tests->do(<<END,{}, $newstate, $restype,$resname);
                 UPDATE resource_sharing
                    SET state=?
-                 WHERE restype=? AND resname=? AND sharetype=?
+                 WHERE restype=? AND resname=?
 END
-            die "unexpected not updated state $what $sharetype $nrows"
+            die "unexpected not updated state $what $nrows"
                 unless $nrows==1;
 
             $dbh_tests->do(<<END,{}, $oldshr->{ResType}, $resname);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 26/82] host allocation: selecthost: allow sort-of-selection of prospective hosts
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (24 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 25/82] host allocation: *_shared_mark_ready: Make $sharetype check optional Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 27/82] host allocation: *_shared_mark_ready: allow alternative $oldtypes Ian Jackson
                   ` (56 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

If one passes a trueish value for $prospective, selecthost does not
worry about whether any host has actually been selected.  It does a
limited amount of prep work.

This will be useful if we want to know some of the non-host-specific
information selecthost computes - in particular, $ho->{Suite} etc.

No functional change with existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 7292a329..3d5f0be3 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -1170,9 +1170,9 @@ sub power_state ($$;$) {
 
 #---------- host selection and properties ----------
 
-sub selecthost ($;$);
-sub selecthost ($;$) {
-    my ($ident, $none_ok) = @_;
+sub selecthost ($;$$);
+sub selecthost ($;$$) {
+    my ($ident, $none_ok, $prospective) = @_;
     # must be run outside transaction
 
     # $ident is <identspec>
@@ -1199,7 +1199,7 @@ sub selecthost ($;$) {
         $r{$ident}= $name;
     } else {
         $name= $r{$ident};
-	if (!defined $name) {
+	if (!defined $name and !$prospective) {
 	    return undef if $none_ok;
 	    die "no specified $ident";
 	}
@@ -1220,6 +1220,8 @@ sub selecthost ($;$) {
         $ho->{OS} = target_var($ho, "os") // "debian";
     }
 
+    return $ho if $prospective;
+
     #----- handle hosts which are themselves guests (nested) -----
 
     if ($name =~ s/^(.*)://) {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 27/82] host allocation: *_shared_mark_ready: allow alternative $oldtypes
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (25 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 26/82] host allocation: selecthost: allow sort-of-selection of prospective hosts Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 28/82] host allocation: Support new reuse-* magic hostflag Ian Jackson
                   ` (55 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

$oldtype may now be a hashref, where keys mapping to truthy values are
permitted for the sharetype precondition.

No functional change for existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index fd975590..f2d43464 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -1056,6 +1056,7 @@ sub executive_resource_shared_mark_ready ($$$;$$) {
 
     my $oldshr;
     $oldstate //= 'prep';
+    $oldstate = { $oldstate => 1 } unless ref $oldstate;
     $newstate //= 'ready';
 
     my $what= "resource $restype $resname";
@@ -1070,8 +1071,9 @@ sub executive_resource_shared_mark_ready ($$$;$$) {
         if (defined $oldshr) {
             die "$what shared $oldshr->{Type} not $sharetype"
                 unless !defined $sharetype or $oldshr->{Type} eq $sharetype;
-            die "$what shared state $oldshr->{State} not $oldstate"
-                unless $oldshr->{State} eq $oldstate;
+            die "$what shared state $oldshr->{State} not".
+		" one of ".(join ' ', sort keys %$oldstate)
+                unless $oldstate->{ $oldshr->{State} };
             my $nrows= $dbh_tests->do(<<END,{}, $newstate, $restype,$resname);
                 UPDATE resource_sharing
                    SET state=?
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 28/82] host allocation: Support new reuse-* magic hostflag
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (26 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 27/82] host allocation: *_shared_mark_ready: allow alternative $oldtypes Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 29/82] host allocation: *_shared_mark_ready: Only prod when $newstate is ready Ian Jackson
                   ` (54 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This is like share-* except it has different MaxTasks and MaxWear
parameters.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 README.planner              |  7 +++++++
 ts-hosts-allocate-Executive | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/README.planner b/README.planner
index f134d716..a9275f12 100644
--- a/README.planner
+++ b/README.planner
@@ -230,6 +230,13 @@ hostflag:
     identically.  The osstest test harness revision is automatically
     appended and therefore does not need to be included.
 
+  reuse-SHARING
+
+    The host may be reused, one job after another.  Like share- but
+    only permits one job at a time, and has a much higher limit for
+    the number of successive jobs.  ts-host-test-share should be used
+    to arrange for the host's state to be recorded appropriately.
+
   equiv-FORMALTOKEN
 
     For each equiv-FORMALTOKEN job flag set on one or more IDENTs, a
diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 2c18a739..6fcfd2e3 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -279,6 +279,16 @@ sub compute_hids () {
                     " $hid->{DefaultSharedMaxTasks}".
                     " $hid->{DefaultSharedMaxWear}\n";
                 next;
+            } elsif ($flag =~ m/^reuse-/) {
+                die if exists $hid->{Shared};
+                my $shr= $'; #'
+                $hid->{Shared}= $shr." ".get_harness_rev();
+                $hid->{SharedMaxTasks}= 1;
+		$hid->{SharedMaxWear}= 10;
+                print DEBUG "HID $ident FLAG $flag SHARE-REUSE $shr".
+                    " $hid->{SharedMaxTasks}".
+                    " $hid->{SharedMaxWear}\n";
+                next;
             } elsif ($flag =~ m/^equiv-/) {
                 my $formalclass= $'; #'
                 die if exists $hid->{Equiv};
@@ -484,6 +494,11 @@ END
         foreach my $kcomb (qw(Shared-Max-Wear Shared-Max-Tasks)) {
             my $kdb= $kcomb;  $kdb =~ y/-A-Z/ a-z/;
             my $khash= $kcomb;  $khash =~ y/-//d;
+	    if ($hid->{$khash}) {
+		$candrow->{$khash} = $hid->{$khash};
+                print DEBUG "$dbg $khash FROM-HID\n";
+		next;
+	    }
             $resprop_q->execute($candrow->{restype},$candrow->{resname},$kdb);
             my $proprow= $resprop_q->fetchrow_hashref();
             my $val= $proprow->{val};
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 29/82] host allocation: *_shared_mark_ready: Only prod when $newstate is ready
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (27 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 28/82] host allocation: Support new reuse-* magic hostflag Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 30/82] plan_search: Break out $share_compat_ok Ian Jackson
                   ` (53 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index f2d43464..4cd4aa50 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -1092,13 +1092,15 @@ END
 END
         }
     });
-    if (!eval {
-       my $qserv = tcpconnect_queuedaemon();
-       print $qserv "prod\n" or die $!;
-       $_ = <$qserv>;  defined && m/^OK prod\b/ or die "$_ ?";
-       1;
-    }) {
-       logm("post-mark-ready queue daemon prod failed: $@");
+    if ($newstate eq 'ready') {
+	if (!eval {
+	    my $qserv = tcpconnect_queuedaemon();
+	    print $qserv "prod\n" or die $!;
+	    $_ = <$qserv>;  defined && m/^OK prod\b/ or die "$_ ?";
+	    1;
+	}) {
+	    logm("post-mark-ready queue daemon prod failed: $@");
+	}
     }
     if ($oldshr) {
 	logm("$restype $resname shared $sharetype marked $newstate");
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 30/82] plan_search: Break out $share_compat_ok
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (28 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 29/82] host allocation: *_shared_mark_ready: Only prod when $newstate is ready Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 31/82] plan_search: Improve debugging of $share_compat_ok->() Ian Jackson
                   ` (52 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 4cd4aa50..e4bb0868 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -700,6 +700,20 @@ sub plan_search ($$$$) {
             # this period is entirely after the proposed slot;
             # so no need to check this or any later periods
 
+	    my $share_compat_ok = sub {
+		my ($eshare) = @_;
+		return 0 unless defined $req->{Shared};
+		return 0 unless $req->{Shared} eq $eshare->{Type};
+		if (defined $share_wear) {
+		    $share_wear++ if $startevt->{Type} eq 'Start';
+		} else {
+		    $share_wear= $eshare->{Wear}+1;
+		}
+		return 0 if $share_wear > $req->{SharedMaxWear};
+		return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
+		return 1;
+	    };
+
 	    next PERIOD if $endevt->{Time} <= $try_time;
             # this period is entirely before the proposed slot;
             # it doesn't overlap, but must check subsequent periods
@@ -711,15 +725,7 @@ sub plan_search ($$$$) {
 		my $eshare= $startevt->{Share};
 		if ($eshare) {
 		    $dbgprint->("PLAN LOOP   OVERLAP ESHARE");
-		    last CHECK unless defined $req->{Shared};
-		    last CHECK unless $req->{Shared} eq $eshare->{Type};
-		    if (defined $share_wear) {
-			$share_wear++ if $startevt->{Type} eq 'Start';
-		    } else {
-			$share_wear= $eshare->{Wear}+1;
-		    }
-		    last CHECK if $share_wear > $req->{SharedMaxWear};
-		    last CHECK if $eshare->{Shares} != $req->{SharedMaxTasks};
+		    last CHECK unless $share_compat_ok->($eshare);
 		}
 		# We have suitable availability for this period
 		$dbgprint->("PLAN LOOP   OVERLAP AVAIL OK");
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 31/82] plan_search: Improve debugging of $share_compat_ok->()
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (29 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 30/82] plan_search: Break out $share_compat_ok Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 32/82] plan_search: Use plan's Wear information rather than tracking it ourselves Ian Jackson
                   ` (51 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

No change other than to debugging output.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index e4bb0868..dfa3710a 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -702,6 +702,12 @@ sub plan_search ($$$$) {
 
 	    my $share_compat_ok = sub {
 		my ($eshare) = @_;
+		$dbgprint->("PLAN LOOP   SHARE-COMPAT-OK ".
+		    "type $eshare->{Type} vs. ".
+			($req->{Shared} // '<undef>')." ".
+		    "wear $eshare->{Wear} ".
+		    "shares $eshare->{Shares} vs. ".
+			($req->{SharedMaxTasks}//'<undef>'));
 		return 0 unless defined $req->{Shared};
 		return 0 unless $req->{Shared} eq $eshare->{Type};
 		if (defined $share_wear) {
@@ -711,6 +717,7 @@ sub plan_search ($$$$) {
 		}
 		return 0 if $share_wear > $req->{SharedMaxWear};
 		return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
+		$dbgprint->("PLAN LOOP   SHARE-COMPAT-OK Y");
 		return 1;
 	    };
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 32/82] plan_search: Use plan's Wear information rather than tracking it ourselves
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (30 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 31/82] plan_search: Improve debugging of $share_compat_ok->() Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 33/82] plan search: Move $share_compat_ok further up the file Ian Jackson
                   ` (50 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

There is no reason not to use this information from the plan.
Not computing it ourselves saves some confusing logic here.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index dfa3710a..e17b6503 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -675,7 +675,6 @@ sub plan_search ($$$$) {
     my $reqix= 0;
     my $try_time= 0;
     my $confirmedok= 0;
-    my $share_wear;
     my $share_reuse= 0;
 
     for (;;) {
@@ -689,8 +688,7 @@ sub plan_search ($$$$) {
       PERIOD:
 	foreach (my $ix=0; $ix<@$events; $ix++) {
 	    $dbgprint->("PLAN LOOP reqs[$reqix]=$req->{Ident}".
-		" evtix=$ix try=$try_time confirmed=$confirmedok".
-		(defined($share_wear) ? " wear=$share_wear" : ""));
+		" evtix=$ix try=$try_time confirmed=$confirmedok");
 
 	    # check the period from $events[$ix] to next event
 	    my $startevt= $events->[$ix];
@@ -710,12 +708,8 @@ sub plan_search ($$$$) {
 			($req->{SharedMaxTasks}//'<undef>'));
 		return 0 unless defined $req->{Shared};
 		return 0 unless $req->{Shared} eq $eshare->{Type};
-		if (defined $share_wear) {
-		    $share_wear++ if $startevt->{Type} eq 'Start';
-		} else {
-		    $share_wear= $eshare->{Wear}+1;
-		}
-		return 0 if $share_wear > $req->{SharedMaxWear};
+		my $wear= $eshare->{Wear}+1;
+		return 0 if $wear > $req->{SharedMaxWear};
 		return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
 		$dbgprint->("PLAN LOOP   SHARE-COMPAT-OK Y");
 		return 1;
@@ -742,13 +736,11 @@ sub plan_search ($$$$) {
 	    # nope
 	    $try_time= $endevt->{Time};
 	    $confirmedok= 0;
-	    undef $share_wear;
 	    $share_reuse= 0;
 	    $dbgprint->("PLAN LOOP   OVERLAP BAD $try_time");
 	}
 	$dbgprint->("PLAN NEXT reqs[$reqix]=$req->{Ident}".
-	    " try=$try_time confirmed=$confirmedok reuse=$share_reuse".
-	    (defined($share_wear) ? " wear=$share_wear" : ""));
+	    " try=$try_time confirmed=$confirmedok reuse=$share_reuse");
 
 	$confirmedok++;
 	$share_reuse++ if defined $share_wear;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 33/82] plan search: Move $share_compat_ok further up the file
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (31 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 32/82] plan_search: Use plan's Wear information rather than tracking it ourselves Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 34/82] plan_search: Track last sharing state to determine $share_reuse Ian Jackson
                   ` (49 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

We are going to want to use this outside the loop.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index e17b6503..4083ae6b 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -684,6 +684,23 @@ sub plan_search ($$$$) {
 
         $events ||= [ ];
 
+	my $share_compat_ok = sub {
+	    my ($eshare) = @_;
+	    $dbgprint->("PLAN LOOP   SHARE-COMPAT-OK ".
+		"type $eshare->{Type} vs. ".
+		    ($req->{Shared} // '<undef>')." ".
+		"wear $eshare->{Wear} ".
+		"shares $eshare->{Shares} vs. ".
+		    ($req->{SharedMaxTasks}//'<undef>'));
+	    return 0 unless defined $req->{Shared};
+	    return 0 unless $req->{Shared} eq $eshare->{Type};
+	    my $wear= $eshare->{Wear}+1;
+	    return 0 if $wear > $req->{SharedMaxWear};
+	    return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
+	    $dbgprint->("PLAN LOOP   SHARE-COMPAT-OK Y");
+	    return 1;
+	};
+
 	# can we do $req at $try_time ?  If not, when later can we ?
       PERIOD:
 	foreach (my $ix=0; $ix<@$events; $ix++) {
@@ -698,23 +715,6 @@ sub plan_search ($$$$) {
             # this period is entirely after the proposed slot;
             # so no need to check this or any later periods
 
-	    my $share_compat_ok = sub {
-		my ($eshare) = @_;
-		$dbgprint->("PLAN LOOP   SHARE-COMPAT-OK ".
-		    "type $eshare->{Type} vs. ".
-			($req->{Shared} // '<undef>')." ".
-		    "wear $eshare->{Wear} ".
-		    "shares $eshare->{Shares} vs. ".
-			($req->{SharedMaxTasks}//'<undef>'));
-		return 0 unless defined $req->{Shared};
-		return 0 unless $req->{Shared} eq $eshare->{Type};
-		my $wear= $eshare->{Wear}+1;
-		return 0 if $wear > $req->{SharedMaxWear};
-		return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
-		$dbgprint->("PLAN LOOP   SHARE-COMPAT-OK Y");
-		return 1;
-	    };
-
 	    next PERIOD if $endevt->{Time} <= $try_time;
             # this period is entirely before the proposed slot;
             # it doesn't overlap, but must check subsequent periods
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 34/82] plan_search: Track last sharing state to determine $share_reuse
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (32 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 33/82] plan search: Move $share_compat_ok further up the file Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 35/82] resource reporting: Print username when listing "rogue tasks" Ian Jackson
                   ` (48 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

What matters for the purpose of $share_reuse is not whether the host
is actually being _shared_ (ie, there are other concurrent allocations
and therefore a concurrent Event with Share information).  What we
really want to know is whether the *last* use of this host was a
suitable sharing setup - because we actually want to know if we will
be able to skip our setup.

So track that explicitly.  (The slightly odd structure, where there
are two loops in one, means that we reset $last_eshare when we go onto
the next $req ie the next host to check.)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 4083ae6b..5f59c44e 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -676,6 +676,7 @@ sub plan_search ($$$$) {
     my $try_time= 0;
     my $confirmedok= 0;
     my $share_reuse= 0;
+    my $last_eshare;
 
     for (;;) {
 	my $req= $requestlist->[$reqix];
@@ -715,6 +716,10 @@ sub plan_search ($$$$) {
             # this period is entirely after the proposed slot;
             # so no need to check this or any later periods
 
+	    $last_eshare = $startevt->{
+                $startevt->{Type} eq 'Unshare' ? 'PreviousShare' : 'Share'
+				      };
+
 	    next PERIOD if $endevt->{Time} <= $try_time;
             # this period is entirely before the proposed slot;
             # it doesn't overlap, but must check subsequent periods
@@ -743,9 +748,10 @@ sub plan_search ($$$$) {
 	    " try=$try_time confirmed=$confirmedok reuse=$share_reuse");
 
 	$confirmedok++;
-	$share_reuse++ if defined $share_wear;
+	$share_reuse++ if $last_eshare and $share_compat_ok->($last_eshare);
 	$reqix++;
 	$reqix %= @$requestlist;
+	undef $last_eshare;
 	last if $confirmedok==@$requestlist;
     }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 35/82] resource reporting: Print username when listing "rogue tasks"
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (33 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 34/82] plan_search: Track last sharing state to determine $share_reuse Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 36/82] resource reporting, nfc: Break out report_rogue_task_description Ian Jackson
                   ` (47 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ms-planner | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ms-planner b/ms-planner
index 78d27b2f..41f27fa0 100755
--- a/ms-planner
+++ b/ms-planner
@@ -325,6 +325,7 @@ END
 	    $info .= " $arow->{type} $arow->{refkey}";
 	    $info .= " ($arow->{comment})" if defined $arow->{comment};
 	    $info .= " $arow->{subtask}";
+	    $info .= " (user $arow->{username})";
 	}
 	$plan->{Allocations}{$reskey}= {
             Task => $arow->{owntaskid},
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 36/82] resource reporting, nfc: Break out report_rogue_task_description
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (34 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 35/82] resource reporting: Print username when listing "rogue tasks" Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 37/82] ts-hosts-allocate-Executive: Better message for hosts abandoned mid-test Ian Jackson
                   ` (46 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 14 ++++++++++++++
 ms-planner           |  6 +-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 5f59c44e..e3ab1dc3 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -51,6 +51,7 @@ BEGIN {
                       report_run_getinfo report_altcolour
                       report_altchangecolour opendb_tests
                       report_blessingscond report_find_push_age_info
+		      report_rogue_task_description
 		      log_stderr_timestamped
                       tcpconnect_queuedaemon plan_search
                       manual_allocation_base_jobinfo
@@ -418,6 +419,19 @@ sub report_blessingscond ($) {
     return $blessingscond;
 }
 
+sub report_rogue_task_description ($) {
+    my ($arow) = @_;
+    # should have the fields from tasks, except taskid which
+    #  caller must print if they want it.
+    # may also have fields from resources (eg subtask)
+    my $info= "rogue task ";
+    $info .= " $arow->{type} $arow->{refkey}";
+    $info .= " ($arow->{comment})" if defined $arow->{comment};
+    $info .= " $arow->{subtask}";
+    $info .= " (user $arow->{username})";
+    return $info;
+}
+
 sub report__find_test ($$$$$$$) {
     my ($blessings, $branches, $tree,
 	$revision, $selection, $extracond, $sortlimit) = @_;
diff --git a/ms-planner b/ms-planner
index 41f27fa0..4b970730 100755
--- a/ms-planner
+++ b/ms-planner
@@ -321,11 +321,7 @@ END
 	    $info= "(preparing)";
 	} else {
 	    print DEBUG "rogue $reso $shareix: $arow->{owntaskid}\n";
-	    $info= "rogue task";
-	    $info .= " $arow->{type} $arow->{refkey}";
-	    $info .= " ($arow->{comment})" if defined $arow->{comment};
-	    $info .= " $arow->{subtask}";
-	    $info .= " (user $arow->{username})";
+	    $info= report_rogue_task_description($arow);
 	}
 	$plan->{Allocations}{$reskey}= {
             Task => $arow->{owntaskid},
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 37/82] ts-hosts-allocate-Executive: Better message for hosts abandoned mid-test
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (35 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 36/82] resource reporting, nfc: Break out report_rogue_task_description Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 38/82] ts-host-reuse: New script, to do reuse state changes Ian Jackson
                   ` (45 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 6fcfd2e3..58e9f891 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -1062,7 +1062,7 @@ sub actual_allocation ($) {
 	    }
 	    # someone was preparing it but they aren't any more
 	    push @allocwarnings,
-		"previous preparation apparently abandoned";
+		"previous use apparently abandoned ($shared->{state})";
 	    $allocatable= 1;
         }
     }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 38/82] ts-host-reuse: New script, to do reuse state changes
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (36 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 37/82] ts-hosts-allocate-Executive: Better message for hosts abandoned mid-test Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 39/82] ts-host-reuse: tolerate unremoveable lv Ian Jackson
                   ` (44 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This will be made part of the test job recipes.

We calculate the sharing scope (sharetype) by reference to a lot of
runvars, etc.

This version of the script is rather far from the finished working
one, but it seems better to preserve the actual history for how it got
the way it is.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-host-reuse | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 163 insertions(+)
 create mode 100755 ts-host-reuse

diff --git a/ts-host-reuse b/ts-host-reuse
new file mode 100755
index 00000000..e14a9149
--- /dev/null
+++ b/ts-host-reuse
@@ -0,0 +1,163 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# usage:
+#   ./ts-host-reuse prealloc|start-test|post-test IDENT [ARGS...]
+#
+# Computes the sharing scope of the host for IDENT, and then
+#
+#   prealloc      Sets the share-* runtime hostflag appropriately
+#
+#   start-test    Expects the host to have previously been `prep'
+#                 (being prepared) or `ready'.
+#                 Marks it as `mid-test'.
+#
+#                 All the scripts before `ready' or `start-test', (at
+#                 least, ones which affect the host) should have been
+#                 marked with @, so that they are skipped when the
+#                 host is shared or reused.
+#
+#   post-test     Expects the host to have previously been `mid-test'
+#                 Does a small amount of cleanup, deleting some things
+#                 which take a lot of space.
+#                 Then marks the host as `ready' for reuse.
+#                 Must not be done if test arrangements had unexpected
+#                 failures which might leave host in an odd state.
+
+use strict qw(vars);
+use DBI;
+BEGIN { unshift @INC, qw(.); }
+use Osstest;
+use POSIX;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+die unless @ARGV==2;
+
+our ($action, $whhost) = @ARGV;
+
+our $ho;
+
+#---------- compute $sharetype ----------
+
+our $sharetype;
+
+sub sharetype_add ($$) {
+    my ($k, $v) = @_;
+    return unless defined $v;
+    $sharetype .= "/$k=$v";
+}
+
+sub compute_test_sharetype () {
+    $sharetype =
+	"test-$flight/$r{arch}/$r{xenbuildjob}/$r{kernbuildjob}/$r{buildjob}";
+
+    sharetype_add('suite', $ho->{Suite});
+    sharetype_add('di', $ho->{DiVersion});
+
+    foreach my $runvar (qw(freebsd_distpath freebsdbuildjob
+			   bios xenable_xsm toolstack kernkind)) {
+	my $val = $r{$runvar};
+	die "$runvar $val ?" if defined $val && $val =~ m{[,/\%\\]};
+	sharetype_add($runvar, $val);
+    }
+
+    return $sharetype;
+}
+
+#---------- functions ----------
+
+sub post_test_cleanup () {
+    my $script = <<'ENDQ';
+        set -e
+        cd /root
+        du -skx * | while read size thing; do
+            printf '%10d %s' "$size" "$thing"
+            if [ $size -gt 11000 ]; then
+                printf ' removing'
+                rm -rf -- "$thing"
+            fi
+            printf '\n'
+        done
+ENDQ
+    my $r_vals = sub {
+	my ($re) = @_;
+	map { $r{$_} }
+            sort
+	    grep /$re/,
+	    keys %r;
+    };
+    my @vgs = $r_vals->(qr{_vg$});
+    my @lvs = $r_vals->(qr{_lv$});
+    $script .= <<ENDI.<<'ENDQ';
+        for vg in @vgs; do
+            for lv in @lvs; do
+ENDI
+                dev=/dev/$vg/$lv
+                printf 'LV %s...\n' "$dev"
+                if ! test -e $dev; then continue; fi
+                dd if=/dev/urandom bs=1024 count=4096 of=$dev ||:
+                lvremove -f $dev
+            done
+        done
+ENDQ
+    target_cmd_root($ho, $script, 300);
+}
+
+#---------- functionality shared between actions ----------
+
+sub noop_if_playing () {
+    my $wantreuse = $ENV{'OSSTEST_REUSE_TEST_HOSTS'};
+    my $intended = intended_blessing();
+    if (!defined $wantreuse) {
+	$wantreuse = $intended !~ /play/;
+    }
+    if (!$wantreuse) {
+	logm("not reusing test hosts (in $intended flight)");
+	exit 0;
+    }
+}
+
+#---------- actions ----------
+
+sub act_prealloc () {
+    noop_if_playing();
+    compute_test_sharetype();
+    $ho = selecthost($whhost, undef, 1);
+    set_runtime_hostflag($ho->{Ident}, "reuse-$sharetype");
+}
+
+sub act_start_test () {
+    compute_test_sharetype();
+    $ho = selecthost($whhost);
+    return unless $ho->{Shared};
+    my %oldstate = map { $_ => 1 } qw(prep ready);
+    host_shared_mark_ready($ho, $sharetype, \%oldstate, 'mid-test');
+}
+
+sub act_post_test () {
+    compute_test_sharetype();
+    $ho = selecthost($whhost);
+    return unless $ho->{Shared};
+    die unless $ho->{Shared}{State} eq 'mid-test';
+    post_test_cleanup();
+    host_shared_mark_ready($ho, $sharetype, 'mid-test', 'ready');
+}
+
+$action =~ y/-/_/;
+&{"act_$action"}();
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 39/82] ts-host-reuse: tolerate unremoveable lv
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (37 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 38/82] ts-host-reuse: New script, to do reuse state changes Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 40/82] ts-host-reuse: Do not depend on bios Ian Jackson
                   ` (43 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

It might be a symlink in the pair tests.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-host-reuse | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ts-host-reuse b/ts-host-reuse
index e14a9149..74ac94aa 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -112,7 +112,7 @@ ENDI
                 printf 'LV %s...\n' "$dev"
                 if ! test -e $dev; then continue; fi
                 dd if=/dev/urandom bs=1024 count=4096 of=$dev ||:
-                lvremove -f $dev
+                lvremove -f $dev ||:
             done
         done
 ENDQ
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 40/82] ts-host-reuse: Do not depend on bios
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (38 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 39/82] ts-host-reuse: tolerate unremoveable lv Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 41/82] ts-host-reuse: Add some missing runvars to the host sharing control Ian Jackson
                   ` (42 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Weirdly, this is only used for guests.  Really, it should be a
target_var, not a raw runvar applying to all guests, since it can be
guest-specific.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-host-reuse | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ts-host-reuse b/ts-host-reuse
index 74ac94aa..67de480f 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -71,7 +71,7 @@ sub compute_test_sharetype () {
     sharetype_add('di', $ho->{DiVersion});
 
     foreach my $runvar (qw(freebsd_distpath freebsdbuildjob
-			   bios xenable_xsm toolstack kernkind)) {
+			   xenable_xsm toolstack kernkind)) {
 	my $val = $r{$runvar};
 	die "$runvar $val ?" if defined $val && $val =~ m{[,/\%\\]};
 	sharetype_add($runvar, $val);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 41/82] ts-host-reuse: Add some missing runvars to the host sharing control
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (39 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 40/82] ts-host-reuse: Do not depend on bios Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 42/82] host allocation: selecthost(): Support @IDENT for reuse Ian Jackson
                   ` (41 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Add some missing runvars to the host sharing control.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-host-reuse | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ts-host-reuse b/ts-host-reuse
index 67de480f..5bdb07d1 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -71,7 +71,8 @@ sub compute_test_sharetype () {
     sharetype_add('di', $ho->{DiVersion});
 
     foreach my $runvar (qw(freebsd_distpath freebsdbuildjob
-			   xenable_xsm toolstack kernkind)) {
+			   xenable_xsm toolstack kernkind
+			   xen_boot_append toolstack)) {
 	my $val = $r{$runvar};
 	die "$runvar $val ?" if defined $val && $val =~ m{[,/\%\\]};
 	sharetype_add($runvar, $val);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 42/82] host allocation: selecthost(): Support @IDENT for reuse
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (40 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 41/82] ts-host-reuse: Add some missing runvars to the host sharing control Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 43/82] ts-hosts-allocate-Executive print sharing info in debug output Ian Jackson
                   ` (40 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This is the first part of a central way to control host reuse, rather
than having to write code in each ts-* script to check Shared etc.

No functional change with existing callers.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 3d5f0be3..be6b7119 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -1175,7 +1175,7 @@ sub selecthost ($;$$) {
     my ($ident, $none_ok, $prospective) = @_;
     # must be run outside transaction
 
-    # $ident is <identspec>
+    # $ident is [@]<identspec>
     #
     # <identspec> can be <ident>, typically "host" or "xxx_host"
     # which means look up the runvar $r{$ident} which
@@ -1191,8 +1191,16 @@ sub selecthost ($;$$) {
     # <hostspec> can be <parent_identspec>:<domname> meaning use the
     # Xen domain name <domname> on the host specified by
     # <parent_identspec>, which is an <identspec> as above.
+    #
+    # The leading @, if present, specifies that this script should be
+    # skipped if the host is being reused or shared.  Specifically:
+    # if the host is shared and in sharing state `ready'.  And, it is
+    # wrong to specify @ when multiple hosts are being selected.
 
     my $name;
+
+    my $isprep = $ident =~ s/^\@//;
+
     if ($ident =~ m/=/) {
         $ident= $`;
         $name= $'; #'
@@ -1352,13 +1360,27 @@ sub selecthost ($;$$) {
 
     $mjobdb->host_check_allocated($ho);
 
-    logm("host $ho->{Ident}: selected $ho->{Name} ".
+    logm("host $ho->{Ident}".
+	 ($isprep ? " (prep)" : "").
+	 ": selected $ho->{Name} ".
 	 (defined $ho->{Ether} ? $ho->{Ether} : '<unknown-ether>').
 	 " $ho->{Ip}".
          (!$ho->{Shared} ? '' :
           sprintf(" - shared %s %s %d", $ho->{Shared}{Type},
                   $ho->{Shared}{State}, $ho->{Shared}{Others}+1)));
 
+    if ($isprep && $ho->{Shared}) {
+	my $st = $ho->{Shared}{State};
+	if ($st eq 'ready') {
+	    logm("host is ready, skipping step");
+	    exit 0;
+	} elsif ($st eq 'prep') {
+	    # ok, we need to do it
+	} else {
+	    die "host sharestate is $st but isprep (@ in ident)";
+	}
+    }
+
     return $ho;
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 43/82] ts-hosts-allocate-Executive print sharing info in debug output
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (41 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 42/82] host allocation: selecthost(): Support @IDENT for reuse Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 44/82] sg-run-job: New @ iffail tag for prep tasks Ian Jackson
                   ` (39 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index 58e9f891..fc107c08 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -691,7 +691,9 @@ sub hid_recurse ($$) {
     print DEBUG "$dbg FINAL start=$start_time va=$variation_age".
 	" variation_bonus=$variation_bonus".
         " previously_failed=$previously_failed".
-	" previously_failed_equiv=$previously_failed_equiv cost=$cost\n";
+	" previously_failed_equiv=$previously_failed_equiv".
+	" eff.share_bonus=$share_reuse*$share_reuse_bonus".
+	" cost=$cost\n";
 
     if (!defined $best || $cost < $best->{Cost}) {
         print DEBUG "$dbg FINAL BEST: ".
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 44/82] sg-run-job: New @ iffail tag for prep tasks
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (42 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 43/82] ts-hosts-allocate-Executive print sharing info in debug output Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 45/82] sg-run-job: Detect improper use of @ iffail with run-ts Ian Jackson
                   ` (38 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Currently no users sites, so no functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 sg-run-job | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 3f44cae7..a074cd42 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -223,12 +223,15 @@ proc recipe-flag {flagname {def 0}} {
 #
 #  IFFAIL can be
 #
-#           [-][!].
-#           [-][!]STATUS
+#           [@][-][!].
+#           [@][-][!]STATUS
 #
 #       where STATUS is the job/step status to be used if the step
 #       status is not as expected, and the special meanings are:
 #
+#           @      Only for per-host-ts: prefix each ident with @
+#                  to run this script only if the host is `prep'
+#                  and not if it is `ready'.
 #           -      for run-ts; suprresses exception on failure.
 #                  for per-host-ts; suppresses consequences of failure.
 #           !      Run this even if the job is being truncated.
@@ -452,8 +455,11 @@ proc reap-ts {reap {wantstatus pass}} {
 
 proc per-host-ts {iffail ident script args} {
     global ok truncate need_xen_hosts flight jobinfo
+
+    set isprep [lindex {{} @} [regsub {^\@} $iffail {} iffail]]
  
-    if {![iffail-check $iffail {$ok && !$truncate} iffail_status]} return
+    if {![iffail-check $iffail {$ok && !$truncate} iffail_status]} \
+	return
 
     set awaitl {}
     foreach host $need_xen_hosts {
@@ -461,7 +467,7 @@ proc per-host-ts {iffail ident script args} {
 	if {[string compare $host host]} {
 	    lappend hostargs +! $host
 	}
-	lappend hostargs + $host
+	lappend hostargs + $isprep$host
         lappend awaitl [eval spawn-ts $iffail $ident $script $hostargs $args]
     }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 45/82] sg-run-job: Detect improper use of @ iffail with run-ts
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (43 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 44/82] sg-run-job: New @ iffail tag for prep tasks Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 46/82] shared/reuse: Use @ for ts-xen-build-prep Ian Jackson
                   ` (37 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Only per-host-ts understands this.  This is a bit of a bear trap, so
arrange to bail rather than putting strange step status values with
`@' at the front in the database...

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sg-run-job b/sg-run-job
index a074cd42..067b28db 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -317,6 +317,9 @@ proc iffail-check {iffail okexpr iffail_status_var} {
     if {![regsub {^!} $iffail {} iffail_status]} {
 	if {![uplevel 1 [list expr $okexpr]]} { return 0 }
     }
+    if {[regexp {^@} $iffail]} {
+	error "internal error - @ only valid for iffail with per-host-ts"
+    }
     return 1
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 46/82] shared/reuse: Use @ for ts-xen-build-prep
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (44 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 45/82] sg-run-job: Detect improper use of @ iffail with run-ts Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 47/82] shared/reuse: Use @ for ts-host-install Ian Jackson
                   ` (36 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Pass @ from sg-run-job.  This is the only call site for
ts-xen-build-prep, so it can lose the open-coded test for SharedReady.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job        | 2 +-
 ts-xen-build-prep | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 067b28db..d46a3a62 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -753,7 +753,7 @@ proc allocate-build-host {ostype} {
 proc prepare-build-host-linux {} {
     global jobinfo
     run-ts broken host-install(*) ts-host-install-twice + --build
-    run-ts . host-build-prep ts-xen-build-prep
+    run-ts . host-build-prep ts-xen-build-prep + @host
 }
 
 proc prepare-build-host-freebsd {} {
diff --git a/ts-xen-build-prep b/ts-xen-build-prep
index dabb9921..092bbffe 100755
--- a/ts-xen-build-prep
+++ b/ts-xen-build-prep
@@ -28,7 +28,6 @@ tsreadconfig();
 our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
-exit 0 if $ho->{SharedReady};
 
 our ($vg,$lv);
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 47/82] shared/reuse: Use @ for ts-host-install
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (45 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 46/82] shared/reuse: Use @ for ts-xen-build-prep Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 48/82] shared/reuse: Use @ for freebsd host prep Ian Jackson
                   ` (35 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Pass @ from sg-run-job.  These are all the call sites for
ts-host-install-*, so we can lose the open-coded test for SharedReady.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 sg-run-job      | 6 +++---
 ts-host-install | 1 -
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index d46a3a62..c454d4ea 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -85,7 +85,7 @@ proc run-job {job} {
         }
     }
 
-    per-host-ts broken  host-install/@(*) ts-host-install-twice
+    per-host-ts @broken host-install/@(*) ts-host-install-twice
 
     per-host-prep
 
@@ -675,7 +675,7 @@ proc examine-host-prep {} {
     run-ts broken  =            ts-hosts-allocate     + host
 }
 proc examine-host-install-debian {} {
-    run-ts broken  host-install ts-host-install-twice + host
+    run-ts broken host-install  ts-host-install-twice + @host
 }
 proc examine-host-install-xen {} {
     examine-host-install-debian
@@ -752,7 +752,7 @@ proc allocate-build-host {ostype} {
 }
 proc prepare-build-host-linux {} {
     global jobinfo
-    run-ts broken host-install(*) ts-host-install-twice + --build
+    run-ts broken host-install(*) ts-host-install-twice + --build @host
     run-ts . host-build-prep ts-xen-build-prep + @host
 }
 
diff --git a/ts-host-install b/ts-host-install
index 924c1e06..b0fd2028 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -53,7 +53,6 @@ our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
 exit 0 if $ho->{Flags}{'no-reinstall'};
-exit 0 if $ho->{SharedReady};
 
 our %timeout= qw(ReadPreseed  350
                  Sshd        2400);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 48/82] shared/reuse: Use @ for freebsd host prep
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (46 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 47/82] shared/reuse: Use @ for ts-host-install Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 49/82] host reuse: sg-run-job: per-host prep: Use @ for per-host-ts Ian Jackson
                   ` (34 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

These are all the relevant call sites for ts-freebsd-host-install and
ts-freebsd-build-prep.  (There's a ts-freebsd-host-install in
ts-memdisk-try-append but that's for host examination and does not
uee or want sharing or reuse.)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job              | 12 +++++++++---
 ts-build-prep-freebsd   |  1 -
 ts-freebsd-host-install |  1 -
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index c454d4ea..0b2e20e7 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -758,9 +758,15 @@ proc prepare-build-host-linux {} {
 
 proc prepare-build-host-freebsd {} {
     global jobinfo
-    if {[recipe-flag testinstall]} { set broken fail } { set broken broken }
-    run-ts $broken host-install(*) ts-freebsd-host-install
-    run-ts . host-build-prep ts-build-prep-freebsd
+    if {[recipe-flag testinstall]} {
+	set broken fail
+	set isprep {}
+    } {
+	set broken broken
+	set isprep @
+    }
+    run-ts $broken host-install(*) ts-freebsd-host-install + ${isprep}host
+    run-ts . host-build-prep ts-build-prep-freebsd + ${isprep}host
 }
 
 proc need-hosts/coverity {} { return BUILD_LINUX }
diff --git a/ts-build-prep-freebsd b/ts-build-prep-freebsd
index ef880503..9606c0f7 100755
--- a/ts-build-prep-freebsd
+++ b/ts-build-prep-freebsd
@@ -28,7 +28,6 @@ tsreadconfig();
 our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
-exit 0 if $ho->{SharedReady};
 
 sub install_deps () {
     my @packages = qw(git glib pkgconf yajl gmake pixman markdown gettext
diff --git a/ts-freebsd-host-install b/ts-freebsd-host-install
index 3c3e9c34..9feb98cd 100755
--- a/ts-freebsd-host-install
+++ b/ts-freebsd-host-install
@@ -65,7 +65,6 @@ our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
 exit 0 if $ho->{Flags}{'no-reinstall'};
-exit 0 if $ho->{SharedReady};
 
 our $timeout = 1000;
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 49/82] host reuse: sg-run-job: per-host prep: Use @ for per-host-ts
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (47 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 48/82] shared/reuse: Use @ for freebsd host prep Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 50/82] shared/reuse: Rely on @ for ts-host-ping-check Ian Jackson
                   ` (33 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

These are the steps that will be skipped when we reuse a test host.

No functional change yet since we don't allocate the host shared yet.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 0b2e20e7..af43008d 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -25,9 +25,9 @@ readconfig
 source-method JobDB
 
 proc per-host-prep {} {
-    per-host-ts .       host-ping-check-native/@ ts-host-ping-check
-    per-host-ts .       xen-install/@     ts-xen-install
-    per-host-ts .       xen-boot/@        ts-host-reboot
+    per-host-ts @.      host-ping-check-native/@ ts-host-ping-check
+    per-host-ts @.      xen-install/@     ts-xen-install
+    per-host-ts @.      xen-boot/@        ts-host-reboot
 
     per-host-ts .       host-ping-check-xen/@ ts-host-ping-check
     per-host-ts .       =(*)            { ts-leak-check basis }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 50/82] shared/reuse: Rely on @ for ts-host-ping-check
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (48 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 49/82] host reuse: sg-run-job: per-host prep: Use @ for per-host-ts Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 51/82] host reuse: Reuse test hosts within a flight Ian Jackson
                   ` (32 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Remove the check for SharedReady.

The existence of this check is perplexing.  It was introduced in
  ts-host-ping-check: Do not run if host is being reused
in 8f1dc3f7c401 (from 2015).

At that time we only share build hosts, and build hosts never ran this
script.  So I don't understand what that was hoping to achieve.  Maybe
it made some difference in a now-lost pre-rebase situation.

Anyway, in our current tree I think we want to rerun the
ts-host-ping-check when we reuse a test host.  My change to add @ to
parts of per-host-prep in sg-run-job deliberately omitted the step
with testid host-ping-check-xen/@.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-host-ping-check | 2 --
 1 file changed, 2 deletions(-)

diff --git a/ts-host-ping-check b/ts-host-ping-check
index a670680c..512aaec3 100755
--- a/ts-host-ping-check
+++ b/ts-host-ping-check
@@ -27,8 +27,6 @@ our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
 
-exit 0 if $ho->{SharedReady};
-
 $_ = `ping -D -i 0.2 -c 100 $ho->{Ip} | tee -a /dev/stderr`;
 
 m/\b([0-9.]+)% packet loss\b/ or die "$_ ?";
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 51/82] host reuse: Reuse test hosts within a flight
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (49 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 50/82] shared/reuse: Rely on @ for ts-host-ping-check Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 52/82] host allocation: Group jobs by their reuse parameters Ian Jackson
                   ` (31 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Mark the host shareable, and unshareable, as appropriate.

There is still a lot more cleanup and improvement to do.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 sg-run-job | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sg-run-job b/sg-run-job
index af43008d..1e2fcfee 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -29,6 +29,8 @@ proc per-host-prep {} {
     per-host-ts @.      xen-install/@     ts-xen-install
     per-host-ts @.      xen-boot/@        ts-host-reboot
 
+    per-host-ts broken  =               { ts-host-reuse start-test }
+
     per-host-ts .       host-ping-check-xen/@ ts-host-ping-check
     per-host-ts .       =(*)            { ts-leak-check basis }
 }
@@ -64,6 +66,8 @@ proc run-job {job} {
     if {!$ok} return
 
     if {[llength $need_xen_hosts]} {
+        per-host-ts broken  =           { ts-host-reuse prealloc }
+	if {!$ok} return
         eval run-ts broken  =             ts-hosts-allocate + $need_xen_hosts
     }
 
@@ -120,6 +124,7 @@ proc run-job {job} {
        set ok 0
     }
 
+    if {$ok} { per-host-ts .  =            { ts-host-reuse post-test }    }
     if {$ok} { setstatus pass                                             }
 
     if {[llength $need_build_host] && $ok} { jobdb::preserve-task 90 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 52/82] host allocation: Group jobs by their reuse parameters
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (50 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 51/82] host reuse: Reuse test hosts within a flight Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 53/82] host reuse: Jiggle the infra-priority a bit, within a flight Ian Jackson
                   ` (30 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This promotes reuse by arranging that jobs that can reuse a host get
to run consecutively.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm  | 47 +++++++++++++++++++++++++++++++++++++
 Osstest/JobDB/Standalone.pm |  2 ++
 ts-host-reuse               |  1 +
 ts-hosts-allocate-Executive |  4 ++++
 4 files changed, 54 insertions(+)

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index 30629572..8c235d45 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -389,6 +389,53 @@ END
     }
 }
 
+sub jobdb_set_hosts_infraprioritygroup ($$$$;$) { # method
+    my ($mo, $flight, $job, $group_key, $rref) = @_;
+    # Sets the runvar hosts_infraprioritygroup in $flight,$job
+    # The runvar values are NUM:GROUPKEY
+    # such that each GROUPKEY always has the same NUM, within the flight
+    # $rref is \%r (for use within a ts-*) or undef
+
+    my $vn = 'hosts_infraprioritygroup';
+
+    my $queryq = $dbh_tests->prepare(<<END);
+        SELECT job, val,
+               (job = ?) AS thisjob
+          FROM runvars
+         WHERE flight=?
+           AND name=?
+      ORDER BY thisjob DESC
+END
+    my $insertq = $dbh_tests->prepare(<<END);
+        INSERT INTO runvars (flight,job, name,val, synth)
+                     VALUES (?,     ?,   ?,   ?,   't')
+END
+
+    my $resulting;
+    db_retry($dbh_tests,[],sub {
+	my $use = 1;
+	$resulting = undef;
+        $queryq->execute($job, $flight, $vn);
+	while (my ($tjob, $tval, $thisjob) = $queryq->fetchrow_array()) {
+	    if ($thisjob) {
+		logm("$vn: job is already in group $tval");
+		return;
+	    }
+	    $tval =~ m/^(\d+)\:/ or die "$flight $job $tval ?";
+	    if ($' eq $group_key) {
+		$use = $1;
+		last;
+	    } elsif ($1 >= $use) {
+		$use = $1 + 1;
+	    }
+	}
+	$resulting = "$use:$group_key";
+	logm("$vn: inserting job into group $resulting");
+	$insertq->execute($flight,$job,$vn, $resulting);
+    });
+    $rref->{$vn} = $resulting if $rref && defined $resulting;
+}
+
 sub jobdb_flight_started_for_log_capture ($$) { #method
     my ($mo, $flight) = @_;
     my $started= $dbh_tests->selectrow_array(<<END);
diff --git a/Osstest/JobDB/Standalone.pm b/Osstest/JobDB/Standalone.pm
index 4f320ccf..1db4dc78 100644
--- a/Osstest/JobDB/Standalone.pm
+++ b/Osstest/JobDB/Standalone.pm
@@ -118,6 +118,8 @@ sub jobdb_resource_shared_mark_ready { } #method
 
 sub jobdb_check_other_job { } #method
 
+sub jobdb_set_hosts_infraprioritygroup { } # method
+
 sub jobdb_flight_started_for_log_capture ($$) { #method
     my ($mo, $flight) = @_;
     return time - 60*60; # just the most recent serial log then,
diff --git a/ts-host-reuse b/ts-host-reuse
index 5bdb07d1..29abe987 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -141,6 +141,7 @@ sub act_prealloc () {
     compute_test_sharetype();
     $ho = selecthost($whhost, undef, 1);
     set_runtime_hostflag($ho->{Ident}, "reuse-$sharetype");
+    $mjobdb->jobdb_set_hosts_infraprioritygroup($flight, $job, $sharetype, \%r);
 }
 
 sub act_start_test () {
diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index fc107c08..a50f8bf3 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -733,9 +733,13 @@ sub alloc_hosts () {
         ? -10000
         : -10 * @hids;
 
+    my $infrapriority =
+	($r{hosts_infraprioritygroup} // '') =~ m/^(\d+):/ ? $1 : undef;
+
     my $ok = alloc_resources(WaitStart =>
                     ($ENV{OSSTEST_RESOURCE_WAITSTART} || $fi->{started}),
                     WaitStartAdjust => $waitstartadjust,
+                    InfraPriority => $infrapriority,
 		    DebugFh => \*DEBUG,
                     \&attempt_allocation);
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 53/82] host reuse: Jiggle the infra-priority a bit, within a flight
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (51 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 52/82] host allocation: Group jobs by their reuse parameters Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 54/82] host reuse: Use literal for the hosts_infraprioritygroup runvar Ian Jackson
                   ` (29 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index a50f8bf3..c1002fc9 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -733,8 +733,13 @@ sub alloc_hosts () {
         ? -10000
         : -10 * @hids;
 
-    my $infrapriority =
-	($r{hosts_infraprioritygroup} // '') =~ m/^(\d+):/ ? $1 : undef;
+    my $infrapriority;
+    if (($r{hosts_infraprioritygroup} // '') =~ m/^(\d+):/) {
+	$infrapriority = ($1 * 100) + ($$ % 100);
+	# $$ provides a pseudorandom element, which arranges that jobs
+	# in a group roughly take turns to take the scheduling lead,
+	# which will hopefully help them converge.
+    }
 
     my $ok = alloc_resources(WaitStart =>
                     ($ENV{OSSTEST_RESOURCE_WAITSTART} || $fi->{started}),
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 54/82] host reuse: Use literal for the hosts_infraprioritygroup runvar
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (52 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 53/82] host reuse: Jiggle the infra-priority a bit, within a flight Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 55/82] host reuse: Bump host share reuse bonus Ian Jackson
                   ` (28 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

At some point this might make the database smarter about indexing.
It's certainly clearer.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index 8c235d45..8fde2934 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -403,19 +403,19 @@ sub jobdb_set_hosts_infraprioritygroup ($$$$;$) { # method
                (job = ?) AS thisjob
           FROM runvars
          WHERE flight=?
-           AND name=?
+           AND name='$vn'
       ORDER BY thisjob DESC
 END
     my $insertq = $dbh_tests->prepare(<<END);
-        INSERT INTO runvars (flight,job, name,val, synth)
-                     VALUES (?,     ?,   ?,   ?,   't')
+        INSERT INTO runvars (flight,job, name,  val, synth)
+                     VALUES (?,     ?,   '$vn', ?,   't')
 END
 
     my $resulting;
     db_retry($dbh_tests,[],sub {
 	my $use = 1;
 	$resulting = undef;
-        $queryq->execute($job, $flight, $vn);
+        $queryq->execute($job, $flight);
 	while (my ($tjob, $tval, $thisjob) = $queryq->fetchrow_array()) {
 	    if ($thisjob) {
 		logm("$vn: job is already in group $tval");
@@ -431,7 +431,7 @@ END
 	}
 	$resulting = "$use:$group_key";
 	logm("$vn: inserting job into group $resulting");
-	$insertq->execute($flight,$job,$vn, $resulting);
+	$insertq->execute($flight,$job, $resulting);
     });
     $rref->{$vn} = $resulting if $rref && defined $resulting;
 }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 55/82] host reuse: Bump host share reuse bonus
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (53 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 54/82] host reuse: Use literal for the hosts_infraprioritygroup runvar Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 56/82] subst_netboot_template: Do not use all of %r Ian Jackson
                   ` (27 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

In test jobs this is now contending with the variation bonus.

If we fail to vary properly this time, we get another go in the next
flight, so this is not so critical.

This increases the amount of test host reuse.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 ts-hosts-allocate-Executive | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ts-hosts-allocate-Executive b/ts-hosts-allocate-Executive
index c1002fc9..b216186a 100755
--- a/ts-hosts-allocate-Executive
+++ b/ts-hosts-allocate-Executive
@@ -673,7 +673,7 @@ sub hid_recurse ($$) {
     $prevfail_bonus //= 7.0*86400;
     my $prevfail_equiv_bonus = $prevfail_bonus * (6.5 / 7.0);
 
-    my $share_reuse_bonus = $r{hostalloc_bonus_sharereuse} // 10000;
+    my $share_reuse_bonus = $r{hostalloc_bonus_sharereuse} // 20000;
 
     my $cost= $start_time
 	+ $duration_for_cost
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 56/82] subst_netboot_template: Do not use all of %r
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (54 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 55/82] host reuse: Bump host share reuse bonus Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 17:59 ` [OSSTEST PATCH 57/82] TestSupport: Provide runvar_is_synth Ian Jackson
                   ` (26 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Instead of copying all of %r into %v, have the template substitutor
fall back to %r from %v.

This is going to be important when we have host-reuse-related access
control to %r.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index be6b7119..634d6d2e 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -2876,6 +2876,7 @@ sub subst_netboot_template ($$$) {
 	$pat =~ s{\%(\w*)\%}{
 		    $1 eq '' ? '%' :
 		    defined($v->{$1}) ? $v->{$1} :
+		    defined($r{$1}) ? $r{$1} :
 		    next;
 		 }ge;
 	# and return the first pattern we managed to completely substitute
@@ -2890,7 +2891,7 @@ sub host_netboot_file ($;$) {
     # returns the full netboot filename path
     # in array context, returns (dir, pathtail)
     #  where dir does not depend on $templatekeytail
-    my %v = %r;
+    my %v;
     my $firmware = get_host_property($ho, "firmware");
     my $templatekeybase = $firmware eq 'uefi' ? 'NetGrub' : 'Pxe';
     $templatekeytail //= 'Templates';
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 57/82] TestSupport: Provide runvar_is_synth
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (55 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 56/82] subst_netboot_template: Do not use all of %r Ian Jackson
@ 2020-10-07 17:59 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 58/82] runvar access: Introduce access control machinery Ian Jackson
                   ` (25 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 17:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Internally we use an array %r_notsynth.  This allows us to avoid
adding code to store_runvar etc.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 634d6d2e..ce13d3a6 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -52,7 +52,7 @@ BEGIN {
                       store_runvar get_runvar get_runvar_maybe
                       get_runvar_default need_runvars
                       unique_incrementing_runvar next_unique_name
-                      stashfilecontents
+                      stashfilecontents runvar_is_synth
 
                       target_cmd_root_status target_cmd_output_root_status
                       target_cmd_root target_cmd target_cmd_build
@@ -147,7 +147,7 @@ BEGIN {
     @EXPORT_OK   = qw();
 }
 
-our (%r,$flight,$job,$stash);
+our (%r,$flight,$job,$stash,%r_,%r_notsynth);
 
 our %timeout= qw(RebootDown   100
                  RebootUp     400
@@ -178,12 +178,13 @@ sub tsreadconfig () {
         logm("starting $flight.$job");
 
         my $q= $dbh_tests->prepare(<<END);
-            SELECT name, val FROM runvars WHERE flight=? AND job=?
+            SELECT name, val, synth FROM runvars WHERE flight=? AND job=?
 END
         $q->execute($flight, $job);
         my $row;
         while ($row= $q->fetchrow_hashref()) {
             $r{ $row->{name} }= $row->{val};
+	    $r_notsynth{ $row->{name} }= !$row->{synth};
             logm("setting $row->{name}=$row->{val}");
         }
         $q->finish();
@@ -434,6 +435,11 @@ END
     return $value;
 }
 
+sub runvar_is_synth ($) {
+    my ($key) = @_;
+    return !$r_notsynth{$key};
+}
+
 sub target_adjust_timeout ($$) {
     my ($ho,$timeoutref) = @_; # $ho might be a $gho
     my $nestinglvl = $ho->{NestingLevel} // $ho->{Host}{NestingLevel};
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 58/82] runvar access: Introduce access control machinery
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (56 preceding siblings ...)
  2020-10-07 17:59 ` [OSSTEST PATCH 57/82] TestSupport: Provide runvar_is_synth Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 59/82] runvar access: Provide runvar_glob Ian Jackson
                   ` (24 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This will allow us to trap accesses, during test host setup, to
runvars which weren't included in ithe calculation of the sharing
scope.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 53 ++++++++++++++++++++++++++++++++++++++++++
 README                 |  2 +-
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index ce13d3a6..b1eca0a9 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -33,6 +33,7 @@ use File::Basename;
 use IO::Handle;
 use Carp;
 use Digest::SHA;
+use File::FnMatch qw(:fnmatch);
 
 BEGIN {
     use Exporter ();
@@ -141,6 +142,8 @@ BEGIN {
                       target_core_dump_setup
                       sha256file host_shared_mark_ready
                       gitcache_setup
+
+		      @accessible_runvar_pats
                       );
     %EXPORT_TAGS = ( );
 
@@ -156,6 +159,10 @@ our %timeout= qw(RebootDown   100
 our $logm_handle= new IO::File ">& STDERR" or die $!;
 our $logm_prefix= '';
 
+# When runvar_access_restrict is called, it will limit reading
+# of non-synth runvars to ones which match these glob patterns.
+our @accessible_runvar_pats = qw(test-host-setup-runvars-will-appear-here);
+
 #---------- test script startup ----------
 
 sub tsreadconfig () {
@@ -3164,4 +3171,50 @@ END
                                  'home-osstest-gitconfig');
 }
 
+sub runvar_access_restrict () {
+    # restricts runvars to those in @accessible_runvar_pats
+    return if "@accessible_runvar_pats" eq "*";
+    return if tied %r;
+    tie %r, 'RunvarMonitor', %r;
+}
+
+sub runvar_access_check ($$) {
+    my ($key, $what) = @_;
+    return if grep { fnmatch $_, $key } @accessible_runvar_pats;
+    my $m = "reuse-uncontrolled runvar $what '$key'\n".
+            " (controlled runvars are @accessible_runvar_pats)";
+    confess $m unless $ENV{OSSTEST_UNCONTROLLED_SHARE_RUNVAR_WARNONLY};
+    Carp::cluck $m;
+}
+
+package RunvarMonitor;
+use Carp;
+use Osstest;
+use Osstest::TestSupport;
+
+sub TIEHASH {
+    my $self = shift;
+    logm("reuse: restricting runvars to @accessible_runvar_pats");
+    return bless { @_ }, $self;
+}
+
+sub _ok {
+    my $self = shift;
+    my $key = shift;
+    Osstest::TestSupport::runvar_access_check($key, 'access');
+}
+
+sub FIRSTKEY {
+    confess
+      "reuse-uncontrolled runvar scanning - change to use runvar_glob!";
+}
+sub FETCH { my ($self, $key) = @_; $self->_ok($key); $self->{$key} }
+sub EXISTS { my ($self, $key) = @_; $self->_ok($key); exists $self->{$key} }
+sub STORE { my ($self, $key, $val) = @_; $self->{$key} = $val; }
+sub DELETE { my ($self, $key) = @_; delete $self->{$key}; }
+
+sub CLEAR { confess }
+sub SCALAR { confess }
+sub UNTIE { confess }
+
 1;
diff --git a/README b/README
index ba4bea1d..a929010c 100644
--- a/README
+++ b/README
@@ -297,7 +297,7 @@ To run osstest in standalone mode:
      curl
      netcat
      chiark-utils-bin
-     libxml-libxml-perl
+     libxml-libxml-perl libfile-fnmatch-perl
      dctrl-tools
      libnet-snmp-perl (if you are going to use Masterswitch PDUs)
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 59/82] runvar access: Provide runvar_glob
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (57 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 58/82] runvar access: Introduce access control machinery Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 60/82] runvar access: Use runvar_glob for dmrestrict runvar search Ian Jackson
                   ` (23 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

We will need this because when runvar access is restricted, accessing
via %r directly won't work.  We want to see what patterns the code is
interested in (so that interest in a nonexistent runvar is properly
tracked).

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index b1eca0a9..6403e52b 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -53,7 +53,7 @@ BEGIN {
                       store_runvar get_runvar get_runvar_maybe
                       get_runvar_default need_runvars
                       unique_incrementing_runvar next_unique_name
-                      stashfilecontents runvar_is_synth
+                      stashfilecontents runvar_is_synth runvar_glob
 
                       target_cmd_root_status target_cmd_output_root_status
                       target_cmd_root target_cmd target_cmd_build
@@ -3187,6 +3187,20 @@ sub runvar_access_check ($$) {
     Carp::cluck $m;
 }
 
+sub runvar_glob {
+    my $monitor = tied %r;
+    my $realr = $monitor || \%r;
+    my @out;
+    foreach my $pat (@_) {
+	if ($monitor) { runvar_access_check($pat, 'scan') }
+	foreach my $key (sort keys %$realr) {
+	    next unless fnmatch $pat, $key;
+	    push @out, $key;
+	}
+    }
+    @out;
+}
+
 package RunvarMonitor;
 use Carp;
 use Osstest;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 60/82] runvar access: Use runvar_glob for dmrestrict runvar search
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (58 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 59/82] runvar access: Provide runvar_glob Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 61/82] runvar access: Introduce sharing_for_build Ian Jackson
                   ` (22 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 3fa26e45..ae3c1d33 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -1032,7 +1032,7 @@ END
     # security.d.o CDN seems unreliable right now
     # and jessie-updates is no more
 
-    if (grep { m/_dmrestrict$/ && $r{$_} } keys %r and
+    if (grep { $r{$_} } runvar_glob('*_dmrestrict') and
 	$suite =~ m/stretch/) {
 	preseed_backports_packages($ho, $sfx, \%xopts, $suite,
 				   qw(chiark-scripts));
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 61/82] runvar access: Introduce sharing_for_build
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (59 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 60/82] runvar access: Use runvar_glob for dmrestrict runvar search Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 62/82] runvar access: Introduce effects_gone_before_share_reuse Ian Jackson
                   ` (21 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Builds don't have so much contingent setup.  We don't track the
runvars; we just rely on the share-* hostflag set in the job.

But selecthost() is going to automatically enable runvar access
control for shared/reused hosts.  So, provide a way to disable that.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 4 +++-
 ts-host-install        | 2 ++
 ts-xen-build-prep      | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 6403e52b..c6bd6714 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -143,7 +143,7 @@ BEGIN {
                       sha256file host_shared_mark_ready
                       gitcache_setup
 
-		      @accessible_runvar_pats
+		      @accessible_runvar_pats sharing_for_build
                       );
     %EXPORT_TAGS = ( );
 
@@ -3171,6 +3171,8 @@ END
                                  'home-osstest-gitconfig');
 }
 
+sub sharing_for_build () { @accessible_runvar_pats = qw(*); };
+
 sub runvar_access_restrict () {
     # restricts runvars to those in @accessible_runvar_pats
     return if "@accessible_runvar_pats" eq "*";
diff --git a/ts-host-install b/ts-host-install
index b0fd2028..5badc706 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -49,6 +49,8 @@ while (@ARGV and $ARGV[0] =~ m/^-/) {
     }
 }
 
+if ($build) { sharing_for_build(); }
+
 our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
diff --git a/ts-xen-build-prep b/ts-xen-build-prep
index 092bbffe..fcabf75a 100755
--- a/ts-xen-build-prep
+++ b/ts-xen-build-prep
@@ -24,6 +24,7 @@ use Osstest::TestSupport;
 use Osstest::Debian;
 
 tsreadconfig();
+sharing_for_build();
 
 our ($whhost) = @ARGV;
 $whhost ||= 'host';
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 62/82] runvar access: Introduce effects_gone_before_share_reuse
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (60 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 61/82] runvar access: Introduce sharing_for_build Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 63/82] test host reuse: Switch to principled sharing scope runvar scheme Ian Jackson
                   ` (20 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

The syslog server, and its port, is used for things that happen in
this job, but the syslog server is torn down and a new one started,
when the host is reused.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm      | 10 ++++++----
 Osstest/TestSupport.pm |  6 ++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index ae3c1d33..01930e1f 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -727,10 +727,12 @@ sub di_installcmdline_core ($$;@) {
     push @cl, "priority=$debconf_priority";
     push @cl, "rescue/enable=true" if $xopts{RescueMode};
 
-    if ($r{syslog_server}) {
-	$r{syslog_server} =~ m/:(\d+)$/ or die "$r{syslog_server} ?";
-	push @cl, "log_host=$`", "log_port=$1";
-    }
+    effects_gone_before_share_reuse(sub {
+        if ($r{syslog_server}) {
+	    $r{syslog_server} =~ m/:(\d+)$/ or die "$r{syslog_server} ?";
+	    push @cl, "log_host=$`", "log_port=$1";
+	}
+    });
 
     return @cl;
 }
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index c6bd6714..752c36c5 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -144,6 +144,7 @@ BEGIN {
                       gitcache_setup
 
 		      @accessible_runvar_pats sharing_for_build
+		      effects_gone_before_share_reuse
                       );
     %EXPORT_TAGS = ( );
 
@@ -3173,6 +3174,11 @@ END
 
 sub sharing_for_build () { @accessible_runvar_pats = qw(*); };
 
+sub effects_gone_before_share_reuse ($) {
+    local @accessible_runvar_pats = qw(*);
+    $_[0]();
+}
+
 sub runvar_access_restrict () {
     # restricts runvars to those in @accessible_runvar_pats
     return if "@accessible_runvar_pats" eq "*";
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 63/82] test host reuse: Switch to principled sharing scope runvar scheme
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (61 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 62/82] runvar access: Introduce effects_gone_before_share_reuse Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 64/82] hsot reuse: Hash the share type Ian Jackson
                   ` (19 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

* When selecthost is passed an @host ident, indicating prep work,
  engage restricted runvar access.  If no call to sharing_for_build
  was made, this means it can access only the runvars in
  the default value of @accessible_runvar_pats.

* Make the sharetype for host reuse be based on the values of
  precisely those same runvars, rather than using an adhoc scheme.

The set of covered runvars is bigger now as a result of testing...

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 23 ++++++++++++++++++++++-
 ts-host-reuse          | 20 ++++++++------------
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 752c36c5..28381f05 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -162,7 +162,22 @@ our $logm_prefix= '';
 
 # When runvar_access_restrict is called, it will limit reading
 # of non-synth runvars to ones which match these glob patterns.
-our @accessible_runvar_pats = qw(test-host-setup-runvars-will-appear-here);
+# The initial list is the runvars whih affect how a test host is
+# set up, and for test jobs it isn't modified.  synth runvars
+# which are read-modify-write by host setup must be listed too.
+our @accessible_runvar_pats =
+  qw(
+      *_dmrestrict *buildjob
+      arch console di_version dom0_mem enable_xsm freebsd_distpath
+      linux_boot_append os suite toolstack xen_boot_append xenable_xsm
+      host                           *_host 
+      host_console                   *_host_console
+      host_hostflagadjust            *_host_hostflagadjust
+      host_hostflags                 *_host_hostflags
+      host_linux_boot_append         *_host_linux_boot_append
+      host_ip                        *_host_ip
+      host_power_install             *_host_power_install
+   );
 
 #---------- test script startup ----------
 
@@ -1274,6 +1289,12 @@ sub selecthost ($;$$) {
 	return $child;
     }
 
+    #----- if we're sharing an actual host, make sure we do it right -----
+
+    if ($isprep) {
+	runvar_access_restrict();
+    }
+
     #----- calculation of the host's properties -----
 
     # Firstly, hardcoded defaults
diff --git a/ts-host-reuse b/ts-host-reuse
index 29abe987..c852a858 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -64,18 +64,14 @@ sub sharetype_add ($$) {
 }
 
 sub compute_test_sharetype () {
-    $sharetype =
-	"test-$flight/$r{arch}/$r{xenbuildjob}/$r{kernbuildjob}/$r{buildjob}";
-
-    sharetype_add('suite', $ho->{Suite});
-    sharetype_add('di', $ho->{DiVersion});
-
-    foreach my $runvar (qw(freebsd_distpath freebsdbuildjob
-			   xenable_xsm toolstack kernkind
-			   xen_boot_append toolstack)) {
-	my $val = $r{$runvar};
-	die "$runvar $val ?" if defined $val && $val =~ m{[,/\%\\]};
-	sharetype_add($runvar, $val);
+    $sharetype = "test-$flight";
+    my %done;
+    foreach my $key (runvar_glob(@accessible_runvar_pats)) {
+	next if runvar_is_synth($key);
+	my $val = $r{$key};
+	next if $done{$key}++;
+	$val =~ s{[^\"-\~]|\%}{ sprintf "%%%02x", ord $& }ge;
+	$sharetype .= "!$key=$r{$key}";
     }
 
     return $sharetype;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 64/82] hsot reuse: Hash the share type
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (62 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 63/82] test host reuse: Switch to principled sharing scope runvar scheme Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 65/82] hsot reuse: Make share type hash more easily greppable Ian Jackson
                   ` (18 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

We don't really want to duplicate (triplicate, actually) lots of the
runvars.  This will make the runvars table needlessly bloated.

So hash the values.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 README        |  2 +-
 ts-host-reuse | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/README b/README
index a929010c..1703e076 100644
--- a/README
+++ b/README
@@ -297,7 +297,7 @@ To run osstest in standalone mode:
      curl
      netcat
      chiark-utils-bin
-     libxml-libxml-perl libfile-fnmatch-perl
+     libxml-libxml-perl libfile-fnmatch-perl libdigest-sha-perl
      dctrl-tools
      libnet-snmp-perl (if you are going to use Masterswitch PDUs)
 
diff --git a/ts-host-reuse b/ts-host-reuse
index c852a858..701070b2 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -43,6 +43,7 @@ use DBI;
 BEGIN { unshift @INC, qw(.); }
 use Osstest;
 use POSIX;
+use Digest::SHA qw(sha224_base64);
 use Osstest::TestSupport;
 
 tsreadconfig();
@@ -64,16 +65,18 @@ sub sharetype_add ($$) {
 }
 
 sub compute_test_sharetype () {
-    $sharetype = "test-$flight";
+    my @runvartexts;
     my %done;
     foreach my $key (runvar_glob(@accessible_runvar_pats)) {
 	next if runvar_is_synth($key);
 	my $val = $r{$key};
 	next if $done{$key}++;
-	$val =~ s{[^\"-\~]|\%}{ sprintf "%%%02x", ord $& }ge;
-	$sharetype .= "!$key=$r{$key}";
+	$val =~ s{[^\!-\~]|\%}{ sprintf "%%%02x", ord $& }ge;
+	push @runvartexts, "$key=$r{$key}";
     }
-
+    my $digest = sha224_base64("@runvartexts");
+    $sharetype = "test-$flight-$digest";
+    logm "share type $sharetype; hash is of: @runvartexts";
     return $sharetype;
 }
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 65/82] hsot reuse: Make share type hash more easily greppable
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (63 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 64/82] hsot reuse: Hash the share type Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 66/82] host lifecycle: Machinery, db, for tracking relevant events Ian Jackson
                   ` (17 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Use - and _ to make up the base64 alphabet instead of + and /

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 ts-host-reuse | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ts-host-reuse b/ts-host-reuse
index 701070b2..0ecbb0bd 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -75,6 +75,7 @@ sub compute_test_sharetype () {
 	push @runvartexts, "$key=$r{$key}";
     }
     my $digest = sha224_base64("@runvartexts");
+    $digest =~ y{/+}{-_};
     $sharetype = "test-$flight-$digest";
     logm "share type $sharetype; hash is of: @runvartexts";
     return $sharetype;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 66/82] host lifecycle: Machinery, db, for tracking relevant events
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (64 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 65/82] hsot reuse: Make share type hash more easily greppable Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 67/82] host lifecycle: Fix detection of concurrent jobs Ian Jackson
                   ` (16 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

When we reuse test hosts, we want to be able to give a list of the
other jobs which might be responsible for any problem.

In principle it would be possible to do this by digging into the
db's history tables like sg-report-host-history does, but this is
quite slow and also I don't have enough confidence in that approach to
use it for this application.

So instead, track the host lifecycle explicitly.

The approach taken is a hybrid one.  I first considered two and a half
approaches:

 1. Permanently record all host/share allocations and share state
    changes in a host history table.  But it is nontrivial to update
    all the allocation machinery to keep this table up to date.  It is
    also nontrivial to extract the necessary information from such a
    table: the allocation information would have to be correlated,
    using timestamps, with the steps table.  That's slow and complex.
    We had such a table but it was never used for these reasons;
    I dropped that empty table recently.

 1b. Like 1 but explicitly put a lifecycle sequence number in the
    allocations table,.  This would make it easy to find relevant
    events but would involve even more complicated logic during
    allocation.

 2. Record the host's lifecycle information in a file on the host.
    This means it gets wiped whenever the host does and makes finding
    the relevant jobs easy: read the file during logs capture, and
    we'll find everything of relevance.  It then has to be permanently
    stored somewhere it can be used for logging and archaeology: a
    per-job runvar giving the relevant host history, up to the point
    where that job finished. does that job nicely.  However, this
    has a serious problem: if the host crashes hard, we may not be
    able to recover the complete information about why!  We really
    want to the information recorded outside the host in question.

So I've taken a hybrid approach: effectively replicate the per-host
file from (2), but put the information in the database.  This
necessites a call to clear the host lifecycle history, which we make
at the *end* of the host install.  As a bonus this might let us more
easily identify if there are particular jobs that leave hosts in
states that are hard to recover from, and it will make total host
failure quite obvious because the host install log report will have a
list of the failed attempts (longer in each successive job).

For build jobs we only record the setup job, and concurrent jobs, in
the runvar.  This does not seem to have been a problem so far, and
this avoids having to do work on other allocations (eg, mg-allocate).
It also avoids having very long lists of previous builds listed in
every build job.

Test jobs are only shared within a flight and with much more limited
scope so the same considerations don't arise.  But by the same token,
we also do not need to adjust mg-allocate etc., since the user ought
not to allocate shares of test hosts unless they know what they are
doing.

In this commit we introduce:
 * The database table
 * The runvar syntax
 * The function for recording the lifecycle events

We have what amounts to an ad-hoc compression scheme for the
information in the lifecycle runvars.  Otherwise this data might get
quite voluminous, which can makes various other db queries slow.

There isn't a very good way to represent out-of-job tasks in the
lifecycle runvar.  We could maybe put in something from the tasks
table, but the entry in the tasks table might be gone by now and that
would involve quoting (and it might be quite large).

But this will only matter when a shared/reused host has been manually
messed with, and recording the task is sufficient to
 (1) note the fact of such interference
 (2) if the task is static, or still going when the job reports,
      can actually be put in the report.
 (3) failing that provide something which could be grepped for in logs

We do not call the recording function yet, so the db update is merely
Preparatory.

There is a bug in this patch: the calculation of $olive is wrong.
This will be fixed in a moment.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm  | 211 ++++++++++++++++++++++++++++++++++++
 Osstest/JobDB/Standalone.pm |   2 +
 Osstest/TestSupport.pm      |  12 ++
 schema/host-lifecycle.sql   |  43 ++++++++
 4 files changed, 268 insertions(+)
 create mode 100644 schema/host-lifecycle.sql

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index 8fde2934..cf82b4cf 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -24,6 +24,7 @@ use Osstest;
 use Osstest::TestSupport;
 use Osstest::Executive;
 use Data::Dumper;
+use Carp;
 
 BEGIN {
     use Exporter ();
@@ -461,4 +462,214 @@ sub jobdb_db_glob ($$) { #method
 
 sub can_anoint ($) { return 1; }
 
+sub jobdb_host_update_lifecycle_info ($$$) { #method
+    my ($mo, $ho, $mode) = @_;
+    # $mode is       sigil
+    #  selectprep  1  @     called several times, from selecthost, $isprep
+    #  wiped       2  n/a   called (usually) once, when install succeeds
+    #  select      1  +     called several times, from selecthost, !$isprep
+    #  final       1  none  called (hopefully) once, from capture-logs
+    #                        (once means within this job)
+    # Notes:
+    #   1   causes a new row to be added to the host lifecycle
+    #       subject to sigil check
+    #   2   removes other rows from the host lifecycle
+    #
+    # Where "sigil" above is nonempty: we look at the runvar.  If the
+    # runvar's final sigil is the same, we conclude that the needed
+    # work has already been done: ie, we do not need to add a row to
+    # the table nor do we necessarily need to update the runvar.
+    #
+    # If the sigil is not right, we replace the runvar with a history
+    # string derived from the lifecycle table, and (if appropriate)
+    # add a row.
+    #
+    # In principle it might be useful to update the runvar every time
+    # because the lifecycle table might have gained rows from other
+    # jobs, but we would like to avoid burdening select with more
+    # pratting about.  So we leave that for capture-logs and
+    # reuse/final, ie when newsigil is none.
+    #
+    # The runvar is
+    #     <ident>_lifecycle
+    # and contains space-separated entries
+    #     [+@][<flight>.][<job>]:<stepno>[,<ident>]
+    #     [+@]<stepno>              same flight, job, ident; new stepno
+    #     "["<omitted-count>"]"     ie literal [ ]
+    #     [+]?<taskid>              task not within a flight/job
+    # where omitted [,<ident>] means "host";
+    # omitted <flight> and <job> mean this runvar's flight and/or job;
+    # and then at then end most one of the sigils
+    #     @                      last call was selectprep
+    #     +                      last call was select
+    #     <none>                 last call was final
+    # items with no such sigil don't appear in build jobs
+    # and instead appear as [<omitted-count>] eg "[4]"
+
+    return if $ho->{Host}; # This host *has* a host - ie, nested
+
+    my $ttaskid = findtask();
+    my $hostname = $ho->{Name};
+    my $tident = $ho->{Ident};
+    my $tstepno = $mo->current_stepno();
+
+    if ($mode eq 'wiped') {
+	db_retry($flight, [qw(running)], $dbh_tests,[], sub {
+            $dbh_tests->do(<<END, {}, $hostname);
+                DELETE FROM host_lifecycle h
+                      WHERE hostname=?
+                        AND NOT EXISTS(
+                SELECT 1
+		  FROM tasks t
+		 WHERE t.live
+		   AND t.taskid = h.taskid
+                );
+END
+        });
+	logm("host lifecycle: $hostname: wiped, cleared out old info");
+	return;
+    }
+
+    my $newsigil =
+      $mode eq 'selectprep' ? '@' :
+      $mode eq 'select'     ? '+' :
+      $mode eq 'final'      ? ''  :
+      confess "$mode ?";
+
+    my $scanq = $dbh_tests->prepare(<<END);
+	   SELECT h.flight, h.job, h.isprep, h.ident, h.stepno,
+                  t.live, t.taskid,
+                  h2.lcseq later_notprep
+	     FROM host_lifecycle h
+        LEFT JOIN host_lifecycle h2
+               ON h2.hostname = h.hostname 
+              AND h2.flight   = h.flight
+              AND h2.job      = h.job
+              AND h2.ident    = h.ident
+              AND h2.taskid   = h.taskid
+              AND h2.lcseq    > h.lcseq
+              AND h.isprep AND NOT h2.isprep
+        LEFT JOIN tasks t
+               ON h.taskid = t.taskid
+            WHERE h.hostname = ?
+         ORDER BY h.lcseq;
+END
+    my $insertq = $dbh_tests->prepare(<<END);
+        INSERT INTO host_lifecycle
+                 (hostname, taskid, flight, job, isprep, ident, stepno)
+          VALUES (?,        ?,      ?,      ?,   ?,      ?,     ?     )
+END
+
+    my $ojvn = "$ho->{Ident}_lifecycle";
+    my $firstrun;
+
+    if (length $r{$ojvn}) {
+	my ($oldsigil,) = reverse split / /, $r{$ojvn};
+	$oldsigil = '' unless $oldsigil =~ m/^\W$/;
+	return if $newsigil ne '' && $oldsigil eq $newsigil;
+    } else {
+	$firstrun = 1;
+    }
+
+    my @lifecycle;
+    db_retry($dbh_tests,[], sub {
+	my $elided;
+	@lifecycle = ();
+        my %tj_seen;
+	# keys in %tj_seen are [@][<flight>.][<job>] or ?<taskid>
+        $scanq->execute($hostname);
+
+	while (my $o = $scanq->fetchrow_hashref()) {
+	    my $olive =
+	      # Any job which appeared since we started thinking
+	      # about this must have been concurrent with us,
+	      # even if it is dead now.
+	      (!$firstrun || $o->{live}) &&
+	      # If this task is still live, we need to have something
+	      # with a live mark, generally all the prep will have
+	      # occurred already, so we don't mark the prep as live
+	      # if there's a later nonprep step.
+	      !$o->{later_notprep};
+
+	    my $olivemark = !!$olive && '+';
+	    if (defined($flight) && defined($o->{flight}) &&
+		$o->{flight} eq $flight &&
+		$o->{job} eq $job) {
+		# Don't put the + mark on our own entries.
+		$olivemark = '';
+	    }
+
+	    my $oisprepmark = !!$o->{isprep} && '@';
+	    my $omarks = $olivemark.$oisprepmark;
+
+	    my $otj = '';
+	    if (!defined $o->{flight}) {
+		$otj .= "?$o->{taskid}";
+	    } else {
+		$otj .= "$o->{flight}." if $o->{flight} ne $flight;
+		$otj .= $o->{job} if $o->{job} ne $job;
+	    }
+	    next if $tj_seen{$oisprepmark.$otj}++;
+
+	    if (!$omarks && !$olive && defined($o->{flight}) &&
+		$ho->{Shared} &&
+		$ho->{Shared}{Type} =~ m/^build-/ &&
+		!$tj_seen{"\@$otj"} # do not elide use if we showed prep
+	       ) {
+		# elide previous, non-concurrent, build jobs
+		if (!$elided) { $elided = [ scalar(@lifecycle), 0]; }
+		$lifecycle[$elided->[0]] = "[".(++$elided->[1])."]";
+		next;
+	    }
+
+	    my $osuffix = !!(defined($o->{ident}) && $o->{ident} ne 'host')
+	      && ",$o->{ident}";
+
+	    my ($lastuncompr,) = grep { !m{^\W*\d+$} } reverse @lifecycle;
+	    if (defined($lastuncompr) &&
+		$lastuncompr =~ m{^\W*\Q$otj\E:\d+\Q$osuffix\E$}) {
+		push @lifecycle, "$omarks$o->{stepno}";
+	    } else {
+		push @lifecycle, "$omarks$otj:$o->{stepno}$osuffix";
+	    }
+	}
+	if (defined $flight) {
+	    $insertq->execute($hostname, $ttaskid,
+			      $flight, $job,
+			      ($mode eq 'selectprep')+0,
+                # ^ DBD::Pg doesn't accept perl canonical false for bool!
+                #   https://rt.cpan.org/Public/Bug/Display.html?id=133229
+			      $tident, $tstepno);
+	} else {
+	    $insertq->execute($hostname, $ttaskid,
+			      undef,undef,
+			      undef,
+			      undef,undef);
+	}
+    });
+
+    if (defined $flight) {
+	push @lifecycle, $newsigil if length $newsigil;
+	store_runvar($ojvn, "@lifecycle");
+    }
+}
+
+sub current_stepno ($) { #method
+    my ($jd) = @_;
+    my $testid = $ENV{OSSTEST_TESTID} // return undef;
+    my $checkq = $dbh_tests->prepare(<<END);
+        SELECT stepno
+          FROM steps
+         WHERE flight=?
+           AND job=?
+           AND testid=?
+END
+    my $stepno;
+    db_retry($flight,[qw(running)], $dbh_tests,[],sub {
+	$checkq->execute($flight,$job,$testid);
+	($stepno) = $checkq->fetchrow_array();
+    });
+    return $stepno;
+}
+
 1;
diff --git a/Osstest/JobDB/Standalone.pm b/Osstest/JobDB/Standalone.pm
index 1db4dc78..6e1ae158 100644
--- a/Osstest/JobDB/Standalone.pm
+++ b/Osstest/JobDB/Standalone.pm
@@ -137,4 +137,6 @@ sub jobdb_db_glob ($) { #method
 
 sub can_anoint ($) { return 0; }
 
+sub jobdb_host_update_lifecycle_info { } #method
+
 1;
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 28381f05..22141981 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -88,6 +88,7 @@ BEGIN {
                       serial_fetch_logs set_host_property modify_host_flag
                       propname_massage propname_check
                       hostprop_putative_record hostflag_putative_record
+                      host_update_lifecycle_info
          
                       get_stashed open_unique_stashfile compress_stashed
                       dir_identify_vcs
@@ -174,6 +175,7 @@ our @accessible_runvar_pats =
       host_console                   *_host_console
       host_hostflagadjust            *_host_hostflagadjust
       host_hostflags                 *_host_hostflags
+      host_lifecycle                 *_host_lifecycle
       host_linux_boot_append         *_host_linux_boot_append
       host_ip                        *_host_ip
       host_power_install             *_host_power_install
@@ -3166,6 +3168,16 @@ sub sha256file ($;$) {
     return $truncate ? substr($digest, 0, $truncate) : $digest;
 }
 
+sub host_update_lifecycle_info ($$) {
+    my ($ho, $mode) = @_;
+    # $mode is
+    #  selectprep       called several times, from selecthost, $isprep
+    #  wiped            called once, when install succeeds
+    #  select           called several times, from selecthost, !$isprep
+    #  final            called hopefully once, from capture-logs
+    $mjobdb->jobdb_host_update_lifecycle_info($ho, $mode)
+}
+
 sub host_shared_mark_ready($$;$$) {
     my ($ho,$sharetype, $oldstate, $newstate) = @_;
 
diff --git a/schema/host-lifecycle.sql b/schema/host-lifecycle.sql
new file mode 100644
index 00000000..7f1f5bb0
--- /dev/null
+++ b/schema/host-lifecycle.sql
@@ -0,0 +1,43 @@
+-- ##OSSTEST## 012 Preparatory
+--
+-- Records the jobs which have touched a host, for host sharing/reuse
+-- The information here is ephemeral - it is cleared when a host is
+-- reinitialised.  The information is persisted by being copied
+-- into a runvar for each job.
+
+CREATE SEQUENCE host_lifecycle_lcseq_seq
+    NO CYCLE;
+
+CREATE TABLE host_lifecycle (
+    hostname     TEXT NOT NULL,
+    lcseq        INTEGER NOT NULL DEFAULT nextval('host_lifecycle_lcseq_seq'),
+    taskid       INTEGER NOT NULL, -- no constraint, tasks can get deleted
+    flight       INTEGER,
+    job          TEXT,
+    stepno       INTEGER,
+    ident        TEXT,
+    isprep       BOOLEAN,
+    PRIMARY KEY  (hostname, lcseq),
+--  restype      TEXT GENERATED ALWAYS AS ('host'),
+--  FOREIGN KEY  (restype,hostname)    REFERENCES resources(restype, resname),
+--     ^ those two omitted because not supported until pgsql 13
+--  FOREIGN KEY (flight, job)         REFERENCES jobs(flight, job),
+--      ^ omitted because the next constraint implies it
+    FOREIGN KEY  (flight, job, stepno) REFERENCES steps(flight, job, stepno),
+    CHECK ((
+	flight       IS NOT NULL AND
+	job          IS NOT NULL AND
+	stepno       IS NOT NULL AND
+	ident        IS NOT NULL AND
+	isprep       IS NOT NULL
+    ) OR (
+	flight       IS     NULL AND
+	job          IS     NULL AND
+	stepno       IS     NULL AND
+	ident        IS     NULL AND
+	isprep       IS     NULL
+    ))
+);
+
+ALTER SEQUENCE host_lifecycle_lcseq_seq
+    OWNED BY host_lifecycle.lcseq;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 67/82] host lifecycle: Fix detection of concurrent jobs
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (65 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 66/82] host lifecycle: Machinery, db, for tracking relevant events Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 68/82] host lifecycle: Prevent referential integrity violation Ian Jackson
                   ` (15 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

The previous algorithm was wrong here.

This commit was originally considerably later than the previous one.
I'm avoiding squshing this commit, to make future archaeology easier.
The effect of the bug is to report other tasks as live too often, so
hosts show up as shared rather than reused.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 Osstest/JobDB/Executive.pm | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index cf82b4cf..3a8308e9 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -561,17 +561,15 @@ END
 END
 
     my $ojvn = "$ho->{Ident}_lifecycle";
-    my $firstrun;
 
     if (length $r{$ojvn}) {
 	my ($oldsigil,) = reverse split / /, $r{$ojvn};
 	$oldsigil = '' unless $oldsigil =~ m/^\W$/;
 	return if $newsigil ne '' && $oldsigil eq $newsigil;
-    } else {
-	$firstrun = 1;
     }
 
     my @lifecycle;
+    my $seen_us;
     db_retry($dbh_tests,[], sub {
 	my $elided;
 	@lifecycle = ();
@@ -581,10 +579,10 @@ END
 
 	while (my $o = $scanq->fetchrow_hashref()) {
 	    my $olive =
-	      # Any job which appeared since we started thinking
-	      # about this must have been concurrent with us,
-	      # even if it is dead now.
-	      (!$firstrun || $o->{live}) &&
+	      # Any job with any entry after we put ourselves in the
+	      # table must have been concurrent with us, even if it is
+	      # dead now.
+	      ($seen_us || $o->{live}) &&
 	      # If this task is still live, we need to have something
 	      # with a live mark, generally all the prep will have
 	      # occurred already, so we don't mark the prep as live
@@ -597,6 +595,7 @@ END
 		$o->{job} eq $job) {
 		# Don't put the + mark on our own entries.
 		$olivemark = '';
+		$seen_us = 1;
 	    }
 
 	    my $oisprepmark = !!$o->{isprep} && '@';
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 68/82] host lifecycle: Prevent referential integrity violation
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (66 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 67/82] host lifecycle: Fix detection of concurrent jobs Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 69/82] host lifecycle: Record lifecycle in db and runvar Ian Jackson
                   ` (14 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

We can't use normal constraints for either of these, sadly.

We can make the constraints into a single query which says "OK".

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index 3a8308e9..f69ce277 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -553,6 +553,28 @@ END
                ON h.taskid = t.taskid
             WHERE h.hostname = ?
          ORDER BY h.lcseq;
+END
+    # We simulate two foreign key constraints which can't be in the
+    # db schema, by checking the values we are going to insert.
+    #
+    # For "resources" we would need a foreign key constraint
+    # with a literal value as part of the foreign key, which is
+    # not supported until PostgreSQL 13.
+    #
+    # For "tasks" we only want to apply the constraint on inserts into
+    # "host_lifecycle" - in particular, we want to allow delet6ions
+    # from "tasks" to render the taskid foreign key unresolvable.
+    # This could be done with a trigger, but since here is the only
+    # place we do insertions into host_lifecycle, this seems easier.
+    my $constraintsq = $dbh_tests->prepare(<<END);
+           SELECT * FROM
+	     (SELECT 1 AS ok
+	        FROM resources where restype='host' and resname=?) 
+              hostname_ok
+             NATURAL JOIN
+             (SELECT 1 AS ok
+                FROM tasks where taskid=? AND live)
+              taskid_ok;
 END
     my $insertq = $dbh_tests->prepare(<<END);
         INSERT INTO host_lifecycle
@@ -632,6 +654,9 @@ END
 		push @lifecycle, "$omarks$otj:$o->{stepno}$osuffix";
 	    }
 	}
+	$constraintsq->execute($hostname, $ttaskid);
+	$constraintsq->fetchrow_array() or confess "$hostname ?";
+
 	if (defined $flight) {
 	    $insertq->execute($hostname, $ttaskid,
 			      $flight, $job,
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 69/82] host lifecycle: Record lifecycle in db and runvar
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (67 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 68/82] host lifecycle: Prevent referential integrity violation Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 70/82] sg-report-flight: Refactor runvar access Ian Jackson
                   ` (13 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This is just the calls to host_update_lifecycle_info.
Now the db table is Needed.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm    | 2 ++
 schema/host-lifecycle.sql | 2 +-
 ts-freebsd-host-install   | 1 +
 ts-host-install           | 1 +
 ts-host-reuse             | 1 +
 ts-logs-capture           | 1 +
 6 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 22141981..163862f8 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -1418,6 +1418,8 @@ sub selecthost ($;$$) {
 	}
     }
 
+    host_update_lifecycle_info($ho, $isprep ? 'selectprep' : 'select');
+
     return $ho;
 }
 
diff --git a/schema/host-lifecycle.sql b/schema/host-lifecycle.sql
index 7f1f5bb0..7e4fc2aa 100644
--- a/schema/host-lifecycle.sql
+++ b/schema/host-lifecycle.sql
@@ -1,4 +1,4 @@
--- ##OSSTEST## 012 Preparatory
+-- ##OSSTEST## 012 Needed
 --
 -- Records the jobs which have touched a host, for host sharing/reuse
 -- The information here is ephemeral - it is cleared when a host is
diff --git a/ts-freebsd-host-install b/ts-freebsd-host-install
index 9feb98cd..31e14d57 100755
--- a/ts-freebsd-host-install
+++ b/ts-freebsd-host-install
@@ -295,3 +295,4 @@ setup_netboot_local($ho);
 
 # Proceed with the install
 install();
+host_update_lifecycle_info($ho, 'wiped');
diff --git a/ts-host-install b/ts-host-install
index 5badc706..276c6af8 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -297,3 +297,4 @@ END
 }
 
 install();
+host_update_lifecycle_info($ho, 'wiped');
diff --git a/ts-host-reuse b/ts-host-reuse
index 0ecbb0bd..85beb51e 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -158,6 +158,7 @@ sub act_post_test () {
     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');
 }
 
diff --git a/ts-logs-capture b/ts-logs-capture
index ec494fe1..0b0b6af6 100755
--- a/ts-logs-capture
+++ b/ts-logs-capture
@@ -309,3 +309,4 @@ if (fetch_logs_host()) {
     }
 }
 logm("logs captured to $stash");
+host_update_lifecycle_info($ho, 'final');
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 70/82] sg-report-flight: Refactor runvar access
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (68 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 69/82] host lifecycle: Record lifecycle in db and runvar Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 71/82] resource reporting, nfc: split a here document Ian Jackson
                   ` (12 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Collect the runvars query into local perl variables.  This will allow
us to reuse the information without going back to the db.

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-report-flight | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/sg-report-flight b/sg-report-flight
index 07834581..281361c0 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1142,6 +1142,16 @@ END
     my $ji = $htmlout_jobq->fetchrow_hashref();
     die unless $ji;
 
+    my $varsq= db_prepare(<<END);
+        SELECT name, val, synth FROM runvars
+                WHERE flight=? AND job=?
+             ORDER BY synth, name
+END
+    $varsq->execute($fi->{Flight}, $job);
+    my $runvar_table = $varsq->fetchall_arrayref({});
+    my %runvar_map;
+    $runvar_map{$_->{name}} = $_ foreach @$runvar_table;
+
     print H <<END;
 <html><head><title>$title</title><head>
 <body>
@@ -1244,14 +1254,8 @@ END
 <h2>Test control variables</h2>
 <table rules=all><tr><th>Name</th><th>Value</th><th>Source</th></tr>
 END
-    my $varsq= db_prepare(<<END);
-        SELECT name, val, synth FROM runvars
-                WHERE flight=? AND job=?
-             ORDER BY synth, name
-END
-    $varsq->execute($fi->{Flight}, $job);
-    while (my $varrow= $varsq->fetchrow_arrayref()) {
-        my ($vn,$vv,$synth) = (@$varrow);
+    foreach my $varrow (@$runvar_table) {
+        my ($vn,$vv,$synth) = (@$varrow{qw(name val synth)});
         print H "<tr><th>".encode_entities($vn)."</th>";
         print H "<td>";
         my $url;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 71/82] resource reporting, nfc: split a here document
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (69 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 70/82] sg-report-flight: Refactor runvar access Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 72/82] resource reporting: Report host reuse/sharing in job report Ian Jackson
                   ` (11 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-report-flight | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sg-report-flight b/sg-report-flight
index 281361c0..a1f424c5 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1213,6 +1213,9 @@ END
 <tr><td>Status:</td><td>$ji->{status}</td></tr>
 </table>
 <p>
+END
+
+    print H <<END;
 <h2>Logfiles etc.</h2>
 For main test script logfiles, see entries in steps table.
 <p>
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 72/82] resource reporting: Report host reuse/sharing in job report
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (70 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 71/82] resource reporting, nfc: split a here document Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 73/82] host reuse: sg-run-job: Reanme post-test-ok parameter Ian Jackson
                   ` (10 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Compatibility: in principle this might generate erroneous reports
which omit sharing/reuse information for allocations made by jobs
using older versions of osstest.

However, we do not share or reuse hosts across different osstest
versions, so this cannot occur.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-report-flight | 331 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 330 insertions(+), 1 deletion(-)

diff --git a/sg-report-flight b/sg-report-flight
index a1f424c5..0413a730 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -29,9 +29,10 @@ use POSIX;
 use IPC::Open2;
 use Data::Dumper;
 use File::Path;
+use Carp;
 
 use Osstest;
-use Osstest::Executive;
+use Osstest::Executive qw(:DEFAULT :colours);
 
 our $specflight;
 our %specver;
@@ -1122,6 +1123,68 @@ END
     return @failures;
 }
 
+# Machinery for generating WITH ... VALUES common table expressions.
+# Use it like this:
+#
+#    1. $some_accum = {}
+#
+#    2. valuestable_add_row($some_accum, $val, $val, $val)
+#          # ^ zero or more times
+#
+#    3. $qtxt = "WITH\n";
+#       @qparams = ();
+#       valuestable_with(\$qtxt, \@qparams, 'cte_name',
+#              qw(txtcol1 txtcol2 intcol::integer boolcol::bool ...));
+#
+# The resulting CTE table will have the name, and column names,
+# you specified.  For non-TEXT columns you must specify the type
+# because [Postgre]SQL's type inference doesn't work properly here.
+#
+# valuestable_with will always leave $qtxt ending with ",\n"
+# so you can call it multiple times.
+
+sub valuestable_add_row ($@) {
+    my ($accum, @row) = @_;
+    # $accum->{Ncols}
+    # $accum->{Params}[]
+    # $accum->{Qtxt}
+    $accum->{Ncols} //= scalar @row;
+    confess unless $accum->{Ncols} == @row;
+    push @{ $accum->{Params} }, @row;
+    $accum->{Qtxt} //= '';
+    $accum->{Qtxt} =~ s/.$/$&,/;
+    $accum->{Qtxt} .= "          (".join(',', ('?',) x @row).")\n";
+}
+sub valuestable_with ($$$@) {
+    my ($qtxtr, $paramsr, $ctename, $accum, @cols) = @_;
+    my $limit = '';
+    $accum->{Qtxt} //= do {
+	# Oh my god
+	# select * from (values );
+	# => ERROR:  syntax error at or near ")"
+	$limit = 'LIMIT 0';
+	"          (".join(',',
+			   map { m/::/ ? "NULL::$'" : "NULL" }
+			   @cols).")\n";
+    };
+    $accum->{Ncols} //= scalar @cols;
+    confess "$accum->{Ncols} != ".(scalar @cols)
+      unless $accum->{Ncols} == @cols;
+    my $cols = join(', ', @cols);
+    my $colsnotypes = join(', ', map { m/::/ ? $` : $_ } @cols);
+    $$qtxtr .= <<END;
+      $ctename ($colsnotypes) AS (SELECT
+            $cols FROM (VALUES
+$accum->{Qtxt}        $limit) $ctename ($colsnotypes)),
+
+END
+    push @$paramsr, @{ $accum->{Params} // [ ] };
+}
+
+sub nullcols {
+    join ", ", map { m/::/ ? "NULL::$' as $`" : "NULL as $_" } @_;
+}
+
 sub htmloutjob ($$) {
     my ($fi,$job) = @_;
     return unless defined $htmldir;
@@ -1213,6 +1276,272 @@ END
 <tr><td>Status:</td><td>$ji->{status}</td></tr>
 </table>
 <p>
+END
+
+    # ---------- resource reuse/sharing report ----------
+
+    # We translate the lifecycle runvars into a set of questions
+    # for the db.  But rather than doing one db query for each
+    # such question, we aggregate the questions into VALUES
+    # expressions and ask the db to produce a collated list of
+    # relevant information.  This has fewer round trips.
+
+    my $shareq_elided_accum = {};
+    my $shareq_tasks_accum = {};
+    my $shareq_main_accum = {};
+    foreach my $lc_var_row (@$runvar_table) {
+	next unless $lc_var_row->{name} =~ m{^(.*_?host)_lifecycle$};
+	my $tident = $1;
+	my $hostname = ($runvar_map{$tident} // next)->{val};
+	my $last_uncompr;
+	my $sort_index;
+	print DEBUG "SHARE LC $job $tident $lc_var_row->{val}\n";
+	foreach (split / /, $lc_var_row->{val}) {
+	    $sort_index++;
+	    if (m/^[\@\+]$/) {
+		valuestable_add_row $shareq_elided_accum,
+		  $tident, $hostname, undef, $&, $sort_index;
+		next;
+	    }
+	    if (m/^\[(\d+)\]$/) { # elided
+		valuestable_add_row $shareq_elided_accum,
+		  $tident, $hostname, $1, undef, $sort_index;
+		next;
+	    }
+	    my $olive = s/^\+//;
+	    if (m/^\?(\d+)$/) { # tasks
+		valuestable_add_row $shareq_tasks_accum,
+		  $tident, $hostname, $olive+0, $1, $sort_index;
+		next;
+	    }
+	    my $oisprep = s/^\@//;
+	    s{^\d+$}{ join ":$&", @$last_uncompr }e if $last_uncompr;
+	    if (my ($tprefix, $oflight, $ojob,
+		    $ostepno, $tsuffix, $oident) =
+		m{^((?:(\d+)\.)?([^:]+)?)\:(\d+)((?:,([^:]+))?)$}) {
+		# main
+		$last_uncompr = [ $tprefix, $tsuffix ];
+		$oflight ||= $specflight;
+		$ojob ||= $job;
+		$oident ||= 'host';
+		valuestable_add_row $shareq_main_accum,
+		  $tident, $hostname, $oflight, $ojob, $ostepno,
+		  $oisprep+0, $oident, $olive+0;
+		next;
+	    }
+	    confess "$tident $hostname $_ ?";
+	}
+    }
+    my @shareq_params;
+    my $shareq_txt = <<END;
+      WITH
+
+END
+
+    valuestable_with \$shareq_txt, \@shareq_params,
+      'q_elided', $shareq_elided_accum,
+      qw(tident hostname count::integer sigil sort_index::integer);
+
+    valuestable_with \$shareq_txt, \@shareq_params,
+      'q_tasks', $shareq_tasks_accum,
+      qw(tident hostname olive::bool taskid::integer sort_index::integer);
+
+    valuestable_with \$shareq_txt, \@shareq_params,
+      'q', $shareq_main_accum,
+      qw(tident hostname flight::integer job
+         stepno::integer oisprep::bool oident olive::bool);
+
+    # Helpers to reduce typing in the mapping from individual r_*
+    # table rows to the overall union (sum type) rows.
+    my $nullcols_main = nullcols(qw(
+        flight::integer job status oidents
+        started::integer rest_started::integer finished::integer
+    ));
+    my $nullcols_tasks = nullcols(qw(
+        taskid::integer type refkey username comment
+    ));
+    my $nullcols_elided = nullcols(qw(
+        elided::integer elided_sigil
+    ));
+
+    $shareq_txt .= <<END;
+      q2 AS
+      (SELECT q.*,
+	      (SELECT started
+		FROM steps s
+	       WHERE s.flight = q.flight
+		 AND s.job    = q.job 
+		 AND s.stepno = q.stepno
+		 AND oisprep)                    AS prep_started,
+	      (SELECT started
+		 FROM steps s
+		WHERE s.flight = q.flight
+		  AND s.job    = q.job
+		  AND s.stepno = q.stepno
+		  AND NOT oisprep)               AS rest_started,
+	      (SELECT max(finished)
+		 FROM steps s
+		WHERE s.flight = q.flight
+		  AND s.job    = q.job)          AS finished
+	FROM Q
+        ORDER BY q.tident),
+
+      r_main AS
+      (SELECT tident, hostname,
+              bool_or(olive)                     AS olive,
+              1                                  AS kind_sort,
+              flight, job,
+	      (SELECT status
+		 FROM jobs
+		WHERE jobs.flight = q2.flight
+		  AND jobs.job    = q2.job)      AS status,
+	      string_agg(DISTINCT oident,',')    AS oidents,
+	      min(prep_started)                  AS prep_started,
+	      min(rest_started)                  AS rest_started,
+	      max(finished)                      AS finished,
+	      $nullcols_tasks,
+	      $nullcols_elided,
+              NULL::integer                      AS sort_index
+	 FROM q2
+     GROUP BY tident, hostname, flight, job),
+
+      r_tasks AS
+      (SELECT tident, hostname, olive,
+              0                                  AS kind_sort,
+              $nullcols_main,
+              taskid, type, refkey, username, comment,
+              $nullcols_elided,
+              sort_index
+         FROM q_tasks NATURAL LEFT JOIN tasks),
+
+      r_elided AS
+      (SELECT tident, hostname, FALSE as olive,
+              2                                  AS kind_sort,
+              $nullcols_main,
+              $nullcols_tasks,
+              count                              AS elided,
+              sigil                              AS elided_sigil,
+              sort_index
+         FROM q_elided)
+
+-- The result row is effectively a sum type.  SQL doesn't have those.
+-- We just pile all the columns of the disjoint types together;
+-- some of them will be null for some variants.  The perl code can
+-- easily figure out which of the unioned CTEs a row came from.
+
+       SELECT * FROM r_main    UNION
+       SELECT * FROM r_tasks   UNION
+       SELECT * FROM r_elided
+     ORDER BY tident, hostname,
+	      kind_sort,
+	      finished, prep_started, rest_started, flight, job, oidents,
+	      sort_index
+END
+
+    print DEBUG "PREPARING SHAREQ\n";
+    my $shareq = db_prepare($shareq_txt);
+    print DEBUG Dumper(\@shareq_params);
+    $shareq->execute(@shareq_params);
+
+    my $share_any;
+    my $altcolour=1;
+    while (my $srow = $shareq->fetchrow_hashref()) {
+	print DEBUG "SHARE SROW ".Dumper($srow);
+	print H <<END if !$share_any++;
+<h2>Task(s) which might have affected this job's host(s)</h2>
+<p>
+<table rules="all"><tr>
+<th>role<br>(here)</td>
+<th>hostname</td>
+<th>rel.</td><!-- share reuse unknown -->
+<th>flight</td>
+<th>job</td>
+<th>role(s)<br>(there)</td>
+<th>install / prep.<br>started</td>
+<th>use</br>started</td>
+<th>last step<br>ended</td>
+<th>job<br>status</td>
+</tr>
+END
+	my $bgcolour = report_altcolour($altcolour ^= 1);
+	printf H <<END, $bgcolour, map { encode_entities $_ }
+<tr %s>
+<td align="center">%s</td>
+<td align="center"><a href="%s">%s</a></td>
+END
+	  $srow->{tident},
+	  "$c{ResultsHtmlPubBaseUrl}/host/$srow->{hostname}.html",
+	  $srow->{hostname};
+	my $rel = $srow->{olive} ?
+	  "<td align=\"center\" bgcolor=\"$red\">share</td>"
+	  : $srow->{prep_started} ?
+	  "<td align=\"center\" bgcolor=\"$purple\">prep.</td>"
+	  :
+	  "<td align=\"center\">reuse</td>";
+        if (defined $srow->{flight}) {
+	    my $furl = "$c{ReportHtmlPubBaseUrl}/$srow->{flight}/";
+	    my $jurl = "$furl/$srow->{job}/info.html";
+	    if ($srow->{flight} != $specflight) {
+		printf H <<END, $rel, map { encode_entities $_ }
+%s
+<td align="right"><a href="%s">%s</a></td>
+<td><a href="%s">%s</a></td>
+END
+		  $furl, $srow->{flight},
+		  $jurl, $srow->{job};
+	    } elsif ($srow->{job} ne $job) {
+		printf H <<END, $rel, map { encode_entities $_ }
+%s
+<td align="center">this</td>
+<td><a href="%s">%s</a></td>
+END
+		  $jurl, $srow->{job};
+	    } else {
+		printf H <<END;
+<td></td>
+<td align="center">this</td>
+<td align="center">this</td>
+END
+	    }
+	    printf H <<END,
+<td align="center">%s</td>
+<td>%s</td><td>%s</td><td>%s</td>
+END
+	      encode_entities($srow->{oidents}),
+	      map { $_ ? show_abs_time($_) : '' }
+	      $srow->{prep_started},
+	      $srow->{rest_started},
+	      !$srow->{olive} && $srow->{finished};
+	    my $info = report_run_getinfo($srow);
+	    print H <<END, 
+<td $info->{ColourAttr}>$info->{Content}</td>
+END
+	} elsif (defined $srow->{elided}) {
+	    printf H <<END, $srow->{elided};
+<td colspan="8" align="center">%d earlier job(s) elided</td>
+END
+	} elsif (defined $srow->{elided_sigil}) {
+	    printf H <<END;
+<td bgcolor="$yellow" colspan="8" align="center">
+this job incomplete, unknown number of other jobs elided
+</td>
+END
+	} elsif (defined $srow->{taskid}) {
+	    printf H <<END, $rel, map { encode_entities $_ }
+%s
+<td bgcolor="$yellow" colspan="7" align="center">?%s: %s</td>
+END
+	      $srow->{taskid},
+	      report_rogue_task_description($srow);
+	} else {
+	    confess Dumper($srow)." ?";
+	}
+	print H <<END;
+</tr>
+END
+    }
+    print H <<END if $share_any;
+</table>
 END
 
     print H <<END;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 73/82] host reuse: sg-run-job: Reanme post-test-ok parameter
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (71 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 72/82] resource reporting: Report host reuse/sharing in job report Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 74/82] host reuse: ts-host-reuse: Prepare for argument handling Ian Jackson
                   ` (9 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

This is more accurate.

No overall functional change.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-run-job    | 2 +-
 ts-host-reuse | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 1e2fcfee..2feb67d9 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -124,7 +124,7 @@ proc run-job {job} {
        set ok 0
     }
 
-    if {$ok} { per-host-ts .  =            { ts-host-reuse post-test }    }
+    if {$ok} { per-host-ts .  =            { ts-host-reuse post-test-ok } }
     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 85beb51e..aad45bdd 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -152,7 +152,7 @@ sub act_start_test () {
     host_shared_mark_ready($ho, $sharetype, \%oldstate, 'mid-test');
 }
 
-sub act_post_test () {
+sub act_post_test_ok () {
     compute_test_sharetype();
     $ho = selecthost($whhost);
     return unless $ho->{Shared};
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 74/82] host reuse: ts-host-reuse: Prepare for argument handling
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (72 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 73/82] host reuse: sg-run-job: Reanme post-test-ok parameter Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 75/82] host reuse: New protocol between sg-run-job and ts-host-reuse Ian Jackson
                   ` (8 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

No functional change.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 ts-host-reuse | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ts-host-reuse b/ts-host-reuse
index aad45bdd..21d77500 100755
--- a/ts-host-reuse
+++ b/ts-host-reuse
@@ -48,9 +48,9 @@ use Osstest::TestSupport;
 
 tsreadconfig();
 
-die unless @ARGV==2;
-
-our ($action, $whhost) = @ARGV;
+die unless @ARGV>=2;
+our $action = shift @ARGV;
+our $whhost = shift @ARGV;
 
 our $ho;
 
@@ -137,6 +137,7 @@ sub noop_if_playing () {
 #---------- actions ----------
 
 sub act_prealloc () {
+    die if @ARGV;
     noop_if_playing();
     compute_test_sharetype();
     $ho = selecthost($whhost, undef, 1);
@@ -145,6 +146,7 @@ sub act_prealloc () {
 }
 
 sub act_start_test () {
+    die if @ARGV;
     compute_test_sharetype();
     $ho = selecthost($whhost);
     return unless $ho->{Shared};
@@ -153,6 +155,7 @@ sub act_start_test () {
 }
 
 sub act_post_test_ok () {
+    die if @ARGV;
     compute_test_sharetype();
     $ho = selecthost($whhost);
     return unless $ho->{Shared};
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 75/82] host reuse: New protocol between sg-run-job and ts-host-reuse
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (73 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 74/82] host reuse: ts-host-reuse: Prepare for argument handling Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 76/82] sg-report-flight: Reformat slightly Ian Jackson
                   ` (7 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

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@xenproject.org>
---
 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



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 76/82] sg-report-flight: Reformat slightly
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (74 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 75/82] host reuse: New protocol between sg-run-job and ts-host-reuse Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 77/82] sg-report-flight: Improvements to other job (share/reuse) reporting Ian Jackson
                   ` (6 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

This is more regular and will make the next commit easier to
understand.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-report-flight | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sg-report-flight b/sg-report-flight
index 0413a730..7dc218cf 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1472,9 +1472,11 @@ END
 	  $srow->{tident},
 	  "$c{ResultsHtmlPubBaseUrl}/host/$srow->{hostname}.html",
 	  $srow->{hostname};
-	my $rel = $srow->{olive} ?
+	my $rel =
+	  $srow->{olive} ?
 	  "<td align=\"center\" bgcolor=\"$red\">share</td>"
-	  : $srow->{prep_started} ?
+	  :
+	  $srow->{prep_started} ?
 	  "<td align=\"center\" bgcolor=\"$purple\">prep.</td>"
 	  :
 	  "<td align=\"center\">reuse</td>";
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 77/82] sg-report-flight: Improvements to other job (share/reuse) reporting
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (75 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 76/82] sg-report-flight: Reformat slightly Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 78/82] flight other job reporting: Put nulls last in the report Ian Jackson
                   ` (5 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

* Prefer to show "prep" (purple) rather than "share".
* Show our own relationship, in particular to show if it was prep.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-report-flight | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/sg-report-flight b/sg-report-flight
index 7dc218cf..2a79db13 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1473,12 +1473,12 @@ END
 	  "$c{ResultsHtmlPubBaseUrl}/host/$srow->{hostname}.html",
 	  $srow->{hostname};
 	my $rel =
-	  $srow->{olive} ?
-	  "<td align=\"center\" bgcolor=\"$red\">share</td>"
-	  :
 	  $srow->{prep_started} ?
 	  "<td align=\"center\" bgcolor=\"$purple\">prep.</td>"
 	  :
+	  $srow->{olive} ?
+	  "<td align=\"center\" bgcolor=\"$red\">share</td>"
+	  :
 	  "<td align=\"center\">reuse</td>";
         if (defined $srow->{flight}) {
 	    my $furl = "$c{ReportHtmlPubBaseUrl}/$srow->{flight}/";
@@ -1499,8 +1499,10 @@ END
 END
 		  $jurl, $srow->{job};
 	    } else {
-		printf H <<END;
-<td></td>
+		confess unless $rel =~ m{([0-9a-z. ]+)\</td\>$};
+		$rel = '<td></td>' if $1 eq 'reuse';
+		printf H <<END, $rel;
+%s
 <td align="center">this</td>
 <td align="center">this</td>
 END
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 78/82] flight other job reporting: Put nulls last in the report
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (76 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 77/82] sg-report-flight: Improvements to other job (share/reuse) reporting Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 79/82] flight other job reporting: Further improvements to ordering Ian Jackson
                   ` (4 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

Cosmetic change only, but this makes the results easier to understand.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-report-flight | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sg-report-flight b/sg-report-flight
index 2a79db13..d8829932 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1434,7 +1434,10 @@ END
        SELECT * FROM r_elided
      ORDER BY tident, hostname,
 	      kind_sort,
-	      finished, prep_started, rest_started, flight, job, oidents,
+              prep_started NULLS LAST,
+              rest_started NULLS LAST,
+	      finished NULLS LAST,
+              flight, job, oidents,
 	      sort_index
 END
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 79/82] flight other job reporting: Further improvements to ordering
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (77 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 78/82] flight other job reporting: Put nulls last in the report Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 80/82] tsreadconfig: Change misleading "setting" message Ian Jackson
                   ` (3 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Jackson

From: Ian Jackson <ian.jackson@eu.citrix.com>

We want to definitely put these NULLs last.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-report-flight | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sg-report-flight b/sg-report-flight
index d8829932..8f99bb69 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1389,7 +1389,9 @@ END
       r_main AS
       (SELECT tident, hostname,
               bool_or(olive)                     AS olive,
-              1                                  AS kind_sort,
+              CASE WHEN min(prep_started)
+                   IS NOT NULL
+                   THEN 1 ELSE 3 END             AS kind_sort,
               flight, job,
 	      (SELECT status
 		 FROM jobs
@@ -1416,7 +1418,9 @@ END
 
       r_elided AS
       (SELECT tident, hostname, FALSE as olive,
-              2                                  AS kind_sort,
+              CASE WHEN count
+                   IS NOT NULL
+                   THEN 2 ELSE 4 END             AS kind_sort,
               $nullcols_main,
               $nullcols_tasks,
               count                              AS elided,
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 80/82] tsreadconfig: Change misleading "setting" message
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (78 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 79/82] flight other job reporting: Further improvements to ordering Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 81/82] sg-report-flight: Sharing reports: more task finished info Ian Jackson
                   ` (2 subsequent siblings)
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

These are the *existing* runvars and it is confusing that we print
"setting" for them.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 Osstest/TestSupport.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 163862f8..f2d8a0e1 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -210,7 +210,7 @@ END
         while ($row= $q->fetchrow_hashref()) {
             $r{ $row->{name} }= $row->{val};
 	    $r_notsynth{ $row->{name} }= !$row->{synth};
-            logm("setting $row->{name}=$row->{val}");
+            logm("runvar $row->{name}=$row->{val}");
         }
         $q->finish();
     });
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 81/82] sg-report-flight: Sharing reports: more task finished info
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (79 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 80/82] tsreadconfig: Change misleading "setting" message Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:00 ` [OSSTEST PATCH 82/82] sg-report-flight: Word-wrapping improvements to job and step names Ian Jackson
  2020-10-07 18:22 ` [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

Other steps from jobs affecting this host either started after we are
running, and therefore didn't affect the stuff we're reporting, or
already in the db.  Furthermore, any such effects for steps which have
finished must have completed by the max finished time  But if there
are unfinished steps, we don't know the finish time.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-report-flight | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sg-report-flight b/sg-report-flight
index 8f99bb69..33f953ca 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1355,7 +1355,8 @@ END
     # table rows to the overall union (sum type) rows.
     my $nullcols_main = nullcols(qw(
         flight::integer job status oidents
-        started::integer rest_started::integer finished::integer
+        started::integer rest_started::integer
+        finished::integer all_finished::boolean
     ));
     my $nullcols_tasks = nullcols(qw(
         taskid::integer type refkey username comment
@@ -1382,7 +1383,11 @@ END
 	      (SELECT max(finished)
 		 FROM steps s
 		WHERE s.flight = q.flight
-		  AND s.job    = q.job)          AS finished
+		  AND s.job    = q.job)          AS finished,
+	      (SELECT every(finished IS NOT NULL)
+		 FROM steps s
+		WHERE s.flight = q.flight
+		  AND s.job    = q.job)          AS all_finished
 	FROM Q
         ORDER BY q.tident),
 
@@ -1401,6 +1406,7 @@ END
 	      min(prep_started)                  AS prep_started,
 	      min(rest_started)                  AS rest_started,
 	      max(finished)                      AS finished,
+	      every(all_finished)                AS all_finished,
 	      $nullcols_tasks,
 	      $nullcols_elided,
               NULL::integer                      AS sort_index
@@ -1466,7 +1472,7 @@ END
 <th>role(s)<br>(there)</td>
 <th>install / prep.<br>started</td>
 <th>use</br>started</td>
-<th>last step<br>ended</td>
+<th>last relevant step<br>ended</td>
 <th>job<br>status</td>
 </tr>
 END
@@ -1522,7 +1528,7 @@ END
 	      map { $_ ? show_abs_time($_) : '' }
 	      $srow->{prep_started},
 	      $srow->{rest_started},
-	      !$srow->{olive} && $srow->{finished};
+	      (!$srow->{olive} || $srow->{all_finished}) && $srow->{finished};
 	    my $info = report_run_getinfo($srow);
 	    print H <<END, 
 <td $info->{ColourAttr}>$info->{Content}</td>
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [OSSTEST PATCH 82/82] sg-report-flight: Word-wrapping improvements to job and step names
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (80 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 81/82] sg-report-flight: Sharing reports: more task finished info Ian Jackson
@ 2020-10-07 18:00 ` Ian Jackson
  2020-10-07 18:22 ` [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

Use <wbr>.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 sg-report-flight | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/sg-report-flight b/sg-report-flight
index 33f953ca..a07e03cb 100755
--- a/sg-report-flight
+++ b/sg-report-flight
@@ -1185,6 +1185,15 @@ sub nullcols {
     join ", ", map { m/::/ ? "NULL::$' as $`" : "NULL as $_" } @_;
 }
 
+sub encode_with_wbrs ($) {
+    my ($s) = @_;
+    my $re = qr{[-/]};
+    join '', map {
+	my $b = s{^$re}{} ? ('<wbr>'. $& . '&#8288;') : '';
+	$b.encode_entities($_);
+    } split m{(?=$re)}, $s;
+}
+
 sub htmloutjob ($$) {
     my ($fi,$job) = @_;
     return unless defined $htmldir;
@@ -1666,11 +1675,9 @@ END
     print H "</th>\n";
 
     foreach my $col (@cols) {
-        my $th= $col;
-        $th =~ s/\-/ $&/g;
         print H "<th>";
         print H "<a href=\"".encode_entities($col)."/$htmlleaf\">";
-        print H encode_entities($th);
+        print H encode_with_wbrs($col);
         print H "</a>";
         print H "</th>";
     }
@@ -1726,7 +1733,8 @@ END
 	    next if $this[1] == $worst[1] && $ei->{Step}{status} ne 'pass';
 	    @worst=@this;
 	    push @worst,
-	        encode_entities("$ei->{Step}{stepno}. $ei->{Step}{testid}");
+	      encode_entities("$ei->{Step}{stepno}. ").
+	      encode_with_wbrs($ei->{Step}{testid});
 	}
 	push @worstrow1, "<td ",$worst[2],">",$worst[3],"</td>";
 	push @worstrow2, "<td ",$worst[2],">",$worst[0],"</td>";
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 85+ messages in thread

* Re: [OSSTEST PATCH 00/82] Reuse test hosts
  2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
                   ` (81 preceding siblings ...)
  2020-10-07 18:00 ` [OSSTEST PATCH 82/82] sg-report-flight: Word-wrapping improvements to job and step names Ian Jackson
@ 2020-10-07 18:22 ` Ian Jackson
  82 siblings, 0 replies; 85+ messages in thread
From: Ian Jackson @ 2020-10-07 18:22 UTC (permalink / raw)
  To: xen-devel

Ian Jackson writes ("[OSSTEST PATCH 00/82] Reuse test hosts"):
> This series arranges to save on host setup by reusing a test host, if
> the previous test passed.  Care is taken to make sure that a host is
> only reused in this way if the new test would have set it up
> identically.
> 
> I have had this branch in preparation since November 2017...

Many of the earlier commits in this series had my Citrix address as
the author.  My setup was not configured to deliver these mails
correctly (ie, via the Citrix mail servers), so those messages will
generally have been blocked as spam.  Additionally, even the mails
which were From: iwj@xenproject were delivered via my colo mail server
which is not really right.  So some of those might also get blocked.

I don't propose to resend the mailbomb.  You can find the complete
series here:
  https://xenbits.xen.org/gitweb/?p=people/iwj/osstest.git;a=shortlog;h=refs/heads/test-host-reuse-v1
  https://xenbits.xen.org/git-http/people/iwj/osstest.git#test-host-reuse-v1

It's in osstest pretest now.

Ian.


^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [OSSTEST PATCH 16/82] abolish "kernkind"; desupport non-pvops kernels
  2020-10-07 17:59 ` [OSSTEST PATCH 16/82] abolish "kernkind"; desupport non-pvops kernels Ian Jackson
@ 2020-10-13  9:29   ` Wei Liu
  0 siblings, 0 replies; 85+ messages in thread
From: Wei Liu @ 2020-10-13  9:29 UTC (permalink / raw)
  To: Ian Jackson
  Cc: xen-devel, Ian Jackson, Boris Ostrovsky, Juergen Gross,
	Stefano Stabellini, Konrad Rzeszutek Wilk, Roger Pau Monné,
	Wei Liu, Paul Durrant, Oleksandr Andrushchenko, Andrew Cooper,
	Olivier Lambert

On Wed, Oct 07, 2020 at 06:59:18PM +0100, Ian Jackson wrote:
> From: Ian Jackson <ian.jackson@eu.citrix.com>
> 
> This was for distinguishing the old-style Xenolinux kernels from pvops
> kernels.
> 
> We have not actually tested any non-pvops kernels for a very very long
> time.  Delete this now because the runvar is slightly in the way of
> test host reuse.
> 
> (Sorry for the wide CC but it seems better to make sure anyone who
> might object can do so.)

No objection from me FWIW.

Wei.


^ permalink raw reply	[flat|nested] 85+ messages in thread

end of thread, other threads:[~2020-10-13  9:29 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 17:59 [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 01/82] ms-queuedaemon: Update for newer Tcl's socket channel ids Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 02/82] Executive.pm planner: fix typo Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 03/82] README.planner: Document magic job hostflags Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 04/82] sg-run-job: Minor whitespace (formatting) changes Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 05/82] sg-run-job: Improve some internal API docs Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 06/82] show_abs_time: Represent undef $timet as <undef> Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 07/82] ts-hosts-allocate-Executive: Add a comment about a warning Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 08/82] host reuse: ms-planner: Bring some variables forward Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 09/82] host reuse: ms-planner: Do not show reuse as shared in the plan Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 10/82] hsot reuse: ms-planner: Abbreviate reporting of test shares Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 11/82] cr-publish-flight-logs: Fix abs_time calls Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 12/82] target setup refactoring: Move target_kernkind_check Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 13/82] target setup refactoring: Move target_kernkind_console_inittab Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 14/82] target setup refactoring: Merge target_kernkind_* Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 15/82] target setup refactoring: Add a doc comment Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 16/82] abolish "kernkind"; desupport non-pvops kernels Ian Jackson
2020-10-13  9:29   ` Wei Liu
2020-10-07 17:59 ` [OSSTEST PATCH 17/82] Debian: osstest-erase-other-disks: Slightly guard against races Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 18/82] host allocation: Remove some unnecessary definedness tests Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 19/82] host allocation: Executive: Honour $xparams{InfraPriority} Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 20/82] ts-hosts-allocate-Executive: Fix handling of failed preps for same sharing Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 21/82] sg-run-job: support +! for *only* adding things to TESTID Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 22/82] sg-run-job: Use +! in per-host-ts implementation Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 23/82] db_retry: Make the sleeps random and increasing Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 24/82] host allocation: *_shared_mark_ready: Allow other states Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 25/82] host allocation: *_shared_mark_ready: Make $sharetype check optional Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 26/82] host allocation: selecthost: allow sort-of-selection of prospective hosts Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 27/82] host allocation: *_shared_mark_ready: allow alternative $oldtypes Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 28/82] host allocation: Support new reuse-* magic hostflag Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 29/82] host allocation: *_shared_mark_ready: Only prod when $newstate is ready Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 30/82] plan_search: Break out $share_compat_ok Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 31/82] plan_search: Improve debugging of $share_compat_ok->() Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 32/82] plan_search: Use plan's Wear information rather than tracking it ourselves Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 33/82] plan search: Move $share_compat_ok further up the file Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 34/82] plan_search: Track last sharing state to determine $share_reuse Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 35/82] resource reporting: Print username when listing "rogue tasks" Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 36/82] resource reporting, nfc: Break out report_rogue_task_description Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 37/82] ts-hosts-allocate-Executive: Better message for hosts abandoned mid-test Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 38/82] ts-host-reuse: New script, to do reuse state changes Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 39/82] ts-host-reuse: tolerate unremoveable lv Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 40/82] ts-host-reuse: Do not depend on bios Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 41/82] ts-host-reuse: Add some missing runvars to the host sharing control Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 42/82] host allocation: selecthost(): Support @IDENT for reuse Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 43/82] ts-hosts-allocate-Executive print sharing info in debug output Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 44/82] sg-run-job: New @ iffail tag for prep tasks Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 45/82] sg-run-job: Detect improper use of @ iffail with run-ts Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 46/82] shared/reuse: Use @ for ts-xen-build-prep Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 47/82] shared/reuse: Use @ for ts-host-install Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 48/82] shared/reuse: Use @ for freebsd host prep Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 49/82] host reuse: sg-run-job: per-host prep: Use @ for per-host-ts Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 50/82] shared/reuse: Rely on @ for ts-host-ping-check Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 51/82] host reuse: Reuse test hosts within a flight Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 52/82] host allocation: Group jobs by their reuse parameters Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 53/82] host reuse: Jiggle the infra-priority a bit, within a flight Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 54/82] host reuse: Use literal for the hosts_infraprioritygroup runvar Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 55/82] host reuse: Bump host share reuse bonus Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 56/82] subst_netboot_template: Do not use all of %r Ian Jackson
2020-10-07 17:59 ` [OSSTEST PATCH 57/82] TestSupport: Provide runvar_is_synth Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 58/82] runvar access: Introduce access control machinery Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 59/82] runvar access: Provide runvar_glob Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 60/82] runvar access: Use runvar_glob for dmrestrict runvar search Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 61/82] runvar access: Introduce sharing_for_build Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 62/82] runvar access: Introduce effects_gone_before_share_reuse Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 63/82] test host reuse: Switch to principled sharing scope runvar scheme Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 64/82] hsot reuse: Hash the share type Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 65/82] hsot reuse: Make share type hash more easily greppable Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 66/82] host lifecycle: Machinery, db, for tracking relevant events Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 67/82] host lifecycle: Fix detection of concurrent jobs Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 68/82] host lifecycle: Prevent referential integrity violation Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 69/82] host lifecycle: Record lifecycle in db and runvar Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 70/82] sg-report-flight: Refactor runvar access Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 71/82] resource reporting, nfc: split a here document Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 72/82] resource reporting: Report host reuse/sharing in job report Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 73/82] host reuse: sg-run-job: Reanme post-test-ok parameter Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 74/82] host reuse: ts-host-reuse: Prepare for argument handling Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 75/82] host reuse: New protocol between sg-run-job and ts-host-reuse Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 76/82] sg-report-flight: Reformat slightly Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 77/82] sg-report-flight: Improvements to other job (share/reuse) reporting Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 78/82] flight other job reporting: Put nulls last in the report Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 79/82] flight other job reporting: Further improvements to ordering Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 80/82] tsreadconfig: Change misleading "setting" message Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 81/82] sg-report-flight: Sharing reports: more task finished info Ian Jackson
2020-10-07 18:00 ` [OSSTEST PATCH 82/82] sg-report-flight: Word-wrapping improvements to job and step names Ian Jackson
2020-10-07 18:22 ` [OSSTEST PATCH 00/82] Reuse test hosts Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.