Reduce hard power cycles
PATCH 1/26 power: Osstest::PDU::*: drop Exporter blocks
In reply to Ian JacksonThis is all very obsolete. These that we are removing are all empty, and nowadays perl has `use parent'. These changes are all textually identical.
We will do ipmi_try in a moment: that one is special as it actually has a parent module.
--- Osstest/PDU/eth008.pm | 11 ----------- Osstest/PDU/guest.pm | 11 ----------- Osstest/PDU/ipmi.pm | 11 ----------- Osstest/PDU/ipmiextra.pm | 11 ----------- Osstest/PDU/manual.pm | 11 ----------- Osstest/PDU/msw.pm | 11 ----------- Osstest/PDU/pause.pm | 11 ----------- Osstest/PDU/unsupported.pm | 11 ----------- Osstest/PDU/xenuse.pm | 11 ----------- 9 files changed, 99 deletions(-)
Osstest/PDU/eth008.pm +0 -11
@@ -23,17 +23,6 @@ use Osstest; use Osstest::TestSupport; use LWP::UserAgent; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - sub new { my ($class, $ho, $methname, $pdu, $user, $pass, $port, @opts) = @_; return bless { Host => $ho,
Osstest/PDU/guest.pm +0 -11
@@ -25,17 +25,6 @@ use Osstest; use Osstest::TestSupport; use IO::File; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - sub new { my ($class, $ho) = @_; return bless { Target => $ho }, $class;
Osstest/PDU/ipmi.pm +0 -11
@@ -23,17 +23,6 @@ use Osstest; use Osstest::TestSupport; use IO::File; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - sub new { my ($class, $ho, $methname, $mgmt, $user, $pass, @opts) = @_; $user ||= get_host_property($ho, 'IpmiUser') || 'ADMIN';
Osstest/PDU/ipmiextra.pm +0 -11
@@ -23,17 +23,6 @@ use Osstest; use Osstest::TestSupport; use IO::File; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - sub new { my ($class, $ho, $methname, $when, $mgmt, $user, $pass, @opts) = @_; return bless { Host => $ho,
Osstest/PDU/manual.pm +0 -11
@@ -23,17 +23,6 @@ use warnings; use Osstest; use IO::File; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - our $tty; sub new {
Osstest/PDU/msw.pm +0 -11
@@ -22,17 +22,6 @@ use warnings; use Osstest; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - sub new { my ($class, $ho, $methname, @args) = @_;
Osstest/PDU/pause.pm +0 -11
@@ -23,17 +23,6 @@ use Osstest; use Osstest::TestSupport; use IO::File; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - sub new { my ($class, $ho, $methname, $on, $off) = @_; if (!defined $on) {
Osstest/PDU/unsupported.pm +0 -11
@@ -22,17 +22,6 @@ use warnings; use Osstest; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - our $tty; sub new {
Osstest/PDU/xenuse.pm +0 -11
@@ -24,17 +24,6 @@ use Osstest; use Osstest::TestSupport; use IO::File; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} - sub new { my ($class, $ho) = @_; return bless { Host => $ho }, $class;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/26 power: Osstest::PDU::*: use parent ::unsupported
In reply to Ian JacksonThis will allow us to introduce default methods, which everyone inherits unless overridden. These changes are all textually identical.
We will do ipmi_try in a moment: that one is special as it actually has a parent module.
--- Osstest/PDU/eth008.pm | 2 ++ Osstest/PDU/guest.pm | 2 ++ Osstest/PDU/ipmi.pm | 2 ++ Osstest/PDU/ipmi_try.pm | 2 ++ Osstest/PDU/ipmiextra.pm | 2 ++ Osstest/PDU/manual.pm | 2 ++ Osstest/PDU/msw.pm | 2 ++ Osstest/PDU/pause.pm | 2 ++ Osstest/PDU/statedb.pm | 2 ++ Osstest/PDU/xenuse.pm | 2 ++ 10 files changed, 20 insertions(+)
Osstest/PDU/eth008.pm +2 -0
@@ -23,6 +23,8 @@ use Osstest; use Osstest::TestSupport; use LWP::UserAgent; +use parent qw(Osstest::PDU::unsupported); + sub new { my ($class, $ho, $methname, $pdu, $user, $pass, $port, @opts) = @_; return bless { Host => $ho,
Osstest/PDU/guest.pm +2 -0
@@ -25,6 +25,8 @@ use Osstest; use Osstest::TestSupport; use IO::File; +use parent qw(Osstest::PDU::unsupported); + sub new { my ($class, $ho) = @_; return bless { Target => $ho }, $class;
Osstest/PDU/ipmi.pm +2 -0
@@ -23,6 +23,8 @@ use Osstest; use Osstest::TestSupport; use IO::File; +use parent qw(Osstest::PDU::unsupported); + sub new { my ($class, $ho, $methname, $mgmt, $user, $pass, @opts) = @_; $user ||= get_host_property($ho, 'IpmiUser') || 'ADMIN';
Osstest/PDU/ipmi_try.pm +2 -0
@@ -24,6 +24,8 @@ use Osstest::TestSupport; use IO::File; use Osstest::PDU::ipmi; +use parent Osstest::PDU::unsupported; + BEGIN { use Exporter (); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
Osstest/PDU/ipmiextra.pm +2 -0
@@ -23,6 +23,8 @@ use Osstest; use Osstest::TestSupport; use IO::File; +use parent qw(Osstest::PDU::unsupported); + sub new { my ($class, $ho, $methname, $when, $mgmt, $user, $pass, @opts) = @_; return bless { Host => $ho,
Osstest/PDU/manual.pm +2 -0
@@ -23,6 +23,8 @@ use warnings; use Osstest; use IO::File; +use parent qw(Osstest::PDU::unsupported); + our $tty; sub new {
Osstest/PDU/msw.pm +2 -0
@@ -22,6 +22,8 @@ use warnings; use Osstest; +use parent qw(Osstest::PDU::unsupported); + sub new { my ($class, $ho, $methname, @args) = @_;
Osstest/PDU/pause.pm +2 -0
@@ -23,6 +23,8 @@ use Osstest; use Osstest::TestSupport; use IO::File; +use parent qw(Osstest::PDU::unsupported); + sub new { my ($class, $ho, $methname, $on, $off) = @_; if (!defined $on) {
Osstest/PDU/statedb.pm +2 -0
@@ -24,6 +24,8 @@ use Osstest; use Osstest::Executive; use Osstest::TestSupport; +use parent qw(Osstest::PDU::unsupported); + sub power_state_await ($$$) { my ($sth, $want, $msg) = @_; poll_loop(30,1, "power: $msg $want", sub {
Osstest/PDU/xenuse.pm +2 -0
@@ -24,6 +24,8 @@ use Osstest; use Osstest::TestSupport; use IO::File; +use parent qw(Osstest::PDU::unsupported); + sub new { my ($class, $ho) = @_; return bless { Host => $ho }, $class;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 5/26 power handling: Break out power_cycle_parse_method
In reply to Ian Jackson--- Osstest/TestSupport.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
Osstest/TestSupport.pm +10 -4
@@ -917,10 +917,10 @@ sub serial_fetch_logs ($) { #---------- power cycling ---------- -sub power_cycle_host_setup ($) { - my ($ho) = @_; +sub power_cycle_parse_method ($$) { + my ($ho, $spec) = @_; my $methobjs = [ ]; - foreach my $meth (split /\;\s*/, ($ho->{Power} // 'unsupported')) { + foreach my $meth (split /\;\s*/, $spec) { if ($meth eq 'nest') { push @$methobjs, $meth; } elsif ($meth =~ m{^(\d+)(?:/(\d+))$}) {
@@ -930,7 +930,13 @@ sub power_cycle_host_setup ($) { push @$methobjs, get_host_method_object($ho,'PDU',$meth); } } - $ho->{PowerMethobjs} = $methobjs; + return $methobjs; +} + +sub power_cycle_host_setup ($) { + my ($ho) = @_; + $spec = ($ho->{Power} // 'unsupported'); + $ho->{PowerMethobjs} = power_cycle_parse_method($ho,$spec); } sub power_cycle_sleep ($) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 7/26 power: PowerApproaches replaces $ho->{PowerMethobjs}
In reply to Ian JacksonThis new variable contains a list of different approaches to try.
* Move the meat of power_state into power_approach_invoke.
* power_state now looks for a single approach to try.
* The default for power_state is to pick the last approach in the list, which by definition is supposed to be the most reliable.
* Currently there will only be one approach, `Only'.
No overall functional change other than to log messages.
--- Osstest/TestSupport.pm | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
Osstest/TestSupport.pm +29 -6
@@ -935,8 +935,15 @@ sub power_cycle_parse_method ($$) { sub power_cycle_host_setup ($) { my ($ho) = @_; - $spec = ($ho->{Power} // 'unsupported'); - $ho->{PowerMethobjs} = power_cycle_parse_method($ho,$spec); + my $spec = ($ho->{Power} // 'unsupported'); + # $ho->{PowerApproaches}[]{Name} see below + # $ho->{PowerApproaches}[]{MethObjs}[] each has ->pdu_power_state($on) + # `Name's are: + # Only Host only supports one method and this is it + $ho->{PowerApproaches} = { + Name => 'Only', + MethObjs => power_cycle_parse_method($ho, $spec), + }; } sub power_reboot_attempts ($$$) {
@@ -978,10 +985,10 @@ sub power_cycle ($) { power_state($ho, 1); } -sub power_state ($$) { - my ($ho, $on) = @_; - logm("power: setting $on for $ho->{Name}"); - my @methobjs = @{ $ho->{PowerMethobjs} }; +sub power_approach_invoke ($$$) { + my ($ho, $approach, $on) = @_; + logm("power: setting $on (using $approach->{Name}) for $ho->{Name}"); + my @methobjs = @{ $approach->{MethObjs} }; if ($methobjs[0] eq 'nest') { shift @methobjs; @methobjs = reverse @methobjs if !$on;
@@ -991,6 +998,22 @@ sub power_state ($$) { } } +sub power_state ($$;$) { + my ($ho, $on, $approach_re) = @_; + my @approaches = @{ $ho->{PowerApproaches} }; + my $approach; + if (defined $approach_re) { + ($approach) = grep { $_->{Name} =~ qr{$approach_re} } @approaches + or die ("No matching power approach for $ho->{Name}". + " (wanted $approach_re) (available: ". + join(' ', map { $_->{Name} } @approaches). + ")\n"); + } else { + $approach = $approaches[-1]; + } + power_approach_invoke($ho,$approach,$on); +} + #---------- host selection and properties ---------- sub selecthost ($);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 8/26 power: power_reboot_attempts: Try multiple approaches
In reply to Ian JacksonActually iterate over PowerApproaches, rather than calling power_state with no approach selector regexp.
No overall functional change right now because nothing puts more than one entry in PowerApproaches.
--- Osstest/TestSupport.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
Osstest/TestSupport.pm +16 -5
@@ -960,11 +960,22 @@ sub power_reboot_attempts ($$$) { # to work. $setup and $await should tolerate this situation; in # particular $await must only succeed if the host really did reboot # into the boot environment that $await expects. - power_state($ho, 0); - $setup->(); - power_cycle_sleep($ho); - power_state($ho, 1); - $await->(); + foreach my $approach (@{ $ho->{PowerApproaches} }) { + logm("power: rebooting $ho->{Name} (using $approach->{Name})"); + if (eval { + power_approach_invoke($ho, $approach, 0); + $setup->(); + power_cycle_sleep($ho); + power_approach_invoke($ho, $approach, 1); + $await->(); + 1; + }) { + logm("power: rebooted $ho->{Name} (using $approach->{Name})"); + return; + } + logm("power: failed to reboot (using $approach->{Name}): $@"); + } + die "power: all approaches to rebooting $ho->{Name} failed!\n"; } sub power_cycle_sleep ($) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 9/26 power: Provide `try_off' pdu method; deprecate ipmi_try
In reply to Ian JacksonWe are going to want to use this magically, in our new approach. Make a general version, and deprecate ipmi_try (which will be obsoleted by the new approach and which has probably not been used very much).
--- Osstest/PDU/ipmi_try.pm | 2 ++ Osstest/PDU/try_off.pm | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 Osstest/PDU/try_off.pm
Osstest/PDU/ipmi_try.pm +2 -0
@@ -14,6 +14,8 @@ # 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/>. +# NOTE: this method is deprecated. Use try_off instead. + package Osstest::PDU::ipmi_try; use strict;
Osstest/PDU/try_off.pm new file +65 -0
65 lines not on this page · raw message
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 10/26 power: New ILOM/PDU arrangements - try just IPMI
In reply to Ian JacksonWe honour two new host properties PowerPDU and PowerILOM, in preference to PowerMethod. The semantics are going to be properly documented in a later patch, but, briefly:
If only one of these is supplied, it works like PowerMethod, except that `nest' is applied by default.
If both are supplied, we make two approaches: one is just ILOM. The other is to use ILOM and PDU together, with pause in between, and with try_off applied to ILOM.
The current configuration in Massachusetts is, for hosts with IPMI, to provide a PowerMethod specifying ad hoc to use PDU and then IPMI, and also to provide both PowerPDU and PowerILOM.
The overall result of this patch, with that configuration, is to avoid using the PDU at all if an IPMI-requested reboot is successful. This should significantly reduce the number of hard power cycles for hosts with IMPI.
--- Osstest/TestSupport.pm | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
Osstest/TestSupport.pm +37 -5
@@ -935,15 +935,47 @@ sub power_cycle_parse_method ($$) { sub power_cycle_host_setup ($) { my ($ho) = @_; - my $spec = ($ho->{Power} // 'unsupported'); # $ho->{PowerApproaches}[]{Name} see below # $ho->{PowerApproaches}[]{MethObjs}[] each has ->pdu_power_state($on) # `Name's are: # Only Host only supports one method and this is it - $ho->{PowerApproaches} = { - Name => 'Only', - MethObjs => power_cycle_parse_method($ho, $spec), - }; + # ILOM Try to use just the ILOM + # PDU Try to use the PDU (but also turn off/on ILOM if provided) + my @approaches; + my $pdu_s = get_host_property($ho,'PowerPDU'); + my $ilom_s = get_host_property($ho,'PowerILOM'); + if ($pdu_s || $ilom_s) { + my $ilom_m; + if ($ilom_s) { + $ilom_m = power_cycle_parse_method($ho, $ilom_s); + push @approaches, { + Name => 'ILOM', + MethObjs => ['nest', @$ilom_m ], + }; + } + if ($pdu_s) { + my $pdu_m = power_cycle_parse_method($ho, $pdu_s); + if ($ilom_m) { + require Osstest::PDU::try_off; + $pdu_m = [ + @$pdu_m, + get_host_method_object($ho, 'PDU', 'pause'), + map { Osstest::PDU::try_off->new_from_mo($_) } @$ilom_m, + ]; + } + push @approaches, { + Name => 'PDU', + MethObjs => ['nest', @$pdu_m ], + }; + } + } else { + my $spec = ($ho->{Power} // 'unsupported'); + push @approaches, { + Name => 'Only', + MethObjs => power_cycle_parse_method($ho, $spec), + }; + } + $ho->{PowerApproaches} = \@approaches; } sub power_reboot_attempts ($$$) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
cover Reduce hard power cycles
We have been having trouble with PDU port relays sticking. We vaguely suspect that this is happening in Massachusetts due to the lower-voltage (120V, and therefore higher-current) electricity (compared to Cambridge, 240V, where the PDUs remain reliable).
To mitigate this issue (and generally prolong hardware life), try to avoid hard power cycling test boxes when we can. Specifically, try a reboot with ssh first, and if that fails try the IMPI if provided. If the IMPI doesn't work either or is not provided, hard power cycle.
Patches 01-25 are ready I think, and have been tested. There is a difficulty with the FreeBSD host install, which is discussed in patch 26 which is definitely not ready in this form.
Ian Jackson (26):
power: Osstest::PDU::*: drop Exporter blocks
power: Osstest::PDU::*: use parent ::unsupported
power: ipmi_try: Use `use parent' instead of Exporter
power: Osstest::PDU::*: reuse default new method where applicable power handling: Break out power_cycle_parse_method
power handling: Introduce power_reboot_attempts
power: PowerApproaches replaces $ho->{PowerMethobjs}
power: power_reboot_attempts: Try multiple approaches
power: Provide `try_off' pdu method; deprecate ipmi_try
power: New ILOM/PDU arrangements - try just IPMI
power: Do not sleep between power off and power on if not needed
power: Provide `ssh' power method
power: Try rebooting hosts with ssh first
power: Document Power* host properties and power methods
power: Honour approach_re in power_cycle and mg-hosts power
ts-host-powercycle: Use a lighter-weight method if available
power: Rename target_reboot_force from target_reboot_hard
power: power_reboot_attempts: Honour an $approach_re
ts-logs-capture: power: try ILOM first
power: Use `Combined' as Name for PDU+ILOM approach
power: Record approach used for power cycles in runvars
Executive: Break out span_colour
Executive: Export $grey_* with :colours
sg-report-host-history: Move SET LOCAL into transaction
sg-report-host-history: Show used power approach(es)
DO NOT APPLY power: ts-freebsd-host-install: Use power_reboot_attempts
Osstest/Executive.pm | 11 +++- Osstest/PDU/eth008.pm | 11 +--- Osstest/PDU/guest.pm | 16 ++--- Osstest/PDU/ipmi.pm | 11 +--- Osstest/PDU/ipmi_try.pm | 14 +---- Osstest/PDU/ipmiextra.pm | 11 +--- Osstest/PDU/manual.pm | 16 +---- Osstest/PDU/msw.pm | 11 +--- Osstest/PDU/pause.pm | 11 +--- Osstest/PDU/ssh.pm | 74 ++++++++++++++++++++++ Osstest/PDU/statedb.pm | 2 + Osstest/PDU/try_off.pm | 70 +++++++++++++++++++++ Osstest/PDU/unsupported.pm | 16 ++--- Osstest/PDU/xenuse.pm | 16 +---- Osstest/TestSupport.pm | 154 +++++++++++++++++++++++++++++++++++++++------ README | 77 +++++++++++++++++++++++ README.dev | 4 +- mg-hosts | 14 +++-- sg-report-host-history | 67 ++++++++++++++++++-- ts-freebsd-host-install | 16 ++--- ts-host-install | 19 +++--- ts-host-powercycle | 6 +- ts-logs-capture | 2 +- 23 files changed, 482 insertions(+), 167 deletions(-) create mode 100644 Osstest/PDU/ssh.pm create mode 100644 Osstest/PDU/try_off.pm
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 14/26 power: Document Power* host properties and power methods
--- README | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.dev | 4 ++-- 2 files changed, 79 insertions(+), 2 deletions(-)
README +77 -0
@@ -631,6 +631,83 @@ Username User name on this host. Defaults to the output of `whoami'. Should not normally be changed. +HostProp_<host>_PowerPDU +HostProp_<host>_PowerILOM + How to power cycle this host. Each item is a ;-separated + list of method specifications. When power is to be removed + or applied, the methods in the list are operated in order + (when powering on) or reverse order (when powering off). + + If both PDU and ILOM are supplied, osstest tries first to just use + ILOM. If that is not successful, it tries again using PDU and + ILOM together. In this case: they are done in the appropriate + order (PDU first, on power on); it is if `pause' were specified in + between PDU and ILOM; and it is as if try_off were specified + before each ILOM. + + A method specification has a keyword at the front, and + is in one of these forms: + + Any of the Osstest::PDU::* modules in Osstest/PDU/*.pm. See + the individual modules. We document here, particularly: + + manual Asks the user on the controlling terminal + unsupported Fails whenever a power operation is needed + + msw [--apc6] <pdu> <port-name-regexp|port-num> + Control and APC masterswitch via SNMP. The SNMP + community is `private'. See the `pdu-msw' script. + + ipmi <mgmt> [<user> [<pass> [<ipmitool options...>]]] + Use IPMI by (by running ipmitool). <mgmt> is the name or + address of the management port. <user> and <pass> + default to the IpmiUser and IpmiPassword host properties. + + ipmiextra on|off|both <mgmt> <user> <pass> [<ipmitool options...>] + Does nothing if `on|off|both' is inapplicable, and has + less error checking and less defaulting than ipmi. + + Supported specially are: + + <delay> + <ondelay>/<offdelay> + pause <delay> + pause <ondelay> <offdelay> + Pause for the specified time(s) (in seconds). + + pause + Pause for <ondelay> (defaulting to the PowerOnTime host + property) on power on, and for 10 seconds on power off. + Normally it is not necessary to specify this explicitly, + as it is implied by providing both PowerPDU and + PowerILOM. + + try_off [<attempts>] <method...> + Use <method>. However, on powering off: make <attempts> + attempts (default=3), and if that fails, only warn rather + than failing. + +HostProp_<host>_PowerOnTime + Length of time it takes this host to wake up from cold power on, + until the ILOM is working. (Used if both PowerPDU and PowerILOM + are set, or if `pause' appears in a power method pspecification.) + Default is 120 seconds. + +HostProp_<host>_PowerCycleTime + Length of time this host must be powered off to ensure that it + reboots properly. (This should be the longer value of the values + for PDU and ILOM, if applicable.) Default is 5 seconds. + +HostProp_<host>_PowerMethod + Older specification for how to power cycle this host. Only used + if neither PowerPDU or PowerILOM is provided. + + Syntax and semantics are the same as those, except that the order + of operation is forwards through the list for both power on and + power off, unless the first `method' is the pseudo-method `nest'. + + This host property is honoured for backward compatibility. + ======================================== Host-specific config settigs
README.dev +2 -2
@@ -38,8 +38,8 @@ Firstly, arrange that it is hooked up to network, serial, and pdu. (In the Xen Project Massachusetts test lab, make sure that ansible playbook hosts/ has the wiring information; running `make install' will then arrange for /root/osstest-hosts-config to contain the Ether, -Serial and PowerMethod configuration, and also configure the DNS and -the DHCP server.) +Serial and PowerILOM/PowerHard/PowerCycleTime configuration, and also +configure the DNS and the DHCP server.) Go through the BIOS set up, using the serial console. Check that: - After AC power loss, machine is set to turn on
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/26 power: ipmi_try: Use `use parent' instead of Exporter
In reply to Ian JacksonThis module already has a superclass, ipmi'. Import it with use parent' instead of Exporter.
--- Osstest/PDU/ipmi_try.pm | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
Osstest/PDU/ipmi_try.pm +1 -13
@@ -22,20 +22,8 @@ use warnings; use Osstest; use Osstest::TestSupport; use IO::File; -use Osstest::PDU::ipmi; -use parent Osstest::PDU::unsupported; - -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter Osstest::PDU::ipmi); - @EXPORT = qw(); - %EXPORT_TAGS = ( ); - - @EXPORT_OK = qw(); -} +use parent qw(Osstest::PDU::ipmi); sub pdu_power_state { my ($mo, $on) = @_;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 4/26 power: Osstest::PDU::*: reuse default new method where applicable
In reply to Ian JacksonThese two modules both had the same new' as unsupported'. Now that we have `use parent' they can be removed.
--- Osstest/PDU/manual.pm | 5 ----- Osstest/PDU/xenuse.pm | 5 ----- 2 files changed, 10 deletions(-)
Osstest/PDU/manual.pm +0 -5
@@ -27,11 +27,6 @@ use parent qw(Osstest::PDU::unsupported); our $tty; -sub new { - my ($class, $ho) = @_; - return bless { Host => $ho }, $class; -} - sub pdu_power_state { my ($mo, $on) = @_; my $onoff= $on ? "on" : "off";
Osstest/PDU/xenuse.pm +0 -5
@@ -26,11 +26,6 @@ use IO::File; use parent qw(Osstest::PDU::unsupported); -sub new { - my ($class, $ho) = @_; - return bless { Host => $ho }, $class; -} - sub pdu_power_state { my ($mo, $on) = @_; my $onoff= $on ? "on" : "off";
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 19/26 ts-logs-capture: power: try ILOM first
In reply to Ian JacksonIf ILOM is provided, and the host is not responding when we try logs capture, try the ILOM before hard power cycling the host.
--- Osstest/TestSupport.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +3 -2
@@ -1440,8 +1440,9 @@ sub target_reboot ($) { sub target_reboot_force ($) { my ($ho) = @_; - power_cycle($ho); - await_tcp(get_timeout($ho,'reboot',$timeout{HardRebootUp}), 5, $ho); + power_reboot_attempts($ho, sub { }, sub { + await_tcp(get_timeout($ho,'reboot',$timeout{HardRebootUp}), 5, $ho); + }, qr{(?!.*SSH)}); } sub tcpconnect ($$) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 20/26 power: Use `Combined' as Name for PDU+ILOM approach
In reply to Ian Jackson--- Osstest/TestSupport.pm | 11 +++++++---- mg-hosts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-)
Osstest/TestSupport.pm +7 -4
@@ -938,9 +938,10 @@ sub power_cycle_host_setup ($) { # $ho->{PowerApproaches}[]{Name} see below # $ho->{PowerApproaches}[]{MethObjs}[] each has ->pdu_power_state($on) # `Name's are: - # Only Host only supports one method and this is it - # ILOM Try to use just the ILOM - # PDU Try to use the PDU (but also turn off/on ILOM if provided) + # Only Host only supports one method and this is it + # ILOM Try to use just the ILOM + # PDU Try to use the PDU (no ILOM provided) + # Combined Try to use the PDU and ILOM tohether my @approaches; my $pdu_s = get_host_property($ho,'PowerPDU'); my $ilom_s = get_host_property($ho,'PowerILOM');
@@ -955,8 +956,10 @@ sub power_cycle_host_setup ($) { } if ($pdu_s) { my $pdu_m = power_cycle_parse_method($ho, $pdu_s); + my $pdu_name = 'PDU'; if ($ilom_m) { require Osstest::PDU::try_off; + $pdu_name = 'Combined'; $pdu_m = [ @$pdu_m, get_host_method_object($ho, 'PDU', 'pause'),
@@ -964,7 +967,7 @@ sub power_cycle_host_setup ($) { ]; } push @approaches, { - Name => 'PDU', + Name => $pdu_name, MethObjs => ['nest', @$pdu_m ], }; }
mg-hosts +1 -1
@@ -31,7 +31,7 @@ # "1" or "off" : power off # "c" or "r" : reboot # APPROACH_RE is a regexp specifying which method to -# use. Methods are: Only ILOM PDU SSH +# use. Methods are: Only Combined ILOM PDU SSH # and the lightest method which matches will be used. # If not specified, the most reliable method will be used. #
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 21/26 power: Record approach used for power cycles in runvars
In reply to Ian Jackson--- Osstest/TestSupport.pm | 17 +++++++++++++---- ts-host-install | 2 +- ts-logs-capture | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-)
Osstest/TestSupport.pm +13 -4
@@ -981,12 +981,15 @@ sub power_cycle_host_setup ($) { $ho->{PowerApproaches} = \@approaches; } -sub power_reboot_attempts ($$$;$) { - my ($ho, $setup, $await, $approach_re) = @_; +sub power_reboot_attempts ($$$;$$) { + my ($ho, $setup, $await, $approach_re, $record_runvar_tail) = @_; # Power cycles $ho, calling $setup->() while it is (supposedly) off. # Then, just after turning $ho on, calls $await->(). # If $await->() succeeds, great: returns. # + # Records the method used in the synth runvar IDENT_power_TAIL + # (a comma-separated list) + # # If it fails (dies), power_reboot_attempts will attempt to power # cycle $ho using a more certain method and call $fn again. This # may occur multiple times.
@@ -1018,6 +1021,12 @@ sub power_reboot_attempts ($$$;$) { 1; }) { logm("power: rebooted $ho->{Name} (using $approach->{Name})"); + if (defined $record_runvar_tail) { + my $rv = "$ho->{Ident}_power_${record_runvar_tail}"; + my $newval = $r{$rv}.(!!length($r{$rv}) and ',') + .$approach->{Name}; + store_runvar($rv, $newval); + } return; } logm("power: failed to reboot (using $approach->{Name}): $@");
@@ -1441,8 +1450,8 @@ sub target_reboot ($) { await_tcp(get_timeout($ho,'reboot',$timeout{RebootUp}), 5,$ho); } -sub target_reboot_force ($) { - my ($ho) = @_; +sub target_reboot_force ($;$) { + my ($ho, $record_runvar_tail) = @_; power_reboot_attempts($ho, sub { }, sub { await_tcp(get_timeout($ho,'reboot',$timeout{HardRebootUp}), 5, $ho); }, qr{(?!.*SSH)});
ts-host-install +1 -1
@@ -71,7 +71,7 @@ END my $logtailer= Osstest::Logtailer->new($c{WebspaceLog}); my $timeout = get_timeout($ho,'reboot',$timeout{ReadPreseed}); await_webspace_fetch_byleaf($timeout, 1, $logtailer, $ho, $ps_url); - }); + }, undef, "install"); if ($poweron_test_only) { logm("Hooray, power on worked.");
ts-logs-capture +1 -1
@@ -175,7 +175,7 @@ sub fetch_logs_host () { if (!try_fetch_logs($ho, $logs)) { logm("log fetching failed, trying hard host reboot..."); if (!eval { - target_reboot_force($ho); + target_reboot_force($ho, 'recover'); 1; }) { logm("host reboot failed, abandoning log fetches: $@");
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 22/26 Executive: Break out span_colour
In reply to Ian JacksonNo functional change.
--- Osstest/Executive.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Osstest/Executive.pm +8 -2
@@ -59,7 +59,8 @@ BEGIN { db_pg_dsn opendb opendb_state db_schema_updates_applied db_schema_updates_intree ); - %EXPORT_TAGS = ( colours => [qw($green $red $yellow $purple $blue)] ); + %EXPORT_TAGS = ( colours => [qw($green $red $yellow $purple $blue + span_colour)] ); @EXPORT_OK = @{ $EXPORT_TAGS{colours} }; }
@@ -306,6 +307,11 @@ our $grey_pale= '#666666'; our $grey_mid= '#888888'; our $grey_dark= '#cccccc'; +sub span_colour ($) { + my ($colour) = @_; + "<span style=\"background-color: $colour\">" +} + sub report_run_getinfo ($) { # $f is a joined flight/job row, must contain at least # flight job status
@@ -345,7 +351,7 @@ END $summary .= " $fs->{status}"; $colour = $failcolour; } - push @content, "<span style=\"background-color: $colour\">". + push @content, span_colour($colour). encode_entities($summary)."</span>"; } if (!@content) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 6/26 power handling: Introduce power_reboot_attempts
In reply to Ian JacksonThis is going to be the new preferred interface for rebooting a host.
Introduce the first two call sites in ts-host-install and ts-freebsd-host-install. power_cycle_sleep is an internal function now.
No overall functional change, since currently power_reboot_attempts only ever tries one method.
Do not adjust ts-freebsd-host-install yet as we have a problem there, which will be discussed in a moment.
--- Osstest/TestSupport.pm | 23 ++++++++++++++++++++++- ts-host-install | 19 +++++++------------ 2 files changed, 29 insertions(+), 13 deletions(-)
Osstest/TestSupport.pm +22 -1
@@ -81,7 +81,7 @@ BEGIN { selecthost get_hostflags get_host_property get_target_property get_host_native_linux_console hostnamepath hostnamepath_list set_runtime_hostflag - power_state power_cycle power_cycle_sleep + power_state power_cycle power_reboot_attempts serial_fetch_logs set_host_property propname_massage propname_check hostprop_putative_record
@@ -939,6 +939,27 @@ sub power_cycle_host_setup ($) { $ho->{PowerMethobjs} = power_cycle_parse_method($ho,$spec); } +sub power_reboot_attempts ($$$) { + my ($ho, $setup, $await) = @_; + # Power cycles $ho, calling $setup->() while it is (supposedly) off. + # Then, just after turning $ho on, calls $await->(). + # If $await->() succeeds, great: returns. + # + # If it fails (dies), power_reboot_attempts will attempt to power + # cycle $ho using a more certain method and call $fn again. This + # may occur multiple times. + # + # All but the last method used for power cycling are not certain + # to work. $setup and $await should tolerate this situation; in + # particular $await must only succeed if the host really did reboot + # into the boot environment that $await expects. + power_state($ho, 0); + $setup->(); + power_cycle_sleep($ho); + power_state($ho, 1); + $await->(); +} + sub power_cycle_sleep ($) { my ($ho) = @_; my $to = get_host_property($ho, 'power-cycle-time', 5);
ts-host-install +7 -12
@@ -56,8 +56,6 @@ our %timeout= qw(ReadPreseed 350 Sshd 2400); sub install () { - power_state($ho, 0); - my ($ps_url,$ps_file)= preseed_create ($ho, '', DiskDevice => $ho->{DiskDevice},
@@ -67,19 +65,16 @@ d-i netcfg/get_hostname string $ho->{Name} d-i netcfg/get_ipaddress string $ho->{Ip} END - setup_netboot_firstboot($ps_url); - power_cycle_sleep($ho); - - my $logtailer= Osstest::Logtailer->new($c{WebspaceLog}); - power_state($ho, 1); - - await_webspace_fetch_byleaf(get_timeout($ho,'reboot',$timeout{ReadPreseed}) - , 1, - $logtailer, $ho, $ps_url); + power_reboot_attempts($ho, sub { + setup_netboot_firstboot($ps_url); + }, sub { + my $logtailer= Osstest::Logtailer->new($c{WebspaceLog}); + my $timeout = get_timeout($ho,'reboot',$timeout{ReadPreseed}); + await_webspace_fetch_byleaf($timeout, 1, $logtailer, $ho, $ps_url); + }); if ($poweron_test_only) { logm("Hooray, power on worked."); - power_state($ho, 0); exit 0; }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 11/26 power: Do not sleep between power off and power on if not needed
In reply to Ian JacksonThis is controlled by a new query method on power method objects. If every power method says it is instananeous then we do not sleep.
This is going to be most useful when we introduce the new SSH approach, which should not sleep for the power off time.
But we do it for guests (ie, L1 nested hosts) too.
--- Osstest/PDU/guest.pm | 5 +++++ Osstest/PDU/try_off.pm | 5 +++++ Osstest/PDU/unsupported.pm | 5 +++++ Osstest/TestSupport.pm | 9 ++++++++- 4 files changed, 23 insertions(+), 1 deletion(-)
Osstest/PDU/guest.pm +5 -0
@@ -56,4 +56,9 @@ sub pdu_power_state { } } +sub instantaneous { + my ($mo) = @_; + return 1; +} + 1;
Osstest/PDU/try_off.pm +5 -0
@@ -62,4 +62,9 @@ sub pdu_power_state { } } +sub instantaneous { + my ($mo) = @_; + return $mo->{Then}->instantaneous(); +} + 1;
Osstest/PDU/unsupported.pm +5 -0
@@ -35,4 +35,9 @@ sub pdu_power_state { die "power switch request for $mo->{Host}{Name} ($on) not supported\n"; } +sub instantaneous { + my ($mo) = @_; + return 0; +} + 1;
Osstest/TestSupport.pm +8 -1
@@ -997,7 +997,14 @@ sub power_reboot_attempts ($$$) { if (eval { power_approach_invoke($ho, $approach, 0); $setup->(); - power_cycle_sleep($ho); + my $need_sleep = 0; + foreach my $mo (@{ $approach->{MethObjs} }) { + next if $mo eq 'nest'; + next if $mo->instantaneous(); + $need_sleep = 1; + last; + } + power_cycle_sleep($ho) if $need_sleep; power_approach_invoke($ho, $approach, 1); $await->(); 1;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 26/26 DO NOT APPLY power: ts-freebsd-host-install: Use power_reboot_attempts
In reply to Ian JacksonRFC. Needs input on how to
| check that this is the installer environment
as requested by the comment
| in particular $await must only succeed if the host really did | reboot into the boot environment that $await expects.
near the top of power_reboot_attempts
--- ts-freebsd-host-install | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
ts-freebsd-host-install +8 -8
@@ -259,14 +259,14 @@ END } # Switch off, setup PXE and switch on to the installer -power_state($ho, 0); -setup_netboot_installer(); -power_cycle_sleep($ho); -power_state($ho, 1); - -# Wait for the host to finish booting -logm("Waiting for the installer to boot"); -await_tcp(get_timeout($ho,'reboot',$timeout), 5, $ho); +power_reboot_attempts($ho, sub { + setup_netboot_installer(); +}, sub { + # Wait for the host to finish booting + logm("Waiting for the installer to boot"); + await_tcp(get_timeout($ho,'reboot',$timeout), 5, $ho); + xxx check that this is the installer environment +}, undef, 'install'); if ($bootonly) { hostprop_putative_record($ho, "MemdiskAppend", $memdisk_append)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 12/26 power: Provide `ssh' power method
In reply to Ian JacksonThis is not really a power method but it can pretend to be one. On power off, it does nothing. On power on it logs into the host to ask it to do a hard reboot.
This is rather best effort, but it is eminently suitable for our new approach/attempts arrangements because those will try another approach if ssh didn't work.
--- Osstest/PDU/ssh.pm | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Osstest/PDU/ssh.pm
Osstest/PDU/ssh.pm new file +74 -0
@@ -0,0 +1,74 @@ +# 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/>. + + +package Osstest::PDU::ssh; + +# This power method is used automatically, even when not configured. + +use strict; +use warnings; + +use Osstest; +use Osstest::TestSupport; + +use parent qw(Osstest::PDU::unsupported); + +our $tty; + +sub pdu_sleep_required { + return 0; +} + +sub pdu_power_state { + my ($mo, $on) = @_; + + if (!$on) { + logm("power: request to turn off via SSH method, ignored"); + return; + } + + # These games with ( )& are needed because the command to request + # a hard reboot request will not return, so the tcp connection + # carrying our ssh command request would just hang. + + my $delay = 5; + + target_cmd_root($mo->{Host}, <<'END', 60); + set -e + type reboot + exec >>/var/log/osstest-reboot.log + date + exec </dev/null 2>&1 + set -x + ( + set +e + sleep $delay + reboot -f -n -d # Linux sysvinit/systemd + reboot -nq # FreeBSD (rejects above due to -f) + )& +END + + sleep($delay); +} + +sub instantaneous { + my ($mo) = @_; + # This does not need any more sleep, if it worked. + return 1; +} + +1;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 13/26 power: Try rebooting hosts with ssh first
In reply to Ian JacksonBefore we try anything with IPMI (if provided) or the PDU, try rebooting with ssh.
I think this will dramatically reduce the rate at which we power cycle our test hosts.
--- Osstest/TestSupport.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +6 -2
@@ -992,8 +992,12 @@ sub power_reboot_attempts ($$$) { # to work. $setup and $await should tolerate this situation; in # particular $await must only succeed if the host really did reboot # into the boot environment that $await expects. - foreach my $approach (@{ $ho->{PowerApproaches} }) { - logm("power: rebooting $ho->{Name} (using $approach->{Name})"); + my $ssh = { + Name => 'SSH', + MethObjs => power_cycle_parse_method($ho, 'ssh'), + }; + foreach my $approach ($ssh, @{ $ho->{PowerApproaches} }) { + logm("power: trying to reboot $ho->{Name} (using $approach->{Name})"); if (eval { power_approach_invoke($ho, $approach, 0); $setup->();
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 15/26 power: Honour approach_re in power_cycle and mg-hosts power
In reply to Ian Jackson--- Osstest/TestSupport.pm | 8 ++++---- mg-hosts | 14 +++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-)
Osstest/TestSupport.pm +4 -4
@@ -1028,15 +1028,15 @@ sub power_cycle_sleep ($) { sleep($to); } -sub power_cycle ($) { - my ($ho) = @_; +sub power_cycle ($;$) { + my ($ho, $approach_re) = @_; $mjobdb->host_check_allocated($ho); die "refusing to set power state for host $ho->{Name}". " possibly shared with other jobs\n" if $ho->{SharedMaybeOthers}; - power_state($ho, 0); + power_state($ho, 0, $approach_re); power_cycle_sleep($ho); - power_state($ho, 1); + power_state($ho, 1, $approach_re); } sub power_approach_invoke ($$$) {
mg-hosts +9 -5
@@ -24,12 +24,16 @@ # of osstest. Will use "sudo". The HOST(s) must be # allocated (via mg-allocate HOST). # -# ./mg-hosts power HOST ACTION +# ./mg-hosts power HOST ACTION [APPROACH_RE] # Power cycles the host. Host must be allocated to the current # user. Actions are: # "0" or "on" : power on # "1" or "off" : power off # "c" or "r" : reboot +# APPROACH_RE is a regexp specifying which method to +# use. Methods are: Only ILOM PDU SSH +# and the lightest method which matches will be used. +# If not specified, the most reliable method will be used. # # ./mg-hosts create-like SOURCE-HOST NEW-HOST[,NEW-HOST...] # Create new host(s). This does NOT copy the
@@ -151,15 +155,15 @@ END } sub cmd_power () { - die unless @ARGV==2; - my ($host,$power) = @ARGV; + die unless @ARGV==2 || @ARGV==3; + my ($host,$power,$approach_re) = @ARGV; $_ = $power; $power = m/^1|^on/ ? 1 : m/^0|^off/ ? 0 : m/^r|^c/ ? -1 : die; my $ho= selecthost("host=$host"); if ($power >= 0) { - power_state($ho, $power); + power_state($ho, $power, $approach_re); } else { - power_cycle($ho); + power_cycle($ho, $approach_re); } }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 16/26 ts-host-powercycle: Use a lighter-weight method if available
In reply to Ian Jackson--- ts-host-powercycle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ts-host-powercycle +4 -2
@@ -33,8 +33,10 @@ our ($whhost) = @ARGV; $whhost ||= 'host'; our $ho= selecthost($whhost); +my $approach_re = qr{(?!.*SSH)}; + if (defined $only) { - power_state($ho, $only); + power_state($ho, $only, $approach_re); } else { - power_cycle($ho); + power_cycle($ho, $approach_re); }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 17/26 power: Rename target_reboot_force from target_reboot_hard
In reply to Ian JacksonWe are going to make this try softer methods first.
No functional change.
--- Osstest/TestSupport.pm | 4 ++-- ts-logs-capture | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Osstest/TestSupport.pm +2 -2
@@ -98,7 +98,7 @@ BEGIN { sshopts authorized_keys known_hosts cfg_tftp_di_version controller_ipaddr remote_perl_script_open remote_perl_script_done - host_reboot target_reboot target_reboot_hard + host_reboot target_reboot target_reboot_force target_choose_vg target_umount_lv target_await_down host_get_free_memory
@@ -1437,7 +1437,7 @@ sub target_reboot ($) { await_tcp(get_timeout($ho,'reboot',$timeout{RebootUp}), 5,$ho); } -sub target_reboot_hard ($) { +sub target_reboot_force ($) { my ($ho) = @_; power_cycle($ho); await_tcp(get_timeout($ho,'reboot',$timeout{HardRebootUp}), 5, $ho);
ts-logs-capture +1 -1
@@ -175,7 +175,7 @@ sub fetch_logs_host () { if (!try_fetch_logs($ho, $logs)) { logm("log fetching failed, trying hard host reboot..."); if (!eval { - target_reboot_hard($ho); + target_reboot_force($ho); 1; }) { logm("host reboot failed, abandoning log fetches: $@");
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 18/26 power: power_reboot_attempts: Honour an $approach_re
In reply to Ian JacksonThe semantics are slightly different here: not specifying it means to try everything rather than only the hardest. But the effect is
similar: not specifying $approach_re means we must succeed.
--- Osstest/TestSupport.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +3 -2
@@ -978,8 +978,8 @@ sub power_cycle_host_setup ($) { $ho->{PowerApproaches} = \@approaches; } -sub power_reboot_attempts ($$$) { - my ($ho, $setup, $await) = @_; +sub power_reboot_attempts ($$$;$) { + my ($ho, $setup, $await, $approach_re) = @_; # Power cycles $ho, calling $setup->() while it is (supposedly) off. # Then, just after turning $ho on, calls $await->(). # If $await->() succeeds, great: returns.
@@ -997,6 +997,7 @@ sub power_reboot_attempts ($$$) { MethObjs => power_cycle_parse_method($ho, 'ssh'), }; foreach my $approach ($ssh, @{ $ho->{PowerApproaches} }) { + next if defined $approach_re && $approach->{Name} !~ qr{$approach_re}; logm("power: trying to reboot $ho->{Name} (using $approach->{Name})"); if (eval { power_approach_invoke($ho, $approach, 0);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 23/26 Executive: Export $grey_* with :colours
In reply to Ian JacksonNo functional change with existing callers.
--- Osstest/Executive.pm | 1 + 1 file changed, 1 insertion(+)
Osstest/Executive.pm +1 -0
@@ -60,6 +60,7 @@ BEGIN { db_schema_updates_applied db_schema_updates_intree ); %EXPORT_TAGS = ( colours => [qw($green $red $yellow $purple $blue + $grey_pale $grey_mid $grey_dark span_colour)] ); @EXPORT_OK = @{ $EXPORT_TAGS{colours} };
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 25/26 sg-report-host-history: Show used power approach(es)
In reply to Ian Jackson--- sg-report-host-history | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
sg-report-host-history +56 -0
@@ -161,6 +161,7 @@ sub reporthost ($) { print H "<th>branch</th><th>intended</th><th>blessing</th>\n"; print H "<th>job</th><th>failure</th>\n"; + print H "<th>power</th>\n"; print H "</tr>\n";
@@ -188,6 +189,16 @@ END LIMIT 1 END + # the final AND is just to reduce the data flow + our $jrunvarq //= db_prepare(<<END); + SELECT name, val + FROM runvars + WHERE flight=? AND job=? + AND ( + name LIKE (? || '_power_%') + ) +END + my $inrows = $hosts{$hostname}; print DEBUG "FOUND ", (scalar @$inrows), " ROWS for $hostname\n";
@@ -213,6 +224,12 @@ END foreach my $jr (@rows) { my $ir = jobquery($infoq, $jr); my $ar = jobquery($allocdq, $jr); + my $ident = $jr->{name}; + $jrunvarq->execute($jr->{flight}, $jr->{job}, $ident); + my %runvars; + while (my ($n, $v) = $jrunvarq->fetchrow_array()) { + $runvars{$n} = $v; + } my $altcolour = report_altcolour($alternate); print H "<tr $altcolour>";
@@ -252,6 +269,45 @@ END my $ri = report_run_getinfo({ %$jr, %$ir }); print H "<td $ri->{ColourAttr}>$ri->{Content}</td>\n"; + my %powers; + foreach my $r (sort keys %runvars) { + next unless $r =~ m{^\Q${ident}\E_power_}; + $powers{$'} = $runvars{$r}; + } + my $skipped = 0; + my $any_power = 0; + my $pr_power_colour = sub { + my ($colour, $contents) = @_; + if ($any_power++) { + print H span_colour($colour), $contents, '</span>'; + } else { + print H "<td bgcolor=\"$colour\">", $contents; + } + }; + my $pr_power = sub { + my ($wh) = @_; + for (; $skipped; $skipped--) { + $pr_power_colour->($grey_mid, " - "); + } + my $how = $powers{$wh}; + my $colour = + $how =~ /PDU/ ? $yellow : + $how =~ /Combined/ ? $yellow : + $how eq 'SSH' ? $green : + $grey_pale ; + $pr_power_colour->($colour, " $how "); + }; + foreach my $wh (qw(install recover)) { + $skipped++, next unless exists $powers{$wh}; + $pr_power->($wh); + delete $powers{$wh}; + } + foreach my $wh (sort keys %powers) { + $pr_power->($wh); + } + print H "<td>" if !$any_power; + print H "</td>\n"; + print H "</tr>\n\n"; $alternate ^= 1; }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 24/26 sg-report-host-history: Move SET LOCAL into transaction
In reply to Ian JacksonGets rid of this warning:
WARNING: SET LOCAL can only be used in transaction blocks
This suggests that this code was previously not effective...
--- sg-report-host-history | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
sg-report-host-history +6 -5
@@ -266,15 +266,16 @@ db_retry($dbh_tests, [], sub { computeflightsrange(); }); -$dbh_tests->do("SET LOCAL enable_seqscan=false"); -# Otherwise the PostgreSQL query planner likes to do a complete scan -# of the runvars table, rather than walking backwards through the -# flights until it has what we've told it is enough. - foreach my $host (@ARGV) { if ($host =~ m/^flight:/) { my $flight=$'; #'; db_retry($dbh_tests, [], sub { + $dbh_tests->do("SET LOCAL enable_seqscan=false"); + # Otherwise the PostgreSQL query planner likes to do a + # complete scan of the runvars table, rather than walking + # backwards through the flights until it has what we've + # told it is enough. + our $hostsinflightq //= db_prepare(<<END); SELECT DISTINCT val FROM runvars
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel