From 3d7ce84c388a0eba069b7ad646dc9fd552881f5d Mon Sep 17 00:00:00 2001 From: Digimer Date: Sun, 31 Jan 2021 00:00:23 -0500 Subject: [PATCH] * Fixed a bug in Get->host_from_ip_address() where hosts that are no longer used are returned, meaning 2+ results could be returned after a node was replaced, meaning no host name was returned. * Fixed a bug in anvil-provision-server where forcing initialization of a new DRBD resource when running on node 2 would fail because the node ID in the drbdsetup command was hard-coded to be run from node 1. Signed-off-by: Digimer --- Anvil/Tools/Get.pm | 6 ++++-- tools/anvil-provision-server | 6 +++++- tools/test.pl | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Anvil/Tools/Get.pm b/Anvil/Tools/Get.pm index 340187ba..f29f2819 100644 --- a/Anvil/Tools/Get.pm +++ b/Anvil/Tools/Get.pm @@ -1255,11 +1255,13 @@ FROM ip_addresses b WHERE a.host_uuid = b.ip_address_host_uuid +AND + a.host_key != 'DELETED' AND b.ip_address_note != 'DELETED' AND - b.ip_address_address = ".$anvil->Database->quote($ip_address)."; -"; + b.ip_address_address = ".$anvil->Database->quote($ip_address)." +;"; $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}; diff --git a/tools/anvil-provision-server b/tools/anvil-provision-server index 0b034790..1da6ddd7 100755 --- a/tools/anvil-provision-server +++ b/tools/anvil-provision-server @@ -162,12 +162,16 @@ sub run_jobs $anvil->data->{job}{short_host_name} = $anvil->Get->short_host_name; $anvil->data->{job}{node1_short_host_name} = $anvil->data->{hosts}{host_uuid}{$node1_host_uuid}{short_host_name}; $anvil->data->{job}{node2_short_host_name} = $anvil->data->{hosts}{host_uuid}{$node2_host_uuid}{short_host_name}; + $anvil->data->{job}{drbd_local_node_id} = $host_uuid eq $node1_host_uuid ? 0 : 1; + $anvil->data->{job}{drbd_peer_node_id} = $host_uuid eq $node1_host_uuid ? 1 : 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'job::node1_host_uuid' => $anvil->data->{job}{node1_host_uuid}, 'job::node2_host_uuid' => $anvil->data->{job}{node2_host_uuid}, 'job::node1_short_host_name' => $anvil->data->{job}{node1_short_host_name}, 'job::node2_short_host_name' => $anvil->data->{job}{node2_short_host_name}, 'job::short_host_name' => $anvil->data->{job}{short_host_name}, + 'job::drbd_local_node_id' => $anvil->data->{job}{drbd_local_node_id}, + 'job::drbd_peer_node_id' => $anvil->data->{job}{drbd_peer_node_id}, }}); # We convert to extents as it ensure clean boundaries and, being based on bytes in both cases, gets @@ -676,7 +680,7 @@ sub startup_resource }); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "job_0195"}); - my $shell_call = $anvil->data->{path}{exe}{drbdsetup}." net-options ".$anvil->data->{job}{server_name}." 1 --set-defaults --_name=".$anvil->data->{job}{peer_short_name}." --protocol=C --fencing=dont-care"; + my $shell_call = $anvil->data->{path}{exe}{drbdsetup}." net-options ".$anvil->data->{job}{server_name}." ".$anvil->data->{job}{drbd_peer_node_id}." --set-defaults --_name=".$anvil->data->{job}{peer_short_name}." --protocol=C --fencing=dont-care"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call}); diff --git a/tools/test.pl b/tools/test.pl index 77f8141b..37a210f4 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -26,6 +26,6 @@ $anvil->Get->switches; $anvil->Database->connect({debug => 3}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0132"}); -$anvil->Cluster->assemble_storage_groups({debug => 2, anvil_uuid => '1aded871-fcb1-4473-9b97-6e9c246fc568'}); +$anvil->DRBD->gather_data({debug => 2}); $anvil->nice_exit({exit_code => 0});