* Fixed a few more bugs in 'ocf:alteeve:anvil', but it's still failing when invoked by pacemaker.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent f5caec52dc
commit ed2e83a1a4
  1. 8
      Anvil/Tools/Server.pm
  2. 9
      notes
  3. 62
      ocf/alteeve/server
  4. 1
      share/words.xml

@ -186,6 +186,10 @@ This is the password to use when connecting to a remote machine. If not set, but
This is the TCP port to use when connecting to a remote machine. If not set, but C<< target >> is, C<< 22 >> will be used.
=head3 refresh (optional, default '0')
Is set to C<< 1 >>, and previously seen servers and their information is cleared.
=head3 remote_user (optional, default 'root')
If C<< target >> is set, this will be the user we connect to the remote machine as.
@ -204,17 +208,19 @@ sub find
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
my $refresh = defined $parameter->{refresh} ? $parameter->{refresh} : 0;
my $remote_user = defined $parameter->{remote_user} ? $parameter->{remote_user} : "root";
my $target = defined $parameter->{target} ? $parameter->{target} : "local";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
password => $anvil->Log->secure ? $password : $anvil->Words->string({key => "log_0186"}),
port => $port,
refresh => $refresh,
remote_user => $remote_user,
target => $target,
}});
# Clear any old data
if (exists $anvil->data->{server}{location})
if ((exists $anvil->data->{server}{location}) && ($refresh))
{
delete $anvil->data->{server}{location};
}

@ -1115,3 +1115,12 @@ virt-install --connect qemu:///system \
--disk path=/dev/an-a01n01_vg0/srv09-psql_0,bus=virtio,cache=writethrough \
--graphics spice \
--noautoconsole --wait -1 > /var/log/anvil-server_srv09-psql.log &
# Migration;
pcs resource move test_server
# (then remove the constraint);
pcs constraint show --full
pcs constraint remove cli-ban-test_server-on-el8-a01n01

@ -98,6 +98,9 @@ my $anvil = Anvil::Tools->new();
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1});
# For the logs...
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, secure => 0, key => "log_0115", variables => { program => 'ocf:alteeve:'.$THIS_FILE }});
### Read or Set the environment variables
# This is the name of the server we're managing. # Example values:
$anvil->data->{environment}{OCF_RESKEY_name} = defined $ENV{OCF_RESKEY_name} ? $ENV{OCF_RESKEY_name} : ""; # srv01-c7
@ -616,13 +619,15 @@ sub migrate_server
# missing.
# If we're given 'migrate_from', we're pulling the server towards us, so we can check both brdiges
# and storage.
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $source = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source};
my $target = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target};
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $source = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source};
my $target = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target};
my $meta_on_node = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server,
source => $source,
target => $target,
meta_on_node => $meta_on_node,
'switches::migrate_to' => $anvil->data->{switches}{migrate_to},
'switches::migrate_from' => $anvil->data->{switches}{migrate_from},
}});
@ -647,12 +652,8 @@ sub migrate_server
$anvil->nice_exit({exit_code => 5});
}
# Get a view of the servers locally and our peer.
validate_all($anvil);
# Find the server
$anvil->Server->find({debug => 3});
my $server_host = defined $anvil->data->{server}{location}{$server}{host} ? $anvil->data->{server}{location}{$server}{host} : "";
my $server_status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
@ -660,12 +661,38 @@ sub migrate_server
server_status => $server_status,
}});
# Is it already on the target?
if (not $server_status)
{
# Maybe...
$anvil->Server->find({debug => 3, target => $target});
$server_host = defined $anvil->data->{server}{location}{$server}{host} ? $anvil->data->{server}{location}{$server}{host} : "";
$server_status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server_host => $server_host,
server_status => $server_status,
}});
if (($server_host eq $target) && (($server_status) && ($server_status eq "running")))
{
# Already over there, we're done.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0430", variables => {
server => $server,
target => $target,
}});
$anvil->nice_exit({exit_code => 0});
}
}
if (not $server_host)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0344", variables => { server => $server }});
$anvil->nice_exit({exit_code => 1});
}
# Get a view of the servers locally and our peer.
validate_all($anvil);
# Get the DRBD status.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0387"});
$anvil->DRBD->get_status({debug => 2});
@ -771,16 +798,17 @@ sub migrate_server
elsif ($anvil->data->{switches}{migrate_from})
{
# Pull the server here. Start by verifying it's on the 'meta_on_node' host.
my $meta_on_node = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node};
my $host = defined $anvil->data->{server}{location}{$server}{host} ? $anvil->data->{server}{location}{$server}{host} : "";
my $status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
# Scan locally and on our peer
$anvil->Server->find({debug => 2});
$anvil->Server->find({debug => 2, target => $meta_on_node});
my $host = defined $anvil->data->{server}{location}{$server}{host} ? $anvil->data->{server}{location}{$server}{host} : "";
my $status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host => $host,
status => $status,
meta_on_node => $meta_on_node,
target => $target,
host => $host,
status => $status,
target => $target,
}});
$anvil->Server->find({debug => 2, target => $meta_on_node});
my $server_host = defined $anvil->data->{server}{location}{$server}{host} ? $anvil->data->{server}{location}{$server}{host} : "";
my $server_status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
@ -791,13 +819,13 @@ sub migrate_server
# This is called after a migration. If that is the case here, the target will be us. Just
# make sure it is running and, if so, return '0'. The 'meta_on_node' is the new host.
if ($meta_on_node eq $target)
if (($target eq $anvil->_hostname) or ($target eq $anvil->_short_hostname) or ($target eq $meta_on_node))
{
# Yup. All we want to do if make sure it is running here.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0345", variables => { server => $server }});
# If it's running, we're succesfully out.
if ($status eq "running")
if (($host eq $target) && ($status eq "running"))
{
# Success!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0347", variables => { server => $server }});

@ -747,6 +747,7 @@ Failed to promote the DRBD resource: [#!variable!resource!#] primary. Expected a
<key name="log_0427">[ Warning ] - The server: [#!variable!server!#] is not yet off after: [#!variable!wait!#] seconds. Giving up waiting.</key>
<key name="log_0428">[ Error ] - The server: [#!variable!server!#] can't by migrated to: [#!variable!target!#] because the resource: [#!variable!resource!#] isn't connected. The current connection state is: [#!variable!connection_state!#].</key>
<key name="log_0429">[ Error ] - The server: [#!variable!server!#] can't by migrated to: [#!variable!target!#] because we can't reach it at all right now.</key>
<key name="log_0430">The migration of the server: [#!variable!server!#] over to: [#!variable!target!#] isn't needed, it's already running on the target. Exiting successfully.</key>
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->
<key name="t_0000">Test</key>

Loading…
Cancel
Save