Merge pull request #362 from ClusterLabs/anvil-tools-dev

* Updated anvil-update-system to detect kmod-drbd upgrade problems an…
main
Digimer 1 year ago committed by GitHub
commit 5f40522cdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      man/anvil-update-system.8
  2. 10
      man/striker-update-cluster.8
  3. 4
      share/words.xml
  4. 228
      tools/anvil-manage-server-storage
  5. 102
      tools/anvil-update-system
  6. 64
      tools/striker-update-cluster

@ -32,6 +32,10 @@ This will force the dnf cache to be cleared before the OS update is started. Thi
\fB\-\-no\-reboot\fR
.TP
If the kernel is updated, the system will normally be rebooted. This switch prevents the reboot from occuring.
.TP
\fB\-\-reboot\fR
.TP
Normally, the system will only reboot if the kernel is updated. If this is used, and if any packages are updated, then a reboot will be performed. This is recommended in most cases.
.IP
.SH AUTHOR
Written by Madison Kelly, Alteeve staff and the Anvil! project contributors.

@ -45,7 +45,15 @@ If the kernel is updated on a remote system, the system will normally be reboote
.TP
\fB\-\-reboot\-self\fR
.TP
By default, if the local system needs to be updated, a message is printed but the local system is NOT rebooted. This switch will instead cause this host to reboot at the end of the cluster update.
By default, if the kenrel on the local system is updated, and so a reboot is needed, a message is printed but the local system is NOT rebooted. This switch will instead cause this host to reboot at the end of the cluster update.
.TP
See \fB\-\-reboot\fR for rebooting if anything is updated.
.TP
\fB\-\-reboot\fR
.TP
Normally, the system will only reboot if the kernel is updated. If this is used, and if any packages are updated, then a reboot will be performed. This is recommended in most cases.
.TP
Must be used with \fB\-\-reboot\-self\fR to reboot the local system. Otherwise, it is passed along to target machines via their anvil-update-system calls.
.IP
.SH AUTHOR
Written by Madison Kelly, Alteeve staff and the Anvil! project contributors.

@ -2916,6 +2916,10 @@ Proceed? [y/N]</key>
<key name="message_0317">The kernel was updated, so a reboot is required. Rebooting now.</key>
<key name="message_0318">Registering a job to reboot this host.</key>
<key name="message_0319">Preparing to update the entire Anvil! cluster.</key>
<key name="message_0320">It looks like there's a kmod-drbd package conflict. Removing old packages and trying to reinstall.</key>
<key name="message_0321">Removing the old drbd-kmod RPMs now.</key>
<key name="message_0322">Installing the latest DRBD kmod RPM now.</key>
<key name="message_0323">Retrying the OS update now.</key>
<!-- Translate names (protocols, etc) -->
<key name="name_0001">Normal Password</key> <!-- none in mail-server -->

@ -998,7 +998,7 @@ sub manage_disk_add
# Find which node is currently Primary and use that host to force primary to start sync. If none,
# force here.
print "- Waiting for all peers to connect the new volume...";
print "- Waiting for all peers to connect the new volume...\n";
my $waiting = 1;
my $wait_until = time + 300;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { wait_until => $wait_until }});
@ -1050,6 +1050,7 @@ sub manage_disk_add
}});
foreach my $peer_name (sort {$a cmp $b} keys %{$anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}})
{
next if not defined $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{volume}{$next_drbd_volume}{'peer-disk-state'};
my $peer_disk_state = $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{volume}{$next_drbd_volume}{'peer-disk-state'};
my $replication_state = $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{volume}{$next_drbd_volume}{'replication-state'};
my $role = $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{'peer-role'};
@ -1059,6 +1060,22 @@ sub manage_disk_add
's3:replication_state' => $replication_state,
's4:role' => $role,
}});
# If the volume is 'Negotiating', disconnect and reconnect the peer.
if (lc($peer_disk_state) eq "negotiating")
{
print "- Problem!\n";
($peer_disk_state, $role) = reconnect_resource($anvil, $short_host_name, $peer_name, $drbd_resource, $next_drbd_volume);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
peer_disk_state => $peer_disk_state,
role => $role,
}});
$disks_ready = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { disks_ready => $disks_ready }});
}
# If it's not established, keep waiting
if (lc($replication_state) ne "established")
{
$disks_ready = 0;
@ -1088,13 +1105,12 @@ sub manage_disk_add
{
if (time > $wait_until)
{
print " Failed!\n[ Error ] - The peers did not connect in the expected period of time.\n";
print "\nFailed!\n[ Error ] - The peers did not connect in the expected period of time.\n";
$anvil->nice_exit({exit_code => 1});
}
sleep 2;
}
}
print " Done!\n";
print "- Peers are connected! Checking if the new volume requires initial sync.\n";
my $all_inconsistent = 1;
@ -1108,6 +1124,7 @@ sub manage_disk_add
disk_state => $disk_state,
role => $role,
}});
if (lc($disk_state) ne "inconsistent")
{
$all_inconsistent = 0;
@ -1123,11 +1140,9 @@ sub manage_disk_add
if ($all_inconsistent)
{
print "- Initial sync required!\n";
my $shell_call = $anvil->data->{path}{exe}{drbdadm}." primary ".$drbd_resource." --force";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
print Dumper %{$anvil->data->{peers}};
die;
my $shell_call = $anvil->data->{path}{exe}{drbdadm}." new-current-uuid --force-resync ".$drbd_resource."/".$next_drbd_volume;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
# Which node should be forced primary?
my $already_primary = 1;
@ -1227,7 +1242,7 @@ sub manage_disk_add
}
else
{
print "Initial sync does not appear to be required.\n";
print "- Initial sync does not appear to be required.\n";
}
# Is the server running? If so, where.
@ -1299,9 +1314,12 @@ sub manage_disk_add
$shell_call .= "/dev/drbd/by-res/".$drbd_resource."/".$next_drbd_volume." ".$new_device_target." ";
$shell_call .= "--persistent --targetbus ".$disk_device_bus." ";
$shell_call .= "--cache ".$disk_cache." ";
$shell_call .= "--io ".$disk_io_policy;
$shell_call .= "--io ".$disk_io_policy." ";
$shell_call .= "--sourcetype block --subdriver raw";
$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 => {
offline => $offline,
shell_call => $shell_call,
}});
if ($offline)
{
# Define the VM, if needed, then add the drive, dump the config and push it out.
@ -1329,15 +1347,57 @@ sub manage_disk_add
if ($host_uuid eq $anvil->Get->host_uuid)
{
# Do the add here.
update_definition($anvil, "define", "");
print "- Adding the drive to the server directly...\n";
($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,
}});
if ($return_code)
{
# Something went wrong.
print "- Failed!\n";
print "Expected the return code '0', but got: [".$return_code."]. The command output, if anything, was:\n";
print "========\n";
print $output."\n";
print "========\n";
$anvil->nice_exit({exit_code => 1});
}
# Get the new XML
print "- Reading the updated server definition\n";
$shell_call = $anvil->data->{path}{exe}{setsid}." --wait ".$anvil->data->{path}{exe}{virsh}." dumpxml --inactive ".$server_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
(my $virsh_definition, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
virsh_definition => $virsh_definition,
return_code => $return_code,
}});
# Make sure the $output is valid XML.
print "- Validating the updated definition\n";
my $problem = $anvil->Server->parse_definition({
server => $server_name,
source => "from_virsh",
definition => $virsh_definition,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }});
if ($problem)
{
# Failed?!
print "
[ Error ] - The definition file read hear appears to be invalid after trying to attach the disk! It is unsafe
[ Error ] - to update the on disk and in DB definition. It's likely the attach has failed.
[ Error ] - Manual update to the server is likely required now.
";
$anvil->nice_exit({exit_code => 1});
}
print "- Updating the stored definition and undefining the server now...\n";
update_definition($anvil, "undefine", "");
update_definition($anvil, "undefine", $virsh_definition);
print "Done!\n";
$anvil->nice_exit({exit_code => 0});
}
@ -1389,6 +1449,11 @@ sub manage_disk_add
$anvil->nice_exit({exit_code => 1});
}
$anvil->data->{server}{$short_host_name}{$server_name}{from_virsh}{xml} = $virsh_definition;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"server::${short_host_name}::${server_name}::from_virsh::xml" => $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh}{xml},
}});
print "- Updating the stored definition and undefining the server now...\n";
update_definition($anvil, "undefine", $virsh_definition);
print "Done!\n";
@ -1399,6 +1464,127 @@ sub manage_disk_add
return(0);
}
sub reconnect_resource
{
my ($anvil, $short_host_name, $peer_name, $drbd_resource, $next_drbd_volume) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
short_host_name => $short_host_name,
peer_name => $peer_name,
drbd_resource => $drbd_resource,
next_drbd_volume => $next_drbd_volume,
}});
my $peer_disk_state = "";
my $role = "";
# Log into the peer and disconnect, then reconnect. Then wait for the disk state to update, and
# return the disk state.
print " - The peer: [".$peer_name."], is stuck 'Negotiating'; disconnecting... ";
my $use_ip = $anvil->data->{peer}{$peer_name}{access}{ip};
my $shell_call = $anvil->data->{path}{exe}{drbdadm}." disconnect ".$drbd_resource;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
use_ip => $use_ip,
shell_call => $shell_call,
}});
my ($output, $error, $return_code) = $anvil->Remote->call({
shell_call => $shell_call,
target => $use_ip,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
error => $error,
return_code => $return_code,
}});
print " reconnecting... ";
sleep 1;
$shell_call = $anvil->data->{path}{exe}{drbdadm}." connect ".$drbd_resource;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
use_ip => $use_ip,
shell_call => $shell_call,
}});
($output, $error, $return_code) = $anvil->Remote->call({
shell_call => $shell_call,
target => $use_ip,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
error => $error,
return_code => $return_code,
}});
print " Done.\n";
# Now wait
print "- Waiting for the disk state to be updated:\n";
my $waiting = 1;
my $wait_until = time + 300;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { wait_until => $wait_until }});
while ($waiting)
{
$anvil->DRBD->get_status({debug => 2});
my $disks_ready = 1;
my $connection_state = $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{'connection-state'};
if (not defined $connection_state)
{
print "Short host name: [".$short_host_name."], resource: [".$drbd_resource."], peer: [".$peer_name."]\n";
print Dumper %{$anvil->data->{drbd}{status}};
die;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { connection_state => $connection_state }});
if (lc($connection_state) eq "connected")
{
# Connected, what's the disk state for the new volume now?
print " - Connected, checking volume: [".$drbd_resource."/".$next_drbd_volume."] disk state: ";
$peer_disk_state = $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{volume}{$next_drbd_volume}{'peer-disk-state'};
my $replication_state = $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{volume}{$next_drbd_volume}{'replication-state'};
$role = $anvil->data->{drbd}{status}{$short_host_name}{resource}{$drbd_resource}{connection}{$peer_name}{'peer-role'};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:peer_disk_state' => $peer_disk_state,
's2:replication_state' => $replication_state,
's3:role' => $role,
}});
if (lc($replication_state) ne "established")
{
print "Not Connected yet.\n";
$disks_ready = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { disks_ready => $disks_ready }});
}
elsif ((not $peer_disk_state) or (lc($peer_disk_state) eq "diskless"))
{
print "Disk not ready yet.\n";
$disks_ready = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { disks_ready => $disks_ready }});
}
if ($disks_ready)
{
print "Ready!\n- Disk state is: [".$peer_disk_state."]\n";
$waiting = 0;
$anvil->data->{peers}{$peer_name}{disk_state} = $peer_disk_state;
$anvil->data->{peers}{$peer_name}{role} = $role;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
waiting => 0,
"peers::${peer_name}::disk_state" => $anvil->data->{peers}{$peer_name}{disk_state},
"peers::${peer_name}::role" => $anvil->data->{peers}{$peer_name}{role},
}});
return($peer_disk_state, $role);
}
}
if (time > $wait_until)
{
$waiting = 0;
print "- Timed out waiting for the peer to connect.\n";
return($peer_disk_state, $role);
}
sleep 3;
}
return($peer_disk_state, $role);
}
sub manage_disk_grow
{
my ($anvil, $drbd_resource, $drbd_volume, $max_free_space) = @_;
@ -2400,7 +2586,6 @@ sub update_definition
my $short_host_name = $anvil->Get->short_host_name;
my $server_name = $anvil->data->{switches}{server_name};
my $server_uuid = $anvil->data->{switches}{server_uuid};
my $server_definition = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_definition_xml};
my $server_host_uuid = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_host_uuid};
my $server_state = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_state};
my $definition_file = $anvil->data->{path}{directories}{shared}{definitions}."/".$server_name.".xml";
@ -2409,7 +2594,6 @@ sub update_definition
's1:short_host_name' => $short_host_name,
's2:server_name' => $server_name,
's3:server_uuid' => $server_uuid,
's4:server_definition' => $server_definition,
's5:server_host_uuid' => $server_host_uuid,
's6:server_state' => $server_state,
's7:definition_file' => $definition_file,
@ -2440,7 +2624,23 @@ sub update_definition
my $disk_definition = $anvil->data->{server}{$short_host_name}{$server_name}{from_disk}{xml} ? $anvil->data->{server}{$short_host_name}{$server_name}{from_disk}{xml} : "";
my $virsh_definition = $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh}{xml} ? $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh}{xml} : "";
my $use_definition = $virsh_definition;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:disk_definition' => $disk_definition,
's2:virsh_definition' => $virsh_definition,
}});
my $use_definition = "";
if ($definition)
{
# Use the passed in definition.
$use_definition = $definition;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { use_definition => $use_definition }});
}
else
{
$use_definition = $virsh_definition;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { use_definition => $use_definition }});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { use_definition => $use_definition }});
if (not $use_definition)
{
if (($server_running_here) or (($server_state eq "running") && ($virsh_definition)))

@ -40,7 +40,8 @@ my $anvil = Anvil::Tools->new();
# Read switches (target ([user@]host[:port]) and the file with the target's password.
$anvil->Get->switches({list => [
"clear-cache",
"no-reboot"], man => $THIS_FILE});
"no-reboot",
"reboot"], man => $THIS_FILE});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
@ -86,7 +87,7 @@ update_progress($anvil, 2, "message_0033");
$anvil->System->maintenance_mode({set => 1});
# Run the update
run_os_update($anvil);
run_os_update($anvil, 1, 3);
# We're done updating
my $reboot_needed = $anvil->System->reboot_needed({debug => 2});
@ -168,6 +169,7 @@ sub update_progress
{
$anvil->Job->update_progress({
debug => 3,
'print' => 1,
progress => $progress,
message => $message,
job_uuid => $anvil->data->{jobs}{job_uuid},
@ -180,7 +182,11 @@ sub update_progress
# This updates the OS.
sub run_os_update
{
my ($anvil) = @_;
my ($anvil, $try, $progress) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
try => $try,
progress => $progress,
}});
# This needs to be set to avoid warnings when called without a job-uuid.
$anvil->data->{sys}{last_update} = 0;
@ -191,14 +197,14 @@ sub run_os_update
if ($host_type eq "node")
{
# Call anvil-safe-stop
update_progress($anvil, 3, "message_0314");
update_progress($anvil, $progress++, "message_0314");
my $problem = $anvil->Cluster->parse_cib({debug => 3});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { problem => $problem }});
if (not $problem)
{
# Call anvil-safe-stop
update_progress($anvil, 4, "message_0315");
update_progress($anvil, $progress++, "message_0315");
my $shell_call = $anvil->data->{path}{exe}{'anvil-safe-stop'};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
@ -251,11 +257,11 @@ WHERE
}
# NOTE: We run this directly to better monitor progress and update the progress.
my $package_changes = 0;
my $transaction_shown = 0;
my $success = 0;
my $to_update = 0;
my $percent_step = 0;
my $progress = 6;
my $counted_lines = 0;
my $next_step = 0;
my $verifying = 0;
@ -309,8 +315,10 @@ WHERE
if ($line =~ / (\d+) Packages$/i)
{
my $counted_lines = $1;
$package_changes = $counted_lines;
$to_update += $counted_lines;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
package_changes => $package_changes,
counted_lines => $counted_lines,
to_update => $to_update,
}});
@ -384,6 +392,76 @@ WHERE
}
close $file_handle;
# If this is the first try and it failed, see if it's a DRBD issue.
if ((not $success) && ($try == 1))
{
# Is this the DRBD kmod issue?
my $remove_drbd_kmod = 0;
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /kmod-drbd/)
{
# Looks like it.
$remove_drbd_kmod = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { remove_drbd_kmod => $remove_drbd_kmod }});
last;
}
}
# Clear the old kmod and try the update again.
if ($remove_drbd_kmod)
{
update_progress($anvil, $progress++, "message_0320");
my $versions_to_remove = "";
my $shell_call = $anvil->data->{path}{exe}{dnf}." list installed";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($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,
}});
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /(kmod-drbd-\d+.*?)\s/)
{
$versions_to_remove .= $1." ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { versions_to_remove => $versions_to_remove }});
}
}
# Now remove those packages.
update_progress($anvil, $progress++, "message_0321");
$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 }});
($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,
}});
# Now install the new packages.
update_progress($anvil, $progress++, "message_0322");
$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,
}});
# Now try again.
update_progress($anvil, $progress++, "message_0323");
run_os_update($anvil, 2, $progress);
return(0);
}
}
# 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__});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { systemctl_output => $systemctl_output, return_code => $return_code }});
@ -419,6 +497,15 @@ WHERE
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
}
# If we installed and packages, and '--reboot' was given, reboot anyway.
if (($package_changes) && ($anvil->data->{switches}{reboot}))
{
# Reboot needed
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0687", variables => { reason => "#!string!log_0690!#" }});
my $reboot_needed = $anvil->System->reboot_needed({set => 1});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
}
# Did it work?
if (not $success)
{
@ -426,6 +513,7 @@ WHERE
update_progress($anvil, 0, "message_0036");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => 0, key => "error_0035", variables => { output => $output } });
sleep 5;
$anvil->nice_exit({exit_code => 3});
}

@ -44,6 +44,7 @@ $anvil->Get->switches({list => [
"clear-cache",
"force",
"no-reboot",
"reboot",
"reboot-self",
"y",
"yes"], man => $THIS_FILE});
@ -407,6 +408,10 @@ sub update_nodes
{
$shell_call .= " --clear-cache";
}
if ($anvil->data->{switches}{reboot})
{
$shell_call .= " --reboot";
}
$shell_call .= $anvil->Log->switches();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
$job_uuid = "";
@ -758,35 +763,15 @@ sub update_strikers_and_dr
print "- Beginning OS update of: [".$short_host_name."]\n";
my $rebooted = 0;
my $output = "";
my $error = "";
my $return_code = "";
if ($anvil->data->{switches}{'clear-cache'})
if (($anvil->data->{switches}{'clear-cache'}) && ($host_uuid eq $anvil->Get->host_uuid))
{
my $shell_call = $anvil->data->{path}{exe}{dnf}." clean all";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
if ($host_uuid eq $anvil->Get->host_uuid)
{
($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,
}});
}
else
{
($output, $error, $return_code) = $anvil->Remote->call({
timeout => 0,
no_cache => 1,
shell_call => $shell_call,
target => $anvil->data->{peer}{$short_host_name}{access}{ip},
});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
error => $error,
return_code => $return_code,
}});
}
print "- Cache cleared.\n";
}
print "- Calling update now.\n";
@ -810,6 +795,31 @@ sub update_strikers_and_dr
print "==============\n";
}
# Loop through the output.
my $package_changes = 0;
foreach my $line (split/\n/, $output)
{
$line = $anvil->Words->clean_spaces({string => $line});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ / (\d+) Packages$/i)
{
$package_changes += $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { package_changes => $package_changes }});
}
}
# Did the user want to reboot on any update?
if (($package_changes) && ($anvil->data->{switches}{reboot}) && ($anvil->data->{switches}{'reboot-self'}))
{
# Reboot needed
print "- Updated: [".$package_changes."] packages, and '--reboot --reboot-self' used, reboot needed!\n";
$anvil->data->{sys}{reboot_needed} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"sys::reboot_needed" => $anvil->data->{sys}{reboot_needed},
}});
}
# Get the newest installed kernel
$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 }});
@ -858,6 +868,10 @@ sub update_strikers_and_dr
{
$shell_call .= " --clear-cache";
}
if ($anvil->data->{switches}{reboot})
{
$shell_call .= " --reboot";
}
$shell_call .= $anvil->Log->switches();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my $job_uuid = $anvil->Database->insert_or_update_jobs({
@ -961,9 +975,9 @@ sub update_strikers_and_dr
# Run anvil-version-change
print "- Running 'anvil-version-changes' now.\n";
$output = "";
$error = "";
$return_code = "";
my $output = "";
my $error = "";
my $return_code = "";
my $shell_call = $anvil->data->{path}{exe}{'anvil-version-changes'};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
if ($host_uuid eq $anvil->Get->host_uuid)

Loading…
Cancel
Save