$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.
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}): $@");
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)});
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.");
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: $@");