* Changed 'anvil-manage-power' to no longer set the job progress to 50 prior to calling a reboot. It now sets to 100 immediately. Also reduced the uptime timer to five minutes from ten.

* Updated striker-auto-initialize-all() to reconnect to DBs during waits to better detect when a DB is marked as offline.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 422d248cbe
commit edf51adaec
  1. 2
      tools/anvil-daemon
  2. 28
      tools/anvil-manage-power
  3. 22
      tools/striker-auto-initialize-all

@ -1281,6 +1281,8 @@ AND
}});
}
### TODO: This shouldn't be needed anymore. anvil-manage-power doesn't set the progress to '50' prior
### to reboot anymore.
# If a reboot is needed, see if the uptime is less than the time since the reboot needed flag was
# set. If the uptime is less, then the system rebooted since it was requested so clear it. h/t to
# Lisa Seelye (@thedoh) for this idea!

@ -188,7 +188,7 @@ sub do_poweroff
my ($anvil, $task) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { task => $task }});
# We'll wait until the system has at least 10 minutes of uptime, unless '--no-wait' was given.
# We'll wait until the system has at least 5 minutes of uptime, unless '--no-wait' was given.
my $uptime = $anvil->data->{switches}{'no-wait'} ? 0 : $anvil->Get->uptime;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"switches::no-wait" => $anvil->data->{switches}{'no-delay'},
@ -196,17 +196,16 @@ sub do_poweroff
}});
my $say_task = $task eq "poweroff" ? "message_0062" : "message_0063";
my $percent = $task eq "poweroff" ? 100 : 50;
print $anvil->Words->string({key => $say_task})."\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => $say_task});
# To minimize the trouble of a problem where the reboot needed flag isn't cleared, and so the system
# wants to repeatedly reboot, we need to add a delay to not let anvil-daemon ask us to
# reboot/power-off until the system uptime is more than ten minutes.
if (($uptime) && ($uptime < 600))
if (($uptime) && ($uptime < 300))
{
# We'll wait until the system has been running for ten minutes.
my $difference = 600 - $uptime;
my $difference = 300 - $uptime;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0224", variables => {
task => $task eq "poweroff" ? "#!string!log_0225!#" : "#!string!log_0226!#",
difference => $difference,
@ -235,16 +234,6 @@ sub do_poweroff
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
}
if ($job_uuid)
{
$anvil->Job->update_progress({
debug => 2,
progress => $percent,
message => $say_task,
job_uuid => $job_uuid,
});
}
# Make sure the 'reboot needed' flag is set. When 'anvil-daemon' starts, it will use this to confirm
# that it is starting post-reboot and clear it.
my $say_reason = $task eq "poweroff" ? "log_0689" : "log_0688";
@ -259,6 +248,17 @@ sub do_poweroff
host_status => $task eq "poweroff" ? "rebooting" : "stopping",
});
# If we have a job UUID, mark that we're done.
if ($job_uuid)
{
$anvil->Job->update_progress({
debug => 2,
progress => 100,
message => $say_task,
job_uuid => $job_uuid,
});
}
# Now do the deed.
my $shell_call = $anvil->data->{path}{exe}{systemctl}." ".$task;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});

@ -406,7 +406,12 @@ sub configure_machine_networks
if ($waiting)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0269"});
sleep 10
# Disconnect and reconnect in case a DB goes offline.
$anvil->Database->disconnect();
sleep 10;
$anvil->refresh();
$anvil->Database->connect();
}
}
@ -547,7 +552,12 @@ sub run_manifests
{
# Wait a bit and check again.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0262"});
# Disconnect and reconnect in case a DB goes offline.
$anvil->Database->disconnect();
sleep 10;
$anvil->refresh();
$anvil->Database->connect();
}
else
{
@ -805,7 +815,12 @@ sub initialize_machines
if ($waiting)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0255"});
# Disconnect and reconnect in case a DB goes offline.
$anvil->Database->disconnect();
sleep 10;
$anvil->refresh();
$anvil->Database->connect();
}
}
@ -1371,7 +1386,12 @@ fi;
{
# Wait 30 seconds and try again
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0230", variables => { number => $striker_number }});
# Disconnect and reconnect in case a DB goes offline.
$anvil->Database->disconnect();
sleep 30;
$anvil->refresh();
$anvil->Database->connect();
}
}
}

Loading…
Cancel
Save