* Fixed a bug in anvil-update-system where updating a single package with --reboot wouldn't request a reboot. Finished reworking it so that a check is made to see if the kernel or DRBD kmod will be updated and, if so, removes the kmod-drbd RPMs prior to doing the update (as opposed to the sloppier check-on-error method).

* Fixed a bug in System->reboot_needed() where the cache file path had a typo in the hash key.
* Updated anvil-daemon to use the full path to dnf when determining if a dnf process was running.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent e278de4b5a
commit 66c82e5e22
  1. 2
      Anvil/Tools/System.pm
  2. 1
      share/words.xml
  3. 2
      tools/anvil-daemon
  4. 81
      tools/anvil-update-system

@ -4460,7 +4460,7 @@ sub reboot_needed
my $set = defined $parameter->{set} ? $parameter->{set} : ""; my $set = defined $parameter->{set} ? $parameter->{set} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { set => $set }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { set => $set }});
my $cache_file = $anvil->data->{paths}{data}{reboot_cache}; my $cache_file = $anvil->data->{path}{data}{reboot_cache};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { cache_file => $cache_file }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { cache_file => $cache_file }});
if (($set) or ($set eq "0")) if (($set) or ($set eq "0"))
{ {

@ -2408,6 +2408,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0741">I was about to start: [#!variable!command!#] with the job UUID: [#!variable!this_job_uuid!#]. However, another job using the same command with the job UUID: [#!variable!other_job_uuid!#]. To avoid race conditions, only one process with a given command is run at the same time.</key> <key name="log_0741">I was about to start: [#!variable!command!#] with the job UUID: [#!variable!this_job_uuid!#]. However, another job using the same command with the job UUID: [#!variable!other_job_uuid!#]. To avoid race conditions, only one process with a given command is run at the same time.</key>
<key name="log_0742">The job with the command: [#!variable!command!#] and job UUID: [#!variable!job_uuid!#] is restarting.</key> <key name="log_0742">The job with the command: [#!variable!command!#] and job UUID: [#!variable!job_uuid!#] is restarting.</key>
<key name="log_0743">Will run without connecting to the databases. Some features will be unavailable.</key> <key name="log_0743">Will run without connecting to the databases. Some features will be unavailable.</key>
<key name="log_0744">A cached request to reboot this host was found (likely from a --no-db update). Registering a job to reboot now!</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. --> <!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key> <key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>

@ -266,7 +266,7 @@ sub wait_on_dnf
}}); }});
while ($waiting) while ($waiting)
{ {
my $pids = $anvil->System->pids({program_name => "dnf"}); my $pids = $anvil->System->pids({program_name => $anvil->data->{path}{exe}{dnf}});
my $dnf_instances = @{$pids}; my $dnf_instances = @{$pids};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dnf_instances => $dnf_instances }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dnf_instances => $dnf_instances }});

@ -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

Loading…
Cancel
Save