* Updated anvil-update-system to set 'job_data' to track reboots, and striker-update-cluster to read it.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent 3016fb875b
commit 02c3d204ea
  1. 1
      Anvil/Tools/Database.pm
  2. 19
      tools/anvil-update-system
  3. 20
      tools/striker-update-cluster

@ -4491,6 +4491,7 @@ WHERE
} }
### TODO: Delete this and convert over to Jobs->get_job_details()
=head2 get_job_details =head2 get_job_details
This gets the details for a given job. If the job is found, a hash reference is returned containing the tables that were read in. This gets the details for a given job. If the job is found, a hash reference is returned containing the tables that were read in.

@ -101,9 +101,20 @@ if ($reboot_needed)
$anvil->System->maintenance_mode({set => 0}); $anvil->System->maintenance_mode({set => 0});
# Record that we're rebooting so that 'striker-update-cluster' knows to wait for a reboot. # Record that we're rebooting so that 'striker-update-cluster' knows to wait for a reboot.
my $query = "UPDATE jobs SET job_status = 'rebooted', modified_date = ".$anvil->Database->quote($anvil->Database->refresh_timestamp)." WHERE job_uuid = ".$anvil->Database->quote($job_uuid).";"; if ($anvil->data->{switches}{'job-uuid'})
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); {
my $query = "
UPDATE
jobs
SET
job_data = 'rebooted',
modified_date = ".$anvil->Database->quote($anvil->Database->refresh_timestamp)."
WHERE
job_uuid = ".$anvil->Database->quote($anvil->data->{switches}{'job-uuid'})."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__}); $anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
}
sleep 2; sleep 2;
my $shell_call = $anvil->data->{path}{exe}{systemctl}." reboot"; my $shell_call = $anvil->data->{path}{exe}{systemctl}." reboot";
@ -347,9 +358,9 @@ sub run_os_update
### See if the kernel has been updated. ### See if the kernel has been updated.
# Get the newest installed kernel # Get the newest installed kernel
my $shell_call = $anvil->data->{path}{exe}{rpm}." -q kernel | ".$anvil->data->{path}{exe}{'sort'}." | ".$anvil->data->{path}{exe}{tail}." -n 1"; $shell_call = $anvil->data->{path}{exe}{rpm}." -q kernel | ".$anvil->data->{path}{exe}{'sort'}." | ".$anvil->data->{path}{exe}{tail}." -n 1";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($installed_kernel, $return_code) = $anvil->System->call({shell_call => $shell_call}); (my $installed_kernel, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
installed_kernel => $installed_kernel, installed_kernel => $installed_kernel,
return_code => $return_code, return_code => $return_code,

@ -120,8 +120,6 @@ manage_daemons($anvil, "stop");
# Update systems # Update systems
update_strikers_and_dr($anvil); update_strikers_and_dr($anvil);
die;
# Update DR Host # Update DR Host
update_nodes($anvil); update_nodes($anvil);
@ -342,10 +340,10 @@ sub update_nodes
{ {
if (time > $next_log) if (time > $next_log)
{ {
$anvil->Database->get_job_details({job_uuid => $job_uuid}); $anvil->Job->get_job_details({job_uuid => $job_uuid});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"jobs::job_progress" => $anvil->data->{jobs}{job_progress}, "jobs::job_progress" => $anvil->data->{jobs}{job_progress},
"jobs::job_status" => $anvil->data->{jobs}{job_status}, "jobs::job_data" => $anvil->data->{jobs}{job_data},
}}); }});
if ($anvil->data->{jobs}{job_progress} == 0) if ($anvil->data->{jobs}{job_progress} == 0)
{ {
@ -380,6 +378,7 @@ sub update_nodes
{ {
$shell_call .= " --clear-cache"; $shell_call .= " --clear-cache";
} }
$shell_call .= $anvil->Log->switches();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
$job_uuid = ""; $job_uuid = "";
$job_uuid = $anvil->Database->insert_or_update_jobs({ $job_uuid = $anvil->Database->insert_or_update_jobs({
@ -400,10 +399,10 @@ sub update_nodes
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { next_log => $next_log }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { next_log => $next_log }});
while ($waiting) while ($waiting)
{ {
$anvil->Database->get_job_details({job_uuid => $job_uuid}); $anvil->Job->get_job_details({job_uuid => $job_uuid});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"jobs::job_progress" => $anvil->data->{jobs}{job_progress}, "jobs::job_progress" => $anvil->data->{jobs}{job_progress},
"jobs::job_status" => $anvil->data->{jobs}{job_status}, "jobs::job_data" => $anvil->data->{jobs}{job_data},
}}); }});
if ($anvil->data->{jobs}{job_progress} == 100) if ($anvil->data->{jobs}{job_progress} == 100)
{ {
@ -412,7 +411,7 @@ sub update_nodes
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { waiting => $waiting }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { waiting => $waiting }});
# Did it reboot? # Did it reboot?
if ($anvil->data->{jobs}{job_status} eq "rebooted") if ($anvil->data->{jobs}{job_data} eq "rebooted")
{ {
$rebooted = 1; $rebooted = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { rebooted => $rebooted }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { rebooted => $rebooted }});
@ -821,6 +820,7 @@ sub update_strikers_and_dr
{ {
$shell_call .= " --clear-cache"; $shell_call .= " --clear-cache";
} }
$shell_call .= $anvil->Log->switches();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my $job_uuid = $anvil->Database->insert_or_update_jobs({ my $job_uuid = $anvil->Database->insert_or_update_jobs({
debug => 2, debug => 2,
@ -864,10 +864,10 @@ sub update_strikers_and_dr
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { next_log => $next_log }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { next_log => $next_log }});
while ($waiting) while ($waiting)
{ {
$anvil->Database->get_job_details({job_uuid => $job_uuid}); $anvil->Job->get_job_details({job_uuid => $job_uuid});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"jobs::job_progress" => $anvil->data->{jobs}{job_progress}, "jobs::job_progress" => $anvil->data->{jobs}{job_progress},
"jobs::job_status" => $anvil->data->{jobs}{job_status}, "jobs::job_data" => $anvil->data->{jobs}{job_data},
}}); }});
if ($anvil->data->{jobs}{job_progress} == 100) if ($anvil->data->{jobs}{job_progress} == 100)
{ {
@ -876,7 +876,7 @@ sub update_strikers_and_dr
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { waiting => $waiting }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { waiting => $waiting }});
# Did it reboot? # Did it reboot?
if ($anvil->data->{jobs}{job_status} eq "rebooted") if ($anvil->data->{jobs}{job_data} eq "rebooted")
{ {
$rebooted = 1; $rebooted = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { rebooted => $rebooted }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { rebooted => $rebooted }});

Loading…
Cancel
Save