* Updated anvil-manage-dr to check if a server is protected before processing a --connect or --disconnect request. Also made it smarter if an attempt to connect a resource fails.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 2 years ago
parent 83e577d057
commit c8ee75420d
  1. 7
      share/words.xml
  2. 43
      tools/anvil-manage-dr

@ -521,6 +521,11 @@ The definition data passed in was:
]]></key> ]]></key>
<key name="error_0368">[ Error ] - Failed to wipe and delete the logical volume: [#!variable!local_lv!#] that was volume number: [#!variable!volume!#] under the server: [#!variable!server!#].</key> <key name="error_0368">[ Error ] - Failed to wipe and delete the logical volume: [#!variable!local_lv!#] that was volume number: [#!variable!volume!#] under the server: [#!variable!server!#].</key>
<key name="error_0369">There was a problem deleting: [#!variable!config_file!#]. The rest of the process completed successfully. Please manually remove this file if it still exists.</key> <key name="error_0369">There was a problem deleting: [#!variable!config_file!#]. The rest of the process completed successfully. Please manually remove this file if it still exists.</key>
<key name="error_0370">[ Error ] - Failed to connect the DRBD resource. Expected return code '0', but got: [#!variable!return_code!#]. The error output, if anything, was
====
#!variable!output!#
====</key>
<key name="error_0371">Can not (dis)connect the server: [#!variable!server!#] as the resource config file: [#!variable!config_file!#] doesn't exist. Do you need to '--protect' it?</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 -->
@ -1320,7 +1325,7 @@ Note: Depending on the disk write load and storage network speed to the DR host,
<key name="job_0387">About to connect the DR resource for the server: [#!variable!server!#].</key> <key name="job_0387">About to connect the DR resource for the server: [#!variable!server!#].</key>
<key name="job_0388">Brought up the connection locally. Now checking that the resource is up on the nodes.</key> <key name="job_0388">Brought up the connection locally. Now checking that the resource is up on the nodes.</key>
<key name="job_0389">Making sure the resource is up on: [#!variable!host_name!#].</key> <key name="job_0389">Making sure the resource is up on: [#!variable!host_name!#].</key>
<key name="job_0390">Waiting now for the our resource to connect.</key> <key name="job_0390">Waiting now for the resource to connect.</key>
<key name="job_0391">Done! The server: [#!variable!server!#] is now connected.</key> <key name="job_0391">Done! The server: [#!variable!server!#] is now connected.</key>
<key name="job_0392"> <key name="job_0392">
Do you want to disconnect the DR host for the server: [#!variable!server!#]? Do you want to disconnect the DR host for the server: [#!variable!server!#]?

@ -94,6 +94,31 @@ sub sanity_check
anvil_uuid => $anvil_uuid, anvil_uuid => $anvil_uuid,
}}); }});
# If we're (dis}connecting, is the server being protected in the first place?
if (($anvil->data->{switches}{'connect'}) or ($anvil->data->{switches}{'disconnect'}))
{
# Is this server configured to be protected?
my $server_name = $anvil->data->{switches}{server};
my $config_file = $anvil->data->{path}{directories}{drbd_resources}."/".$server_name.".res";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { config_file => $config_file }});
if (not -e $config_file)
{
# Can't connect an unprotected server.
my $variables = {
server => $server_name,
config_file => $config_file,
};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "error_0371", variables => $variables});
$anvil->Job->update_progress({
progress => 100,
message => "error_0371",
variables => $variables,
job_status => "failed",
});
}
$anvil->nice_exit({exit_code => 1});
}
# If we're doing a --protect or --remove, make sure we're a node, the cluster is up, and both nodes # If we're doing a --protect or --remove, make sure we're a node, the cluster is up, and both nodes
# are ready. # are ready.
if (($anvil->data->{switches}{protect}) or ($anvil->data->{switches}{remove})) if (($anvil->data->{switches}{protect}) or ($anvil->data->{switches}{remove}))
@ -986,6 +1011,24 @@ sub process_connect
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
}}); }});
# If this was an error, abort.
if ($return_code)
{
# Failed.
my $variables = {
return_code => $return_code,
output => $output,
};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "error_0370", variables => $variables});
$anvil->Job->update_progress({
progress => 100,
message => "error_0370",
variables => $variables,
});
$anvil->nice_exit({exit_code => 1});
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0388", variables => $variables}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0388", variables => $variables});
$anvil->Job->update_progress({ $anvil->Job->update_progress({
progress => 60, progress => 60,

Loading…
Cancel
Save