Second attempt to fix the storage group race condition. This time, we only let node 1 assemble storage groups.

Signed-off-by: digimer <mkelly@alteeve.ca>
This commit is contained in:
digimer 2023-05-01 20:29:20 -04:00
parent d64044c7d1
commit e483840ceb
2 changed files with 15 additions and 11 deletions

View File

@ -379,9 +379,6 @@ ORDER BY
scan_lvm_vg_internal_uuid => $scan_lvm_vg_internal_uuid,
}});
# Using previously loaded storage group data can be racy, so query group membership directly.
$anvil->Database->get_storage_group_data({debug => $debug});
# Skip VGs that are in a group already.
if ((exists $anvil->data->{storage_groups}{vg_uuid}{$scan_lvm_vg_internal_uuid}) &&
($anvil->data->{storage_groups}{vg_uuid}{$scan_lvm_vg_internal_uuid}{storage_group_uuid}))

View File

@ -516,20 +516,27 @@ 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};
$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,
's1:anvil_name' => $anvil_name,
's2:node1_host_uuid' => $node1_host_uuid,
's3:node2_host_uuid' => $node2_host_uuid,
's4:host_uuid' => $host_uuid,
}});
# This both loads storage group data and assembles ungrouped VGs into storage groups, when possible.
# 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;