Bugfixes
cover Bugfixes
Many of these are fixes to host sharing.
I'm still doing a formal dev test but I expect to push these soon.
Ian Jackson (16):
share in jobdb: Break out $checkconstraints and move call share in jobdb: Move out-of-flight special case higher up PDU/IPMI: Retransmit, don't just wait
PDU/MSW: Warn that SNMP status is often not immediately updated PDU/MSW: Break out get()
PDU/MSW: Break out action_value()
PDU/MSW: Actually implement delayed-*
PDU/MSW: Make show() return the value from get() PDU/MSU: Retransmit on/off until PDU has changed
host reuse fixes: Fix running of steps adhoc
host reuse fixes: Fix runvar entry for adhoc tasks Introduce guest_mk_lv_name
Prefix guest LV names with the job name
reporting: Minor fix to reporting of tasks with no subtask host reuse fixes: Do not break host-reuse if no host allocated
starvation: Do not count more than half a flight as starved
Osstest/Executive.pm | 2 +- Osstest/JobDB/Executive.pm | 46 +++++++++++++++++++++++-------------- Osstest/PDU/ipmi.pm | 5 ++-- Osstest/TestSupport.pm | 9 ++++++-- pdu-msw | 37 +++++++++++++++++++++++++---- ts-debian-fixup | 22 ++++++++++++++++++ ts-debian-install | 2 +- ts-host-reuse | 2 +- ts-hosts-allocate-Executive | 2 +- 9 files changed, 97 insertions(+), 30 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/16 share in jobdb: Break out $checkconstraints and move call
This must happen after we introduce our new row or it is not effective!
--- Osstest/JobDB/Executive.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Osstest/JobDB/Executive.pm +6 -2
@@ -582,6 +582,11 @@ END VALUES (?, ?, ?, ?, ?, ?, ? ) END + my $checkconstraints = sub { + $constraintsq->execute($hostname, $ttaskid); + $constraintsq->fetchrow_array() or confess "$hostname ?"; + }; + my $ojvn = "$ho->{Ident}_lifecycle"; if (length $r{$ojvn}) {
@@ -654,8 +659,6 @@ 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,
@@ -670,6 +673,7 @@ END undef, undef,undef); } + $checkconstraints->(); }); if (defined $flight) {
Signature · 1 line
2.20.1
PATCH 2/16 share in jobdb: Move out-of-flight special case higher up
In reply to Ian JacksonThis avoids running the runvar computation loop outside flights. This is good amongst other things because that loop prints warnings about undef $flight and $job.
--- Osstest/JobDB/Executive.pm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
Osstest/JobDB/Executive.pm +18 -15
@@ -587,6 +587,18 @@ END $constraintsq->fetchrow_array() or confess "$hostname ?"; }; + + if (!defined $flight) { + db_retry($dbh_tests,[], sub { + $insertq->execute($hostname, $ttaskid, + undef,undef, + undef, + undef,undef); + $checkconstraints->(); + }); + return; + } + my $ojvn = "$ho->{Ident}_lifecycle"; if (length $r{$ojvn}) {
@@ -660,26 +672,17 @@ END } } - if (defined $flight) { - $insertq->execute($hostname, $ttaskid, - $flight, $job, - ($mode eq 'selectprep')+0, + $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); - } + $tident, $tstepno); $checkconstraints->(); }); - if (defined $flight) { - push @lifecycle, $newsigil if length $newsigil; - store_runvar($ojvn, "@lifecycle"); - } + push @lifecycle, $newsigil if length $newsigil; + store_runvar($ojvn, "@lifecycle"); } sub current_stepno ($) { #method
Signature · 1 line
2.20.1
PATCH 3/16 PDU/IPMI: Retransmit, don't just wait
In reply to Ian JacksonWe have a system for which
ipmitool -H sabro0m -U root -P XXXX -I lanplus power on
seems to work but doesn't take effect the first time.
Retransit each retry.
--- Osstest/PDU/ipmi.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Osstest/PDU/ipmi.pm +3 -2
@@ -66,11 +66,12 @@ sub pdu_power_state { return; } - system_checked((@cmd, qw(power), $onoff)); - my $count = 60; for (;;) { last if $getstatus->() eq $onoff; + + system_checked((@cmd, qw(power), $onoff)); + die "did not power $onoff" unless --$count > 0; sleep(1); }
Signature · 1 line
2.20.1
PATCH 4/16 PDU/MSW: Warn that SNMP status is often not immediately updated
In reply to Ian JacksonIf you don't know this, it's very confusing.
--- pdu-msw | 1 + 1 file changed, 1 insertion(+)
pdu-msw +1 -0
@@ -133,4 +133,5 @@ if (!defined $action) { print "was: "; show(); set(); print "now: "; show(); + print "^ note, PDUs often do not update returned info immediately\n"; }
Signature · 1 line
2.20.1
PATCH 5/16 PDU/MSW: Break out get()
In reply to Ian JacksonThis is going to be useful in a moment.
--- pdu-msw | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
pdu-msw +6 -1
@@ -106,13 +106,18 @@ my @map= (undef, qw( delayed-off delayed-reboot)); -sub show () { +sub get () { my $got= $session->get_request($read_oid); die "SNMP error reading $read_oid ".$session->error()." " unless $got; my $val= $got->{$read_oid}; die unless $val; my $mean= $map[$val]; die "$val ?" unless defined $mean; + return $mean; +} + +sub show () { + my $mean = get(); printf "pdu-msw $dnsname: #%s \"%s\" = %s\n", $useport, $usename, $mean; }
Signature · 1 line
2.20.1
PATCH 6/16 PDU/MSW: Break out action_value()
In reply to Ian JacksonThis is going to be useful in a moment.
--- pdu-msw | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
pdu-msw +8 -3
@@ -121,13 +121,17 @@ sub show () { printf "pdu-msw $dnsname: #%s \"%s\" = %s\n", $useport, $usename, $mean; } -sub set () { +sub action_value () { my $delayadd= ($action =~ s/^delayed-// ? 3 : 0); my $valset= ($action =~ m/^(?:0|off)$/ ? 2 : $action =~ m/^(?:1|on)$/ ? 1 : $action =~ m/^(?:reboot)$/ ? 3 : die "unknown action $action\n$usagemsg"); - + return $valset; +} + +sub set ($) { + my ($valset) = @_; my $res= $session->set_request(-varbindlist => [ $write_oid, INTEGER, $valset ]); die "SNMP set ".$session->error()." " unless $res; }
@@ -135,8 +139,9 @@ sub set () { if (!defined $action) { show(); } else { + my $valset = action_value(); print "was: "; show(); - set(); + set($valset); print "now: "; show(); print "^ note, PDUs often do not update returned info immediately\n"; }
Signature · 1 line
2.20.1
PATCH 7/16 PDU/MSW: Actually implement delayed-*
In reply to Ian JacksonNothing in our tree uses this but having it here is useful docs for the protocol so I shan't just delete it.
--- pdu-msw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pdu-msw +1 -1
@@ -127,7 +127,7 @@ sub action_value () { $action =~ m/^(?:1|on)$/ ? 1 : $action =~ m/^(?:reboot)$/ ? 3 : die "unknown action $action\n$usagemsg"); - return $valset; + return $valset + $delayadd; } sub set ($) {
Signature · 1 line
2.20.1
PATCH 8/16 PDU/MSW: Make show() return the value from get()
In reply to Ian JacksonNo-one uses this return value yet, so NFC.
--- pdu-msw | 1 + 1 file changed, 1 insertion(+)
pdu-msw +1 -0
@@ -119,6 +119,7 @@ sub get () { sub show () { my $mean = get(); printf "pdu-msw $dnsname: #%s \"%s\" = %s\n", $useport, $usename, $mean; + return $mean; } sub action_value () {
Signature · 1 line
2.20.1
PATCH 9/16 PDU/MSU: Retransmit on/off until PDU has changed
In reply to Ian JacksonThe main effect of this is that the transcript will actually show the new PDU state. Previously we would call show(), but APC PDUs would normally not change immediately, so the transcript would show the old state.
This also guards against an unresponsive PDU or a packet getting lost. I don't think we have ever seen that.
--- pdu-msw | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
pdu-msw +18 -3
@@ -41,6 +41,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { if (@ARGV<2 || @ARGV>3 || $ARGV[0] =~ m/^-/) { die "bad usage\n$usagemsg"; } +our ($max_retries) = 16; # timeout = 0.05 * max_retries^2 our ($dnsname,$outlet,$action) = @ARGV; my ($session,$error) = Net::SNMP->session(
@@ -142,7 +143,21 @@ if (!defined $action) { } else { my $valset = action_value(); print "was: "; show(); - set($valset); - print "now: "; show(); - print "^ note, PDUs often do not update returned info immediately\n"; + + my $retries = 0; + for (;;) { + set($valset); + sleep $retries * 0.1; + print "now: "; my $got = show(); + if ($got eq $map[$valset]) { last; } + if ($map[$valset] !~ m{^(?:off|on)$}) { + print + "^ note, PDUs often do not update returned info immediately\n"; + last; + } + if ($retries >= $max_retries) { + die "PDU does not seem to be changing state!\n"; + } + $retries++; + } }
Signature · 1 line
2.20.1
PATCH 10/16 host reuse fixes: Fix running of steps adhoc
In reply to Ian JacksonWhen a ts script is run by hand, for adhoc testing, there is no OSSTEST_TESTID variable in the environment and the script does not know it's own step number. Such adhoc runs are not tracked as steps in the steps table.
For host lifecycle purposes, treat these as ad-hoc out-of-flight uses, based only on the taskid (which will usually be a person's personal static task).
Without this, these adhoc runs fail with a constraint violating trying to insert a flight/job/step row into the host lifecycle table: the constraint requires the step to be specified but it is NULL.
--- Osstest/JobDB/Executive.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/JobDB/Executive.pm +1 -1
@@ -588,7 +588,7 @@ END }; - if (!defined $flight) { + if (!defined $flight || !defined $tstepno) { db_retry($dbh_tests,[], sub { $insertq->execute($hostname, $ttaskid, undef,undef,
Signature · 1 line
2.20.1
PATCH 11/16 host reuse fixes: Fix runvar entry for adhoc tasks
In reply to Ian JacksonWhen processing an item from the host lifecycle table into the runvar, we don't want to do all the processing of flight and job. Instead, we should simply put the ?<taskid> into the runvar.
Previously this would produce ?<taskid>: which the flight reporting code would choke on.
--- Osstest/JobDB/Executive.pm | 5 +++++ 1 file changed, 5 insertions(+)
Osstest/JobDB/Executive.pm +5 -0
@@ -649,6 +649,11 @@ END } next if $tj_seen{$oisprepmark.$otj}++; + if (!defined $o->{flight}) { + push @lifecycle, "$omarks$otj"; + next; + } + if (!$omarks && !$olive && defined($o->{flight}) && $ho->{Shared} && $ho->{Shared}{Type} =~ m/^build-/ &&
Signature · 1 line
2.20.1
PATCH 12/16 Introduce guest_mk_lv_name
In reply to Ian JacksonThis changes the way the disk name is constructed but not to any overall effect.
--- Osstest/TestSupport.pm | 9 +++++++-- ts-debian-install | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-)
Osstest/TestSupport.pm +7 -2
@@ -76,7 +76,7 @@ BEGIN { target_jobdir target_extract_jobdistpath_subdir target_extract_jobdistpath target_extract_distpart target_tftp_prefix - lv_create lv_dev_mapper + lv_create lv_dev_mapper guest_mk_lv_name poll_loop tcpconnect await_tcp contents_make_cpio file_simple_write_contents
@@ -2177,6 +2177,11 @@ sub guest_var_commalist ($$) { return split /\,/, guest_var($gho,$runvartail,''); } +sub guest_mk_lv_name ($$) { + my ($gho, $suffix) = @_; + return "$gho->{Name}".$suffix; +} + sub prepareguest ($$$$$$) { my ($ho, $gn, $hostname, $tcpcheckport, $mb, $boot_timeout) = @_;
@@ -2205,7 +2210,7 @@ sub prepareguest ($$$$$$) { # If we have defined guest specific disksize, use it $mb = guest_var($gho,'disksize',$mb); if (defined $mb) { - store_runvar("${gn}_disk_lv", $r{"${gn}_hostname"}.'-disk'); + store_runvar("${gn}_disk_lv", guest_mk_lv_name($gho, '-disk')); } if (defined $mb) {
ts-debian-install +1 -1
@@ -100,7 +100,7 @@ END my $cfg= "/etc/xen/$gho->{Name}.cfg"; store_runvar("$gho->{Guest}_cfgpath", $cfg); - store_runvar("$gho->{Guest}_swap_lv", "$gho->{Name}-swap"); + store_runvar("$gho->{Guest}_swap_lv", guest_mk_lv_name($gho, "-swap")); } prep();
Signature · 1 line
2.20.1
PATCH 13/16 Prefix guest LV names with the job name
In reply to Ian JacksonThis means that a subsequent test which reuses the same host will not use the same LVs. This is a good idea because reusing the same LV names in a subsequent job means relying on the "ad hoc run" cleanup code. This is a bad idea because that code is rarely tested.
And because, depending on the situation, the old LVs may even still be in use. For example, in a pair test, the guest's LVs will still be set up for use with nbd.
It seems better to fix this by using a fresh LV rather than adding more teardown code.
The "wear limit" on host reuse is what prevents the disk filling up with LVs from old guests.
ts-debian-fixup needs special handling, because Debian's xen-tools' xen-create-image utility hardcodes its notion of LV name construction. We need to rename the actual LVs (perhaps overwriting old ones from a previous ad-hoc run) and also update the config.
--- Osstest/TestSupport.pm | 2 +- ts-debian-fixup | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
Osstest/TestSupport.pm +1 -1
@@ -2179,7 +2179,7 @@ sub guest_var_commalist ($$) { sub guest_mk_lv_name ($$) { my ($gho, $suffix) = @_; - return "$gho->{Name}".$suffix; + return $job."_$gho->{Name}".$suffix; } sub prepareguest ($$$$$$) {
ts-debian-fixup +22 -0
@@ -37,6 +37,27 @@ sub savecfg () { $cfg= get_filecontents("$cfgstash.orig"); } +sub lvnames () { + my $lvs = target_cmd_output_root($ho, "lvdisplay --colon", 30); + foreach my $suffix (qw(disk swap)) { + my $old = "$gho->{Name}-$suffix"; + my $new = "${job}_${old}"; + my $full_old = "/dev/$gho->{Vg}/$old"; + my $full_new = "/dev/$gho->{Vg}/$new"; + $cfg =~ s{\Q$full_old\E(?![0-9a-zA-Z/_.-])}{ + logm "Replacing in domain config \`$&' with \`$full_new'"; + $full_new; + }ge; + if ($lvs =~ m{^ *\Q$full_old\E}m) { + if ($lvs =~ m{^ *\Q$full_new\E}m) { + # In case we are re-running (eg, adhoc) + target_cmd_root($ho, "lvremove -f $full_new", 30); + } + target_cmd_root($ho, "lvrename $full_old $new", 30); + } + } +} + sub ether () { # $cfg =~ s/^ [ \t]* # ( vif [ \t]* \= [ \t]* \[ [ \t]* [\'\"]
@@ -207,6 +228,7 @@ sub writecfg () { } savecfg(); +lvnames(); ether(); access(); $console = target_setup_rootdev_console_inittab($ho,$gho,"$mountpoint");
Signature · 1 line
2.20.1
PATCH 14/16 reporting: Minor fix to reporting of tasks with no subtask
In reply to Ian Jacksonsubtask can be NULL. If so, do not include it.
This change fixes a warning and a minor cosmetic defect.
--- Osstest/Executive.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/Executive.pm +1 -1
@@ -427,7 +427,7 @@ sub report_rogue_task_description ($) { my $info= "rogue task "; $info .= " $arow->{type} $arow->{refkey}"; $info .= " ($arow->{comment})" if defined $arow->{comment}; - $info .= " $arow->{subtask}"; + $info .= " $arow->{subtask}" if defined $arow->{subtask}; $info .= " (user $arow->{username})"; return $info; }
Signature · 1 line
2.20.1
PATCH 15/16 host reuse fixes: Do not break host-reuse if no host allocated
In reply to Ian JacksonIf host allocation failed, or our dependency jobs failed, then we won't have allocated a host. The host runvar will not be set. In this case, we want to do nothing.
But we forgot to pass $noneok to selecthost.
--- ts-host-reuse | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ts-host-reuse +1 -1
@@ -165,7 +165,7 @@ sub act_start_test () { sub act_final () { if (!@ARGV) { - $ho = selecthost($whhost); + $ho = selecthost($whhost, 1); return unless $ho; host_update_lifecycle_info($ho, 'final'); } elsif ("@ARGV" eq "--post-test-ok") {
Signature · 1 line
2.20.1
PATCH 16/16 starvation: Do not count more than half a flight as starved
In reply to Ian JacksonThis seems like a sensible rule.
This also prevents the following bizarre behaviour: when a flight has a handful of jobs that cannot be run at all (eg because it's a commissioning flight for only hosts of a particular arch), those jobs can complete quite quickly. Even with a high X value because only a smallish portion of the flight has finished, this can lead to a modest threshhold value. This combines particularly badly with commissioning flights, where the duraation estimates are often nonsense.
--- ts-hosts-allocate-Executive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ts-hosts-allocate-Executive +1 -1
@@ -863,7 +863,7 @@ sub starving ($$) { "D=%d W=%d X=%.3f t_D=%s t_me=%s t_lim=%.3f X'=%.4f (fi.s=%s)", $d, $w, $X, $total_d, $projected_me, $lim, $Xcmp, $fi->{started} - $now; - my $bad = $projected_me > $lim; + my $bad = $projected_me > $lim && $d >= $w; return ($bad, $m); }
Signature · 1 line
2.20.1