From 41fb8baedae350d14baba679c1318f6bbcc05eef Mon Sep 17 00:00:00 2001 From: digimer Date: Mon, 27 Mar 2023 12:35:22 -0400 Subject: [PATCH] * Fixed a bug in Database->get_storage_group_data() that was deleting DR host storage group members. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 9 ++++++--- Anvil/Tools/Get.pm | 44 +++++++++-------------------------------- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index b5049a32..0f3d05e6 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -5866,7 +5866,7 @@ sub get_storage_group_data $anvil->Database->get_hosts({debug => $debug}); } - $query = " + $query = " SELECT a.storage_group_uuid, a.storage_group_anvil_uuid, @@ -6012,12 +6012,14 @@ WHERE my $internal_vg_uuid = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_internal_uuid}; my $vg_size = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_size}; my $vg_name = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_name}; + my $host_type = $anvil->data->{hosts}{host_uuid}{$this_host_uuid}{host_type}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { this_host_uuid => $this_host_uuid, storage_group_member_uuid => $storage_group_member_uuid, internal_vg_uuid => $internal_vg_uuid, vg_size => $anvil->Convert->add_commas({number => $vg_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size}).")", vg_name => $vg_name, + host_type => $host_type, }}); if ($vg_size > $size_to_match) @@ -6038,9 +6040,10 @@ WHERE $node2_seen = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { node2_seen => $node2_seen }}); } - else + elsif ($host_type eq "node") { - # This host doesn't belong in this group anymore. Delete it. + # This host is a node that isn't in the Anvil!, so it doesn't belong + # in this group anymore. Delete it. $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "warning_0130", variables => { storage_group_name => $group_name, host_name => $anvil->Get->host_name_from_uuid({host_uuid => $this_host_uuid}), diff --git a/Anvil/Tools/Get.pm b/Anvil/Tools/Get.pm index 50432e6a..a7d3c7d5 100644 --- a/Anvil/Tools/Get.pm +++ b/Anvil/Tools/Get.pm @@ -511,45 +511,20 @@ sub available_resources delete $anvil->data->{anvil_resources}{$anvil_uuid}; } - # Get the node UUIDs for this anvil. - my $query = " -SELECT - anvil_name, - anvil_node1_host_uuid, - anvil_node2_host_uuid -FROM - anvils -WHERE - anvil_uuid = ".$anvil->Database->quote($anvil_uuid)." -;"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); - my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); - my $count = @{$results}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - results => $results, - count => $count, - }}); - if (not $count) - { - # Not found. - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0169", variables => { anvil_uuid => $anvil_uuid }}); - return("!!error!!"); - } + # Load hosts and network bridges. This loads Anvil! data as well + $anvil->Database->get_hosts({debug => $debug}); + $anvil->Database->get_bridges({debug => $debug}); # Get the details. - my $anvil_name = $results->[0]->[0]; - my $node1_host_uuid = $results->[0]->[1]; - my $node2_host_uuid = $results->[0]->[2]; + my $anvil_name = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_name}; + my $node1_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node1_host_uuid}; + my $node2_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node2_host_uuid}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { anvil_name => $anvil_name, node1_host_uuid => $node1_host_uuid, node2_host_uuid => $node2_host_uuid, }}); - # Load hosts and network bridges - $anvil->Database->get_hosts({debug => $debug}); - $anvil->Database->get_bridges({debug => $debug}); - # This both loads storage group data and assembles ungrouped VGs into storage groups, when possible. $anvil->Cluster->assemble_storage_groups({ debug => $debug, @@ -560,7 +535,6 @@ WHERE $anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{cores} = 0; $anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{threads} = 0; $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{hardware} = 0; - foreach my $host_uuid ($node1_host_uuid, $node2_host_uuid) { my $this_is = "node1"; @@ -682,7 +656,7 @@ WHERE $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{allocated} = 0; $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{hardware} = $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available}; - $query = " + my $query = " SELECT server_name, server_ram_in_use @@ -693,8 +667,8 @@ WHERE ORDER BY server_name ASC;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); - $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); - $count = @{$results}; + my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); + my $count = @{$results}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { results => $results, count => $count,