From fcbace6713a785e03cf63a7707ff6895d0d6726b Mon Sep 17 00:00:00 2001 From: digimer Date: Thu, 28 Sep 2023 16:01:32 -0400 Subject: [PATCH] Updated anvil-join-anvil to hold if either node is still running anvil-configure-host * Fixed a minor bug and added logging of maintenance_mode calls in anvil-configure-host. Signed-off-by: digimer --- share/words.xml | 2 +- tools/anvil-configure-host | 6 +++--- tools/anvil-daemon | 2 +- tools/anvil-join-anvil | 33 +++++++++++++++++++++++++++------ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/share/words.xml b/share/words.xml index 6a0fc997..8da7a104 100644 --- a/share/words.xml +++ b/share/words.xml @@ -1686,7 +1686,7 @@ Note: This is a permanent action! If you protect this server again later, a full Server Storage Management This job manages the storage on a given hosted server. It can grow an existing disk, add a new disk, insert an ISO into an optical disc, or eject a disc. The server: [#!variable!server!#] will now be forced off! - The subnode: [#!variable!subnode!#] is not ready. Configured: [#!variable!configured!#], maintenance mode: [#!variable!maintenance_mode!#]. + The subnode: [#!variable!subnode!#] is not ready. Configured: [#!variable!configured!#], maintenance mode: [#!variable!maintenance_mode!#], job_running: [#!variable!job_running!#]. Waiting for a bit, then will check again. Waiting for both subnodes to be configured and out of maintenance mode. diff --git a/tools/anvil-configure-host b/tools/anvil-configure-host index 732e7158..e78a9dd8 100755 --- a/tools/anvil-configure-host +++ b/tools/anvil-configure-host @@ -64,7 +64,7 @@ pickup_job_details($anvil); overwrite_variables_with_switches($anvil); # Set maintenance mode -$anvil->System->maintenance_mode({set => 1}); +$anvil->System->maintenance_mode({set => 1, debug => 2}); reconfigure_network($anvil); @@ -88,7 +88,7 @@ $anvil->Job->update_progress({ }); # Clear maintenance mode. -$anvil->System->maintenance_mode({set => 0}); +$anvil->System->maintenance_mode({set => 0, debug => 2}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0467"}); ### TODO: As of now, the network doesn't come up reliably, so reboot. We add a 60 second delay to make it @@ -435,7 +435,7 @@ ORDER BY }}); # An undefined interface will have the MAC address value set to '1', ignore those. - next if $variable_value == 1; + next if $variable_value eq "1"; if ($variable_name =~ /form::config_step2::(.*?)_mac_to_set::value/) { diff --git a/tools/anvil-daemon b/tools/anvil-daemon index f1755bbb..df7a509b 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -577,7 +577,7 @@ sub handle_periodic_tasks check_db_in_use_states($anvil); # Do Striker-specific minute tasks - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { host_type => $host_type }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }}); if ($host_type eq "striker") { # This can take a while, but it's been optimized to minimize how long it takes to diff --git a/tools/anvil-join-anvil b/tools/anvil-join-anvil index 6ce721dc..6a0f5528 100755 --- a/tools/anvil-join-anvil +++ b/tools/anvil-join-anvil @@ -2409,7 +2409,7 @@ sub wait_for_subnodes my $ready = 1; foreach my $host_uuid ($node1_host_uuid, $node2_host_uuid) { - my $host_name = $anvil->data->{hosts}{host_uuid}{$node2_host_uuid}{host_name}; + my $host_name = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_name}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_uuid => $host_uuid, host_name => $host_name, @@ -2420,6 +2420,7 @@ sub wait_for_subnodes variable_source_table => "hosts", variable_source_uuid => $host_uuid, }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { maintenance_mode => $maintenance_mode }}); (my $configured, $variable_uuid, $modified_date) = $anvil->Database->read_variable({ variable_name => "system::configured", variable_source_uuid => $host_uuid, @@ -2427,12 +2428,31 @@ sub wait_for_subnodes }); $maintenance_mode = 1 if not defined $maintenance_mode; $configured = 0 if not defined $configured; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { - maintenance_mode => $maintenance_mode, - configured => $configured, - }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { configured => $configured }}); + + # Is anvil-configure-host running? + my $job_running = 0; + $anvil->Database->get_jobs({job_host_uuid => $host_uuid}); + foreach my $job_uuid (sort {$a cmp $b} keys %{$anvil->data->{jobs}{running}}) + { + my $job_command = $anvil->data->{jobs}{running}{$job_uuid}{job_command}; + my $job_data = $anvil->data->{jobs}{running}{$job_uuid}{job_data}; + my $job_progress = $anvil->data->{jobs}{running}{$job_uuid}{job_progress}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + 's1:job_uuid' => $job_uuid, + 's2:job_command' => $job_command, + 's3:job_data' => $job_data, + 's4:job_progress' => $job_progress, + }}); + next if $job_progress == 100; + if ($job_command =~ /anvil-configure-host/) + { + $job_running = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_running => $job_running }}); + } + } - if (($maintenance_mode) or (not $configured)) + if (($maintenance_mode) or ($job_running) or (not $configured)) { $ready = 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ready => $ready }}); @@ -2441,6 +2461,7 @@ sub wait_for_subnodes subnode => $host_name, configured => $configured, maintenance_mode => $maintenance_mode, + job_running => $job_running, }}); } }