From d68adb5b4ef4e21b7a66985f1ee43ad65a07a390 Mon Sep 17 00:00:00 2001 From: digimer Date: Mon, 24 Jul 2023 20:44:40 -0400 Subject: [PATCH] * Updated anvil-manage-power to not reboot if anvil-version-changes is running (which, if it's taking time, is generating new kmods). Signed-off-by: digimer --- Anvil/Tools/Cluster.pm | 2 +- share/words.xml | 1 + tools/anvil-manage-power | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Anvil/Tools/Cluster.pm b/Anvil/Tools/Cluster.pm index a50a68ab..63325d07 100644 --- a/Anvil/Tools/Cluster.pm +++ b/Anvil/Tools/Cluster.pm @@ -2441,7 +2441,7 @@ sub get_peers =head2 get_primary_host_uuid -This takes an Anvil! UUID and returns with the node's host UUID that is currently the "primary" node. That is to say, which node has the most servers running on it, by allocated RAM. For example, if node 1 has two servers, each with 8 GiB of RAN and node 2 has one VM with 32 GiB of RAM, node 2 will be considered primary as it would take longest to migrate servers off. +This takes an Anvil! UUID and returns with the node's host UUID that is currently the "primary" node. That is to say, which node has the most servers running on it, by allocated RAM. For example, if node 1 has two servers, each with 8 GiB of RAM and node 2 has one VM with 32 GiB of RAM, node 2 will be considered primary as it would take longest to migrate servers off. If all is equal, node 1 is considered primary. If only one node is a cluster member, it is considered primary. If neither node is up, an empty string is returned. diff --git a/share/words.xml b/share/words.xml index ab528f3f..c8b6ec65 100644 --- a/share/words.xml +++ b/share/words.xml @@ -2925,6 +2925,7 @@ Proceed? [y/N] Update almost complete. Picked this job up after a '--no-db' run, and now we have database access again. [ Note ] - It looks like 'dnf' (pid(s): [#!variable!pids!#]) is running, holding our start up until it's done (in case the system is being updated now). This daemon just started. Holding off starting jobs for another: [#!variable!will_start_in!#] second(s). + [ Note ] - It looks like 'anvil-version-changes' (pid(s): [#!variable!pids!#]) is running, holding off on power action until it's done (in case the system is being updated now or kernel modules are being built). Normal Password diff --git a/tools/anvil-manage-power b/tools/anvil-manage-power index 7b8eb093..45305905 100755 --- a/tools/anvil-manage-power +++ b/tools/anvil-manage-power @@ -244,6 +244,43 @@ sub do_poweroff host_status => $task eq "poweroff" ? "rebooting" : "stopping", }); + # Wait if anvil-version-change is running. + my $next_log = time - 1; + my $waiting = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + next_log => $next_log, + waiting => $waiting, + }}); + while ($waiting) + { + my $pids = $anvil->System->pids({program_name => $anvil->data->{path}{exe}{'anvil-version-changes'}}); + my $avc_instances = @{$pids}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { avc_instances => $avc_instances }}); + + if ($avc_instances) + { + if (time > $next_log) + { + my $say_pids = ""; + foreach my $pid (@{$pids}) + { + $say_pids .= $pid.", "; + } + $say_pids =~ s/, $//; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0325", variables => { pids => $say_pids }}); + + $next_log = time + 60; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { next_log => $next_log }}); + } + sleep 10; + } + else + { + $waiting = 0; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { waiting => $waiting }}); + } + } + # If we have a job UUID, mark that we're done. if ($job_uuid) {