Reuse test hosts
cover 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...
Signature · 1 line
2.20.1
PATCH 1/82 ms-queuedaemon: Update for newer Tcl's socket channel ids
From: Ian Jackson <[email protected]>
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.
--- ms-queuedaemon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
ms-queuedaemon +5 -5
@@ -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 " " } }
Signature · 1 line
2.20.1
PATCH 2/82 Executive.pm planner: fix typo
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- Osstest/Executive.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/Executive.pm +1 -1
@@ -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: {
Signature · 1 line
2.20.1
PATCH 3/82 README.planner: Document magic job hostflags
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- README.planner | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
README.planner +60 -0
@@ -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 -------
Signature · 1 line
2.20.1
PATCH 4/82 sg-run-job: Minor whitespace (formatting) changes
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
No functional change.
--- sg-run-job | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sg-run-job +4 -4
@@ -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} }
Signature · 1 line
2.20.1
PATCH 5/82 sg-run-job: Improve some internal API docs
In reply to Ian Jackson--- sg-run-job | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sg-run-job +4 -4
@@ -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. #
Signature · 1 line
2.20.1
PATCH 6/82 show_abs_time: Represent undef $timet as <undef>
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest.pm | 1 + 1 file changed, 1 insertion(+)
Osstest.pm +1 -0
@@ -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; }
Signature · 1 line
2.20.1
PATCH 7/82 ts-hosts-allocate-Executive: Add a comment about a warning
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- ts-hosts-allocate-Executive | 4 ++++ 1 file changed, 4 insertions(+)
ts-hosts-allocate-Executive +4 -0
@@ -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
Signature · 1 line
2.20.1
PATCH 8/82 host reuse: ms-planner: Bring some variables forward
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ms-planner | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
ms-planner +6 -5
@@ -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".
Signature · 1 line
2.20.1
PATCH 9/82 host reuse: ms-planner: Do not show reuse as shared in the plan
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ms-planner | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
ms-planner +5 -2
@@ -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") :
Signature · 1 line
2.20.1
PATCH 10/82 hsot reuse: ms-planner: Abbreviate reporting of test shares
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- ms-planner | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ms-planner +3 -1
@@ -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};
Signature · 1 line
2.20.1
PATCH 11/82 cr-publish-flight-logs: Fix abs_time calls
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
There was a missing space in these messages, since they were introduced in 31b7cae19fe1
timing traces: cr-publish-flight-logs: Report more progress
--- cr-publish-flight-logs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cr-publish-flight-logs +1 -1
@@ -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 $!;
Signature · 1 line
2.20.1
PATCH 12/82 target setup refactoring: Move target_kernkind_check
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ts-debian-fixup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ts-debian-fixup +1 -1
@@ -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));
Signature · 1 line
2.20.1
PATCH 13/82 target setup refactoring: Move target_kernkind_console_inittab
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ts-debian-fixup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ts-debian-fixup +2 -2
@@ -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));
Signature · 1 line
2.20.1
PATCH 14/82 target setup refactoring: Merge target_kernkind_*
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
Combine these two functions. Rename them to a name which doesn't mention "kernkind".
No functional change.
--- Osstest/Debian.pm | 3 +-- Osstest/TestSupport.pm | 11 ++++------- ts-debian-fixup | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-)
Osstest/Debian.pm +1 -2
@@ -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');
Osstest/TestSupport.pm +4 -7
@@ -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');
ts-debian-fixup +1 -2
@@ -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));
Signature · 1 line
2.20.1
PATCH 15/82 target setup refactoring: Add a doc comment
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- Osstest/TestSupport.pm | 3 +++ 1 file changed, 3 insertions(+)
Osstest/TestSupport.pm +3 -0
@@ -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);
Signature · 1 line
2.20.1
PATCH 16/82 abolish "kernkind"; desupport non-pvops kernels
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/TestSupport.pm | 9 ++------- README | 2 +- make-hosts-flight | 1 - mfi-common | 7 ++----- 4 files changed, 5 insertions(+), 14 deletions(-)
Osstest/TestSupport.pm +2 -7
@@ -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');
README +1 -1
@@ -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
make-hosts-flight +0 -1
@@ -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
mfi-common +2 -5
@@ -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 "
Signature · 1 line
2.20.1
Re: [OSSTEST PATCH 16/82] abolish "kernkind"; desupport non-pvops kernels
Quoted 11 lines · Ian Jackson
From: Ian Jackson <[email protected]>
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.
PATCH 17/82 Debian: osstest-erase-other-disks: Slightly guard against races
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/Debian.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Osstest/Debian.pm +2 -2
@@ -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
Signature · 1 line
2.20.1
PATCH 18/82 host allocation: Remove some unnecessary definedness tests
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
$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.
--- Osstest/Executive.pm | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
Osstest/Executive.pm +2 -9
@@ -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) {
Signature · 1 line
2.20.1
PATCH 19/82 host allocation: Executive: Honour $xparams{InfraPriority}
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/Executive.pm | 1 + 1 file changed, 1 insertion(+)
Osstest/Executive.pm +1 -0
@@ -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) {
Signature · 1 line
2.20.1
PATCH 20/82 ts-hosts-allocate-Executive: Fix handling of failed preps for same sharing
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ts-hosts-allocate-Executive | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
ts-hosts-allocate-Executive +5 -6
@@ -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; } }
Signature · 1 line
2.20.1
PATCH 21/82 sg-run-job: support +! for *only* adding things to TESTID
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- sg-run-job | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
sg-run-job +9 -1
@@ -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 } }
Signature · 1 line
2.20.1
PATCH 22/82 sg-run-job: Use +! in per-host-ts implementation
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
This makes this slightly clearer, even more so in a moment.
No functional change.
--- sg-run-job | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
sg-run-job +4 -5
@@ -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] }
Signature · 1 line
2.20.1
PATCH 23/82 db_retry: Make the sleeps random and increasing
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
When there's a thundering herd, this can run out of retries.
--- Osstest.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Osstest.pm +7 -4
@@ -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; }
Signature · 1 line
2.20.1
PATCH 24/82 host allocation: *_shared_mark_ready: Allow other states
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/Executive.pm | 19 +++++++++++-------- Osstest/JobDB/Executive.pm | 5 +++-- Osstest/TestSupport.pm | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-)
Osstest/Executive.pm +11 -8
@@ -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"); } }
Osstest/JobDB/Executive.pm +3 -2
@@ -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
Osstest/TestSupport.pm +3 -3
@@ -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 ($) {
Signature · 1 line
2.20.1
PATCH 25/82 host allocation: *_shared_mark_ready: Make $sharetype check optional
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/Executive.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Osstest/Executive.pm +9 -5
@@ -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);
Signature · 1 line
2.20.1
Ian Jackson writes ("[OSSTEST PATCH 00/82] Reuse test hosts"):
Quoted 6 lines
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.
PATCH 26/82 host allocation: selecthost: allow sort-of-selection of prospective hosts
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/TestSupport.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Osstest/TestSupport.pm +6 -4
@@ -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/^(.*)://) {
Signature · 1 line
2.20.1
PATCH 27/82 host allocation: *_shared_mark_ready: allow alternative $oldtypes
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
$oldtype may now be a hashref, where keys mapping to truthy values are permitted for the sharetype precondition.
No functional change for existing callers.
--- Osstest/Executive.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Osstest/Executive.pm +4 -2
@@ -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=?
Signature · 1 line
2.20.1
PATCH 28/82 host allocation: Support new reuse-* magic hostflag
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
This is like share-* except it has different MaxTasks and MaxWear parameters.
--- README.planner | 7 +++++++ ts-hosts-allocate-Executive | 15 +++++++++++++++ 2 files changed, 22 insertions(+)
README.planner +7 -0
@@ -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
ts-hosts-allocate-Executive +15 -0
@@ -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};
Signature · 1 line
2.20.1
PATCH 29/82 host allocation: *_shared_mark_ready: Only prod when $newstate is ready
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- Osstest/Executive.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
Osstest/Executive.pm +9 -7
@@ -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");
Signature · 1 line
2.20.1
PATCH 30/82 plan_search: Break out $share_compat_ok
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
No functional change.
--- Osstest/Executive.pm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
Osstest/Executive.pm +15 -9
@@ -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");
Signature · 1 line
2.20.1
PATCH 31/82 plan_search: Improve debugging of $share_compat_ok->()
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
No change other than to debugging output.
--- Osstest/Executive.pm | 7 +++++++ 1 file changed, 7 insertions(+)
Osstest/Executive.pm +7 -0
@@ -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; };
Signature · 1 line
2.20.1
PATCH 32/82 plan_search: Use plan's Wear information rather than tracking it ourselves
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
There is no reason not to use this information from the plan. Not computing it ourselves saves some confusing logic here.
--- Osstest/Executive.pm | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
Osstest/Executive.pm +4 -12
@@ -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;
Signature · 1 line
2.20.1
PATCH 33/82 plan search: Move $share_compat_ok further up the file
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
We are going to want to use this outside the loop.
No functional change.
--- Osstest/Executive.pm | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
Osstest/Executive.pm +17 -17
@@ -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
Signature · 1 line
2.20.1
PATCH 34/82 plan_search: Track last sharing state to determine $share_reuse
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.)
--- Osstest/Executive.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Osstest/Executive.pm +7 -1
@@ -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; }
Signature · 1 line
2.20.1
PATCH 35/82 resource reporting: Print username when listing "rogue tasks"
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- ms-planner | 1 + 1 file changed, 1 insertion(+)
ms-planner +1 -0
@@ -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},
Signature · 1 line
2.20.1
PATCH 36/82 resource reporting, nfc: Break out report_rogue_task_description
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- Osstest/Executive.pm | 14 ++++++++++++++ ms-planner | 6 +----- 2 files changed, 15 insertions(+), 5 deletions(-)
Osstest/Executive.pm +14 -0
@@ -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) = @_;
ms-planner +1 -5
@@ -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},
Signature · 1 line
2.20.1
PATCH 37/82 ts-hosts-allocate-Executive: Better message for hosts abandoned mid-test
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- ts-hosts-allocate-Executive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ts-hosts-allocate-Executive +1 -1
@@ -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; } }
Signature · 1 line
2.20.1
PATCH 38/82 ts-host-reuse: New script, to do reuse state changes
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ts-host-reuse | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100755 ts-host-reuse
ts-host-reuse new file +163 -0
@@ -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"}();
Signature · 1 line
2.20.1
PATCH 39/82 ts-host-reuse: tolerate unremoveable lv
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
It might be a symlink in the pair tests.
--- ts-host-reuse | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ts-host-reuse +1 -1
@@ -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
Signature · 1 line
2.20.1
PATCH 40/82 ts-host-reuse: Do not depend on bios
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ts-host-reuse | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ts-host-reuse +1 -1
@@ -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);
Signature · 1 line
2.20.1
PATCH 41/82 ts-host-reuse: Add some missing runvars to the host sharing control
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
Add some missing runvars to the host sharing control.
--- ts-host-reuse | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ts-host-reuse +2 -1
@@ -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);
Signature · 1 line
2.20.1
PATCH 42/82 host allocation: selecthost(): Support @IDENT for reuse
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/TestSupport.pm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +24 -2
@@ -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; }
Signature · 1 line
2.20.1
PATCH 43/82 ts-hosts-allocate-Executive print sharing info in debug output
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- ts-hosts-allocate-Executive | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ts-hosts-allocate-Executive +3 -1
@@ -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: ".
Signature · 1 line
2.20.1
PATCH 44/82 sg-run-job: New @ iffail tag for prep tasks
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
Currently no users sites, so no functional change.
--- sg-run-job | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sg-run-job +10 -4
@@ -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] }
Signature · 1 line
2.20.1
PATCH 45/82 sg-run-job: Detect improper use of @ iffail with run-ts
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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...
--- sg-run-job | 3 +++ 1 file changed, 3 insertions(+)
sg-run-job +3 -0
@@ -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 }
Signature · 1 line
2.20.1
PATCH 46/82 shared/reuse: Use @ for ts-xen-build-prep
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- sg-run-job | 2 +- ts-xen-build-prep | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
sg-run-job +1 -1
@@ -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 {} {
ts-xen-build-prep +0 -1
@@ -28,7 +28,6 @@ tsreadconfig(); our ($whhost) = @ARGV; $whhost ||= 'host'; our $ho= selecthost($whhost); -exit 0 if $ho->{SharedReady}; our ($vg,$lv);
Signature · 1 line
2.20.1
PATCH 47/82 shared/reuse: Use @ for ts-host-install
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- sg-run-job | 6 +++--- ts-host-install | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
sg-run-job +3 -3
@@ -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 }
ts-host-install +0 -1
@@ -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);
Signature · 1 line
2.20.1
PATCH 48/82 shared/reuse: Use @ for freebsd host prep
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.)
--- sg-run-job | 12 +++++++++--- ts-build-prep-freebsd | 1 - ts-freebsd-host-install | 1 - 3 files changed, 9 insertions(+), 5 deletions(-)
sg-run-job +9 -3
@@ -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 }
ts-build-prep-freebsd +0 -1
@@ -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
ts-freebsd-host-install +0 -1
@@ -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;
Signature · 1 line
2.20.1
PATCH 49/82 host reuse: sg-run-job: per-host prep: Use @ for per-host-ts
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- sg-run-job | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sg-run-job +3 -3
@@ -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 }
Signature · 1 line
2.20.1
PATCH 50/82 shared/reuse: Rely on @ for ts-host-ping-check
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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/@.
--- ts-host-ping-check | 2 -- 1 file changed, 2 deletions(-)
ts-host-ping-check +0 -2
@@ -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 "$_ ?";
Signature · 1 line
2.20.1
PATCH 51/82 host reuse: Reuse test hosts within a flight
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
Mark the host shareable, and unshareable, as appropriate.
There is still a lot more cleanup and improvement to do.
--- sg-run-job | 5 +++++ 1 file changed, 5 insertions(+)
sg-run-job +5 -0
@@ -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 }
Signature · 1 line
2.20.1
PATCH 52/82 host allocation: Group jobs by their reuse parameters
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
This promotes reuse by arranging that jobs that can reuse a host get to run consecutively.
--- Osstest/JobDB/Executive.pm | 47 +++++++++++++++++++++++++++++++++++++ Osstest/JobDB/Standalone.pm | 2 ++ ts-host-reuse | 1 + ts-hosts-allocate-Executive | 4 ++++ 4 files changed, 54 insertions(+)
Osstest/JobDB/Executive.pm +47 -0
@@ -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);
Osstest/JobDB/Standalone.pm +2 -0
@@ -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,
ts-host-reuse +1 -0
@@ -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 () {
ts-hosts-allocate-Executive +4 -0
@@ -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);
Signature · 1 line
2.20.1
PATCH 53/82 host reuse: Jiggle the infra-priority a bit, within a flight
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- ts-hosts-allocate-Executive | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
ts-hosts-allocate-Executive +7 -2
@@ -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}),
Signature · 1 line
2.20.1
PATCH 54/82 host reuse: Use literal for the hosts_infraprioritygroup runvar
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
At some point this might make the database smarter about indexing. It's certainly clearer.
--- Osstest/JobDB/Executive.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Osstest/JobDB/Executive.pm +5 -5
@@ -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; }
Signature · 1 line
2.20.1
PATCH 55/82 host reuse: Bump host share reuse bonus
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- ts-hosts-allocate-Executive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ts-hosts-allocate-Executive +1 -1
@@ -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
Signature · 1 line
2.20.1
PATCH 56/82 subst_netboot_template: Do not use all of %r
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/TestSupport.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Osstest/TestSupport.pm +2 -1
@@ -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';
Signature · 1 line
2.20.1
PATCH 57/82 TestSupport: Provide runvar_is_synth
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
Internally we use an array %r_notsynth. This allows us to avoid adding code to store_runvar etc.
--- Osstest/TestSupport.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Osstest/TestSupport.pm +9 -3
@@ -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};
Signature · 1 line
2.20.1
PATCH 58/82 runvar access: Introduce access control machinery
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
This will allow us to trap accesses, during test host setup, to runvars which weren't included in ithe calculation of the sharing scope.
--- Osstest/TestSupport.pm | 53 ++++++++++++++++++++++++++++++++++++++++++ README | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-)
Osstest/TestSupport.pm +53 -0
@@ -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;
README +1 -1
@@ -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)
Signature · 1 line
2.20.1
PATCH 59/82 runvar access: Provide runvar_glob
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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).
--- Osstest/TestSupport.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
Osstest/TestSupport.pm +15 -1
@@ -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;
Signature · 1 line
2.20.1
PATCH 60/82 runvar access: Use runvar_glob for dmrestrict runvar search
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- Osstest/Debian.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/Debian.pm +1 -1
@@ -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));
Signature · 1 line
2.20.1
PATCH 61/82 runvar access: Introduce sharing_for_build
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/TestSupport.pm | 4 +++- ts-host-install | 2 ++ ts-xen-build-prep | 1 + 3 files changed, 6 insertions(+), 1 deletion(-)
Osstest/TestSupport.pm +3 -1
@@ -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 "*";
ts-host-install +2 -0
@@ -49,6 +49,8 @@ while (@ARGV and $ARGV[0] =~ m/^-/) { } } +if ($build) { sharing_for_build(); } + our ($whhost) = @ARGV; $whhost ||= 'host'; our $ho= selecthost($whhost);
ts-xen-build-prep +1 -0
@@ -24,6 +24,7 @@ use Osstest::TestSupport; use Osstest::Debian; tsreadconfig(); +sharing_for_build(); our ($whhost) = @ARGV; $whhost ||= 'host';
Signature · 1 line
2.20.1
PATCH 62/82 runvar access: Introduce effects_gone_before_share_reuse
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- Osstest/Debian.pm | 10 ++++++---- Osstest/TestSupport.pm | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-)
Osstest/Debian.pm +6 -4
@@ -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; }
Osstest/TestSupport.pm +6 -0
@@ -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 "*";
Signature · 1 line
2.20.1
PATCH 63/82 test host reuse: Switch to principled sharing scope runvar scheme
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
* 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...
--- Osstest/TestSupport.pm | 23 ++++++++++++++++++++++- ts-host-reuse | 20 ++++++++------------ 2 files changed, 30 insertions(+), 13 deletions(-)
Osstest/TestSupport.pm +22 -1
@@ -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
ts-host-reuse +8 -12
@@ -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;
Signature · 1 line
2.20.1
PATCH 64/82 hsot reuse: Hash the share type
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- README | 2 +- ts-host-reuse | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
README +1 -1
@@ -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)
ts-host-reuse +7 -4
@@ -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; }
Signature · 1 line
2.20.1
PATCH 65/82 hsot reuse: Make share type hash more easily greppable
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
Use - and _ to make up the base64 alphabet instead of + and /
--- ts-host-reuse | 1 + 1 file changed, 1 insertion(+)
ts-host-reuse +1 -0
@@ -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;
Signature · 1 line
2.20.1
PATCH 66/82 host lifecycle: Machinery, db, for tracking relevant events
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- 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
Osstest/JobDB/Executive.pm +211 -0
@@ -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;
Osstest/JobDB/Standalone.pm +2 -0
@@ -137,4 +137,6 @@ sub jobdb_db_glob ($) { #method sub can_anoint ($) { return 0; } +sub jobdb_host_update_lifecycle_info { } #method + 1;
Osstest/TestSupport.pm +12 -0
@@ -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) = @_;
schema/host-lifecycle.sql new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 67/82 host lifecycle: Fix detection of concurrent jobs
In reply to Ian JacksonThe 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.
--- Osstest/JobDB/Executive.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Osstest/JobDB/Executive.pm +6 -7
@@ -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} && '@';
Signature · 1 line
2.20.1
PATCH 68/82 host lifecycle: Prevent referential integrity violation
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
We can't use normal constraints for either of these, sadly.
We can make the constraints into a single query which says "OK".
--- Osstest/JobDB/Executive.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Osstest/JobDB/Executive.pm +25 -0
@@ -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,
Signature · 1 line
2.20.1
PATCH 69/82 host lifecycle: Record lifecycle in db and runvar
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
This is just the calls to host_update_lifecycle_info. Now the db table is Needed.
--- 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(-)
Osstest/TestSupport.pm +2 -0
@@ -1418,6 +1418,8 @@ sub selecthost ($;$$) { } } + host_update_lifecycle_info($ho, $isprep ? 'selectprep' : 'select'); + return $ho; }
schema/host-lifecycle.sql +1 -1
@@ -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
ts-freebsd-host-install +1 -0
@@ -295,3 +295,4 @@ setup_netboot_local($ho); # Proceed with the install install(); +host_update_lifecycle_info($ho, 'wiped');
ts-host-install +1 -0
@@ -297,3 +297,4 @@ END } install(); +host_update_lifecycle_info($ho, 'wiped');
ts-host-reuse +1 -0
@@ -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'); }
ts-logs-capture +1 -0
@@ -309,3 +309,4 @@ if (fetch_logs_host()) { } } logm("logs captured to $stash"); +host_update_lifecycle_info($ho, 'final');
Signature · 1 line
2.20.1
PATCH 70/82 sg-report-flight: Refactor runvar access
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- sg-report-flight | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
sg-report-flight +12 -8
@@ -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;
Signature · 1 line
2.20.1
PATCH 71/82 resource reporting, nfc: split a here document
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
--- sg-report-flight | 3 +++ 1 file changed, 3 insertions(+)
sg-report-flight +3 -0
@@ -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>
Signature · 1 line
2.20.1
PATCH 72/82 resource reporting: Report host reuse/sharing in job report
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- sg-report-flight | 331 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 330 insertions(+), 1 deletion(-)
sg-report-flight +330 -1
@@ -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;
Signature · 1 line
2.20.1
PATCH 73/82 host reuse: sg-run-job: Reanme post-test-ok parameter
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
This is more accurate.
No overall functional change.
--- sg-run-job | 2 +- ts-host-reuse | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sg-run-job +1 -1
@@ -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 }
ts-host-reuse +1 -1
@@ -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};
Signature · 1 line
2.20.1
PATCH 74/82 host reuse: ts-host-reuse: Prepare for argument handling
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
No functional change.
--- ts-host-reuse | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
ts-host-reuse +6 -3
@@ -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};
Signature · 1 line
2.20.1
PATCH 75/82 host reuse: New protocol between sg-run-job and ts-host-reuse
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
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.
--- sg-run-job | 8 +++++++- ts-host-reuse | 25 ++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-)
sg-run-job +7 -1
@@ -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 }
ts-host-reuse +16 -9
@@ -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/-/_/;
Signature · 1 line
2.20.1
PATCH 76/82 sg-report-flight: Reformat slightly
In reply to Ian JacksonThis is more regular and will make the next commit easier to understand.
--- sg-report-flight | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sg-report-flight +4 -2
@@ -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>";
Signature · 1 line
2.20.1
PATCH 77/82 sg-report-flight: Improvements to other job (share/reuse) reporting
In reply to Ian Jackson* Prefer to show "prep" (purple) rather than "share".
* Show our own relationship, in particular to show if it was prep.
--- sg-report-flight | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sg-report-flight +7 -5
@@ -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
Signature · 1 line
2.20.1
PATCH 78/82 flight other job reporting: Put nulls last in the report
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
Cosmetic change only, but this makes the results easier to understand.
--- sg-report-flight | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sg-report-flight +4 -1
@@ -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
Signature · 1 line
2.20.1
PATCH 79/82 flight other job reporting: Further improvements to ordering
In reply to Ian JacksonFrom: Ian Jackson <[email protected]>
We want to definitely put these NULLs last.
--- sg-report-flight | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sg-report-flight +6 -2
@@ -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,
Signature · 1 line
2.20.1
PATCH 80/82 tsreadconfig: Change misleading "setting" message
In reply to Ian JacksonThese are the *existing* runvars and it is confusing that we print "setting" for them.
--- Osstest/TestSupport.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/TestSupport.pm +1 -1
@@ -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(); });
Signature · 1 line
2.20.1
PATCH 81/82 sg-report-flight: Sharing reports: more task finished info
In reply to Ian JacksonOther 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.
--- sg-report-flight | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sg-report-flight +10 -4
@@ -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>
Signature · 1 line
2.20.1
PATCH 82/82 sg-report-flight: Word-wrapping improvements to job and step names
In reply to Ian JacksonUse <wbr>.
--- sg-report-flight | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
sg-report-flight +12 -4
@@ -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>'. $& . '⁠') : ''; + $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>";
Signature · 1 line
2.20.1