From f69befd0906b2ecf170ea24f915fd13443c01fca Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 22 Jan 2019 19:54:40 +0000 Subject: [PATCH] power: Record approach used for power cycles in runvars Signed-off-by: Ian Jackson --- Osstest/TestSupport.pm | 17 +++++++++++++---- ts-host-install | 2 +- ts-logs-capture | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index fb14c4b..334cc2c 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -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)}); diff --git a/ts-host-install b/ts-host-install index 068242e..292733b 100755 --- a/ts-host-install +++ b/ts-host-install @@ -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."); diff --git a/ts-logs-capture b/ts-logs-capture index fe3b081..a429bb7 100755 --- a/ts-logs-capture +++ b/ts-logs-capture @@ -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: $@"); -- 2.39.5