* Fixed a bug where, once a DRBD resource was allowed to be dual-primary for migration, that wasn't properly disabled post-migration.

* Updated DRBD->allow_two_primaries() to take the 'set_to' parameter which can be 'yes' to all and 'no' to disallow dual-primary.
* Updated ocf:alteeve:server to call allow_two_primaries() with 'set_to' = 'no' instead of calling 'adjust' after a migration completes.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 124e0435c4
commit 607c097fc8
  1. 1
      Anvil/Tools/Cluster.pm
  2. 19
      Anvil/Tools/DRBD.pm
  3. 6
      Anvil/Tools/ScanCore.pm
  4. 20
      Anvil/Tools/Server.pm
  5. 4
      ocf/alteeve/server
  6. 2
      share/words.xml

@ -2799,6 +2799,7 @@ sub migrate_server
if ($node) if ($node)
{ {
$anvil->Cluster->_set_server_constraint({ $anvil->Cluster->_set_server_constraint({
debug => 2,
server => $server, server => $server,
preferred_node => $node, preferred_node => $node,
}); });

@ -108,6 +108,10 @@ If C<< target >> is set, this will be the user we connect to the remote machine
This is the name of the resource to enable two primaries on. This is the name of the resource to enable two primaries on.
=head3 set_to (optional, default 'yes')
This can be set to C<< yes >> to allow two-primary, or C<< no >> to disable it.
=head3 target (optional) =head3 target (optional)
This is the IP or host name of the machine to read the version of. If this is not set, the local system's version is checked. This is the IP or host name of the machine to read the version of. If this is not set, the local system's version is checked.
@ -129,12 +133,14 @@ sub allow_two_primaries
my $port = defined $parameter->{port} ? $parameter->{port} : ""; my $port = defined $parameter->{port} ? $parameter->{port} : "";
my $remote_user = defined $parameter->{remote_user} ? $parameter->{remote_user} : "root"; my $remote_user = defined $parameter->{remote_user} ? $parameter->{remote_user} : "root";
my $resource = defined $parameter->{resource} ? $parameter->{resource} : ""; my $resource = defined $parameter->{resource} ? $parameter->{resource} : "";
my $set_to = defined $parameter->{set_to} ? $parameter->{set_to} : "yes";
my $target = defined $parameter->{target} ? $parameter->{target} : ""; my $target = defined $parameter->{target} ? $parameter->{target} : "";
my $target_node_id = defined $parameter->{target_node_id} ? $parameter->{target_node_id} : ""; my $target_node_id = defined $parameter->{target_node_id} ? $parameter->{target_node_id} : "";
my $return_code = 255; my $return_code = 255;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
password => $anvil->Log->is_secure($password), password => $anvil->Log->is_secure($password),
port => $port, port => $port,
set_to => $set_to,
remote_user => $remote_user, remote_user => $remote_user,
resource => $resource, resource => $resource,
target => $target, target => $target,
@ -147,6 +153,12 @@ sub allow_two_primaries
return($return_code); return($return_code);
} }
if (($set_to ne "yes") && ($set_to ne "no"))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0312", variables => { set_to => $set_to }});
return($return_code);
}
# Do we need to scan devices? # Do we need to scan devices?
my $host = $anvil->Get->short_host_name; my $host = $anvil->Get->short_host_name;
if (not $anvil->data->{drbd}{config}{$host}{peer}) if (not $anvil->data->{drbd}{config}{$host}{peer})
@ -188,13 +200,14 @@ sub allow_two_primaries
} }
} }
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 1, key => "log_0350", variables => { my $key = $set_to eq "yes" ? "log_0350" : "log_0642";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 1, key => "", variables => {
resource => $resource, resource => $resource,
target_name => $peer_name, target_name => $peer_name,
target_node_id => $target_node_id, target_node_id => $target_node_id,
}}); }});
my $shell_call = $anvil->data->{path}{exe}{drbdsetup}." net-options ".$resource." ".$target_node_id." --allow-two-primaries=yes"; my $shell_call = $anvil->data->{path}{exe}{drbdsetup}." net-options ".$resource." ".$target_node_id." --allow-two-primaries=".$set_to;
my $output = ""; my $output = "";
if ($anvil->Network->is_local({host => $target})) if ($anvil->Network->is_local({host => $target}))
{ {
@ -1876,7 +1889,7 @@ sub reload_defaults
if (not $resource) if (not $resource)
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "DRBD->allow_two_primaries()", parameter => "resource" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "DRBD->reload_defaults()", parameter => "resource" }});
return($return_code); return($return_code);
} }

@ -371,7 +371,7 @@ WHERE
my $health_agent_name = $row->[0]; my $health_agent_name = $row->[0];
my $health_source_name = $row->[1]; my $health_source_name = $row->[1];
my $health_source_weight = $row->[2]; my $health_source_weight = $row->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:health_agent_name' => $health_agent_name, 's1:health_agent_name' => $health_agent_name,
's2:health_source_name' => $health_source_name, 's2:health_source_name' => $health_source_name,
's3:health_source_weight' => $health_source_weight, 's3:health_source_weight' => $health_source_weight,
@ -380,7 +380,7 @@ WHERE
if ($health_source_weight) if ($health_source_weight)
{ {
$health_score += $health_source_weight; $health_score += $health_source_weight;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { health_score => $health_score }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { health_score => $health_score }});
} }
} }
@ -1294,7 +1294,7 @@ sub post_scan_analysis_node
debug => $debug, debug => $debug,
host_uuid => $anvil->data->{cib}{parsed}{peer}{host_uuid}, host_uuid => $anvil->data->{cib}{parsed}{peer}{host_uuid},
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
local_health => $local_health, local_health => $local_health,
peer_health => $peer_health, peer_health => $peer_health,
}}); }});

@ -974,13 +974,18 @@ sub migrate_virsh
} }
# Enable dual-primary for any resources we know about for this server. # Enable dual-primary for any resources we know about for this server.
my $resources_to_disable_dual_primary = [];
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$source}{$server}{resource}}) foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$source}{$server}{resource}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource => $resource }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource => $resource }});
my ($return_code) = $anvil->DRBD->allow_two_primaries({ my ($return_code) = $anvil->DRBD->allow_two_primaries({
debug => $debug, debug => 2,
resource => $resource, resource => $resource,
set_to => "yes",
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { return_code => $return_code }});
push @{$resources_to_disable_dual_primary}, $resource;
} }
### NOTE: This method is called by ocf:alteeve:server, which operates without database access. As ### NOTE: This method is called by ocf:alteeve:server, which operates without database access. As
@ -1189,13 +1194,20 @@ WHERE
} }
# Switch off dual-primary. # Switch off dual-primary.
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$target}{$server}{resource}}) foreach my $resource (sort {$a cmp $b} @{$resources_to_disable_dual_primary})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource => $resource }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource => $resource }});
$anvil->DRBD->reload_defaults({ my ($return_code) = $anvil->DRBD->allow_two_primaries({
debug => $debug, debug => 2,
resource => $resource, resource => $resource,
set_to => "no",
}); });
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource => $resource }});
# $anvil->DRBD->reload_defaults({
# debug => 2,
# resource => $resource,
# });
} }
return($success); return($success);

@ -135,7 +135,7 @@ foreach my $key (sort {$a cmp $b} keys %ENV)
# If pacemaker is in debug, so are we, # If pacemaker is in debug, so are we,
if ($anvil->data->{environment}{PCMK_debug}) if ($anvil->data->{environment}{PCMK_debug})
{ {
$anvil->Log->level({set => 3}); $anvil->Log->level({set => 2});
} }
# Originally, this was designed to start and stop a server's DRBD resources on demand. Early testing appears # Originally, this was designed to start and stop a server's DRBD resources on demand. Early testing appears
@ -1225,7 +1225,6 @@ pmsuspended - The domain has been suspended by guest power management, e.g. ente
sub migrate_server sub migrate_server
{ {
my ($anvil) = @_; my ($anvil) = @_;
### NOTE: For now, we're not going to block if the target is not UpToDate. There are times when a ### NOTE: For now, we're not going to block if the target is not UpToDate. There are times when a
### user might want to do this (ie: sync will be done soon and the need to evacuate the node ### user might want to do this (ie: sync will be done soon and the need to evacuate the node
@ -1723,7 +1722,6 @@ sub validate_storage_drbd
drbd_device => $drbd_device, drbd_device => $drbd_device,
lv_path => $on_lv, lv_path => $on_lv,
}}); }});
} }
### NOTE: Checking/Managing firewall ports is expensive option, so DRBD ports are permanently opened ### NOTE: Checking/Managing firewall ports is expensive option, so DRBD ports are permanently opened

@ -423,6 +423,7 @@ The attempt to start the servers appears to have failed. The return code '0' was
<key name="error_0309">I tried to change the fencing preferred node to: [#!variable!prefer!#], but it doesn't appear to have worked. The preferred node is: [#!variable!current!#] ('--' means there is no preferred node)</key> <key name="error_0309">I tried to change the fencing preferred node to: [#!variable!prefer!#], but it doesn't appear to have worked. The preferred node is: [#!variable!current!#] ('--' means there is no preferred node)</key>
<key name="error_0310">I tried to remove the fence delay from the node: [#!variable!node!#], but it doesn't appear to have worked. The preferred node is: [#!variable!current!#] ('--' means there is no preferred node)</key> <key name="error_0310">I tried to remove the fence delay from the node: [#!variable!node!#], but it doesn't appear to have worked. The preferred node is: [#!variable!current!#] ('--' means there is no preferred node)</key>
<key name="error_0311">Failed to find the UUID column for the table: [#!variable!table!#].</key> <key name="error_0311">Failed to find the UUID column for the table: [#!variable!table!#].</key>
<key name="error_0312">The 'set_to' parameter: [#!variable!set_to!#] is invalid. It must be 'yes' or 'no'.</key>
<!-- Files templates --> <!-- Files templates -->
<!-- NOTE: Translating these files requires an understanding of which lines are translatable --> <!-- NOTE: Translating these files requires an understanding of which lines are translatable -->
@ -1835,6 +1836,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0639">The Anvil! daemon is in startup mode, and the job: [#!variable!job_uuid!#], command: [#!variable!job_command!#] is not a startup job, ignoring it for now.</key> <key name="log_0639">The Anvil! daemon is in startup mode, and the job: [#!variable!job_uuid!#], command: [#!variable!job_command!#] is not a startup job, ignoring it for now.</key>
<key name="log_0640">Out peer is online, no need to check server location constraints.</key> <key name="log_0640">Out peer is online, no need to check server location constraints.</key>
<key name="log_0641">The server: [#!variable!server!#] has a location constraint that preferres our peer, but our peer is offline. Updating the location constraint to prefer this node.</key> <key name="log_0641">The server: [#!variable!server!#] has a location constraint that preferres our peer, but our peer is offline. Updating the location constraint to prefer this node.</key>
<key name="log_0642">Disabling dual primary for the resource: [#!variable!resource!#] to the node: [#!variable!target_name!# (#!variable!target_node_id!#)].</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. --> <!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key> <key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>

Loading…
Cancel
Save