@ -191,6 +191,9 @@ WHERE
# Register a job to reboot.
# Register a job to reboot.
update_progress($anvil, 98, "message_0318");
update_progress($anvil, 98, "message_0318");
# Record that we're going to reboot now.
update_progress($anvil, 100, "message_0317");
if ($anvil->data->{sys}{database}{connections})
if ($anvil->data->{sys}{database}{connections})
{
{
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
@ -202,12 +205,16 @@ WHERE
job_title => "job_0009",
job_title => "job_0009",
job_description => "job_0006",
job_description => "job_0006",
job_progress => 0,
job_progress => 0,
job_status => "anvil_startup",
});
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
}
# Record that we're going to reboot now.
# If we got a job UUID, unlink the cache file.
update_progress($anvil, 100, "message_0317");
if (-e $anvil->data->{path}{data}{reboot_cache})
{
unlink $anvil->data->{path}{data}{reboot_cache};
}
}
}
}
else
else
{
{
@ -242,6 +249,12 @@ sub update_progress
"jobs::job_uuid" => $anvil->data->{jobs}{job_uuid},
"jobs::job_uuid" => $anvil->data->{jobs}{job_uuid},
}});
}});
if ($progress > 100)
{
$progress = 100;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { progress => $progress }});
}
if ($anvil->data->{jobs}{job_uuid})
if ($anvil->data->{jobs}{job_uuid})
{
{
$anvil->Job->update_progress({
$anvil->Job->update_progress({
@ -260,24 +273,21 @@ sub update_progress
sub run_os_update
sub run_os_update
{
{
my ($anvil, $progress) = @_;
my ($anvil, $progress) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { progress => $progress }});
try => $try,
progress => $progress,
}});
# This needs to be set to avoid warnings when called without a job-uuid.
# This needs to be set to avoid warnings when called without a job-uuid.
$anvil->data->{sys}{last_update} = 0;
$anvil->data->{sys}{last_update} = 0;
# Make sure that, if we're a node, we're out of the cluster.
# Make sure that, if we're a node, we're out of the cluster.
my $host_type = $anvil->Get->host_type();
my $host_type = $anvil->Get->host_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { host_type => $host_type }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { host_type => $host_type }});
if ($host_type eq "node")
if ($host_type eq "node")
{
{
# Call anvil-safe-stop
# Call anvil-safe-stop
update_progress($anvil, $progress++, "message_0314");
update_progress($anvil, $progress++, "message_0314");
my $problem = $anvil->Cluster->parse_cib({debug => 3} );
my $problem = $anvil->Cluster->parse_cib();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { problem => $problem }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { problem => $problem }});
if (not $problem)
if (not $problem)
{
{
# Call anvil-safe-stop
# Call anvil-safe-stop
@ -334,15 +344,14 @@ WHERE
}
}
# Before we start, do we need to remove our locally build DRBD kernel modules?
# Before we start, do we need to remove our locally build DRBD kernel modules?
my $package_changes = 0;
my $remove_drbd_kmod = 0;
my $remove_drbd_kmod = 0;
my $shell_call = $anvil->data->{path}{exe}{dnf}." check-update";
my $shell_call = $anvil->data->{path}{exe}{dnf}." check-update";
open (my $file_handle, $shell_call." 2>&1 |") or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
open (my $file_handle, $shell_call." 2>&1 |") or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
while(<$file_handle>)
{
{
chomp;
chomp;
my $line = $_;
my $line = $anvil->Words->clean_spaces({string => $_});
$output .= $line."\n";
$line = $anvil->Words->clean_spaces({string => $line});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if (($line =~ /kmod-drbd/) or ($line =~ /kernel/))
if (($line =~ /kmod-drbd/) or ($line =~ /kernel/))
@ -359,6 +368,7 @@ WHERE
# So, shall we?
# So, shall we?
if ($remove_drbd_kmod)
if ($remove_drbd_kmod)
{
{
# Yes, remove
update_progress($anvil, $progress++, "message_0320");
update_progress($anvil, $progress++, "message_0320");
my $versions_to_remove = "";
my $versions_to_remove = "";
my $shell_call = $anvil->data->{path}{exe}{dnf}." list installed";
my $shell_call = $anvil->data->{path}{exe}{dnf}." list installed";
@ -375,7 +385,11 @@ WHERE
if ($line =~ /(kmod-drbd-\d+.*?)\s/)
if ($line =~ /(kmod-drbd-\d+.*?)\s/)
{
{
$versions_to_remove .= $1." ";
$versions_to_remove .= $1." ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { versions_to_remove => $versions_to_remove }});
$package_changes++;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
versions_to_remove => $versions_to_remove,
package_changes => $package_changes,
}});
}
}
}
}
@ -384,26 +398,17 @@ WHERE
$shell_call = $anvil->data->{path}{exe}{dnf}." -y remove ".$versions_to_remove;
$shell_call = $anvil->data->{path}{exe}{dnf}." -y remove ".$versions_to_remove;
$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 }});
($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
open ($file_handle, $shell_call." 2>&1 |") or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
while(<$file_handle>)
output => $output,
{
return_code => $return_code,
chomp;
}});
my $line = $anvil->Words->clean_spaces({string => $_});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
# # Now install the new packages.
}
# update_progress($anvil, $progress++, "message_0322");
close $file_handle;
# $shell_call = $anvil->data->{path}{exe}{dnf}." -y install kmod-drbd";
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
#
# ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
# output => $output,
# return_code => $return_code,
# }});
}
}
# NOTE: We run this directly to better monitor progress and update the progress.
# NOTE: We run this directly to better monitor progress and update the progress.
my $package_changes = 0;
my $transaction_shown = 0;
my $transaction_shown = 0;
my $success = 0;
my $success = 0;
my $to_update = 0;
my $to_update = 0;
@ -434,7 +439,7 @@ WHERE
{
{
# Update done, verifying now.
# Update done, verifying now.
$verifying = 1;
$verifying = 1;
update_progress($anvil, $progress, "message_0038");
update_progress($anvil, $progress++ , "message_0038");
}
}
if ($line =~ /Running transaction/i)
if ($line =~ /Running transaction/i)
@ -442,7 +447,7 @@ WHERE
# Done downloading
# Done downloading
if (not $transaction_shown)
if (not $transaction_shown)
{
{
update_progress($anvil, $progress, "message_0037");
update_progress($anvil, $progress++ , "message_0037");
$transaction_shown = 1;
$transaction_shown = 1;
}
}
}
}
@ -458,7 +463,7 @@ WHERE
}
}
}
}
if ($line =~ / (\d+) Packages$/i)
if (( $line =~ / (\d+) Packages$/i) or ($line =~ / (\d+) Package$/i) )
{
{
my $counted_lines = $1;
my $counted_lines = $1;
$package_changes = $counted_lines;
$package_changes = $counted_lines;
@ -476,7 +481,7 @@ WHERE
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update_size => $update_size }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update_size => $update_size }});
# Ready to install, update to 5%. The next step will count up to 95%.
# Ready to install, update to 5%. The next step will count up to 95%.
update_progress($anvil, $progress, "message_0035,!!size!$update_size!!");
update_progress($anvil, $progress++ , "message_0035,!!size!$update_size!!");
# The total (reliable) count of events is (to_update * 3), counting '(x/y): '
# The total (reliable) count of events is (to_update * 3), counting '(x/y): '
# (download), 'Upgrading '/'Installing ' and 'Verifying '. We ignore the scriplet
# (download), 'Upgrading '/'Installing ' and 'Verifying '. We ignore the scriplet
@ -539,8 +544,10 @@ WHERE
close $file_handle;
close $file_handle;
# Reload daemons to pick up any changed systemctl daemons.
# Reload daemons to pick up any changed systemctl daemons.
my ($systemctl_output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{systemctl}." daemon-reload", source => $THIS_FILE, line => __LINE__});
$shell_call = $anvil->data->{path}{exe}{systemctl}." daemon-reload";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { systemctl_output => $systemctl_output, return_code => $return_code }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($systemctl_output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { systemctl_output => $systemctl_output, return_code => $return_code }});
### See if the kernel has been updated.
### See if the kernel has been updated.
# Get the newest installed kernel
# Get the newest installed kernel