Another attempt to resolve the stoage group race condition. This moves the check for auto-assembly to scan-lvm. It only works for the first assemble, after that the user can/should use anvil-manage-storage-groups.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 2 years ago
parent e483840ceb
commit 510db70253
  1. 9
      Anvil/Tools/Database.pm
  2. 13
      Anvil/Tools/Get.pm
  3. 48
      scancore-agents/scan-lvm/scan-lvm

@ -5900,7 +5900,6 @@ ORDER BY
my $storage_group_member_host_uuid = $row->[4];
my $storage_group_member_vg_uuid = $row->[5]; # This is the VG's internal UUID
my $storage_group_member_note = $row->[6]; # If this is 'DELETED', the link isn't used anymore
my $storage_group_member_host_name = $anvil->data->{hosts}{host_uuid}{$storage_group_member_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
storage_group_uuid => $storage_group_uuid,
storage_group_anvil_uuid => $storage_group_anvil_uuid,
@ -5909,6 +5908,14 @@ ORDER BY
storage_group_member_host_uuid => $storage_group_member_host_uuid,
storage_group_member_vg_uuid => $storage_group_member_vg_uuid,
storage_group_member_note => $storage_group_member_note,
}});
if (not exists $anvil->data->{hosts}{host_uuid}{$storage_group_member_host_uuid})
{
$anvil->Database->get_hosts({debug => $debug});
}
my $storage_group_member_host_name = $anvil->data->{hosts}{host_uuid}{$storage_group_member_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
storage_group_member_host_name => $storage_group_member_host_name,
}});

@ -516,7 +516,6 @@ sub available_resources
$anvil->Database->get_bridges({debug => $debug});
# Get the details.
my $host_uuid = $anvil->Get->host_uuid;
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};
@ -524,20 +523,8 @@ sub available_resources
's1:anvil_name' => $anvil_name,
's2:node1_host_uuid' => $node1_host_uuid,
's3:node2_host_uuid' => $node2_host_uuid,
's4:host_uuid' => $host_uuid,
}});
# If we're node 1, we'll try to assemble the storage group. Onle node 1 does this to help avoid race
# conditions. This both loads storage group data and assembles ungrouped VGs into storage groups,
# when possible.
if ($host_uuid eq $node1_host_uuid)
{
$anvil->Cluster->assemble_storage_groups({
debug => 2,
anvil_uuid => $anvil_uuid,
});
}
# This will store the available resources based on the least of the nodes.
$anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{cores} = 0;
$anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{threads} = 0;

@ -84,6 +84,9 @@ read_last_scan($anvil);
# Loog for changes
find_changes($anvil);
# Check storage for storage groups.
check_storage_groups($anvil);
# Shut down.
$anvil->ScanCore->agent_shutdown({agent => $THIS_FILE});
$anvil->nice_exit({exit_code => 0});
@ -93,6 +96,51 @@ $anvil->nice_exit({exit_code => 0});
# Functions #
#############################################################################################################
sub check_storage_groups
{
my ($anvil) = @_;
# Are we in an Anvil!? If so, are there any storage groups yet?
my $anvil_uuid = $anvil->Cluster->get_anvil_uuid();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }});
if ($anvil_uuid)
{
# If we're node 1, we'll try to assemble the storage group. Onle node 1 does this to help avoid race
# conditions. This both loads storage group data and assembles ungrouped VGs into storage groups,
# when possible.
$anvil->Database->get_anvils();
my $host_uuid = $anvil->Get->host_uuid;
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 => 2, list => {
's1:anvil_name' => $anvil_name,
's2:node1_host_uuid' => $node1_host_uuid,
's3:node2_host_uuid' => $node2_host_uuid,
's4:host_uuid' => $host_uuid,
}});
if ($host_uuid eq $node1_host_uuid)
{
# Are there any storage groups yet? If not, try to assemble one.
my $query = "SELECT COUNT(*) FROM storage_groups WHERE storage_group_anvil_uuid = ".$anvil->Database->quote($anvil_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $count = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { count => $count }});
if (not $count)
{
$anvil->Cluster->assemble_storage_groups({
debug => 2,
anvil_uuid => $anvil_uuid,
});
}
}
}
return(0);
}
sub find_changes
{
my ($anvil) = @_;

Loading…
Cancel
Save