Fixed a bug where the peer subnode would add a server to pacemaker

* Updated anvil-provision-server to only call add_server_to_cluster() if
  it's NOT the peer.
* Added the new 'ok_if_exists' parameter to Cluster->add_server() to
  return 0 if the server already existed in pacemaker as a resource.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 11 months ago
parent 423f677716
commit 7018703c24
  1. 14
      Anvil/Tools/Cluster.pm
  2. 12
      tools/anvil-provision-server

@ -105,6 +105,10 @@ This takes a server name, finds where it is running and then adds it to pacemake
Parameters; Parameters;
=head3 ok_if_exists (optional, default '0')
Normally, if the server is already in the cluster, C<< !!error!! >> is returned. If this is set to C<< 1 >> and the server is already in pacemaker, we'll return C<< 0 >> instead.
=head3 server_name (required) =head3 server_name (required)
This is the name of the server being added. This is the name of the server being added.
@ -118,9 +122,11 @@ sub add_server
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 2; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Cluster->add_server()" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Cluster->add_server()" }});
my $server_name = defined $parameter->{server_name} ? $parameter->{server_name} : ""; my $ok_if_exists = defined $parameter->{ok_if_exists} ? $parameter->{ok_if_exists} : "";
my $server_name = defined $parameter->{server_name} ? $parameter->{server_name} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
server_name => $server_name, ok_if_exists => $ok_if_exists,
server_name => $server_name,
}}); }});
if (not $server_name) if (not $server_name)
@ -146,6 +152,10 @@ sub add_server
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"cib::parsed::cib::resources::primitive::${server_name}::type" => $anvil->data->{cib}{parsed}{cib}{resources}{primitive}{$server_name}{type}, "cib::parsed::cib::resources::primitive::${server_name}::type" => $anvil->data->{cib}{parsed}{cib}{resources}{primitive}{$server_name}{type},
}}); }});
if ($ok_if_exists)
{
return(0);
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0213", variables => { server_name => $server_name }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0213", variables => { server_name => $server_name }});
return("!!error!!"); return("!!error!!");
} }

@ -321,8 +321,11 @@ sub run_jobs
# Make sure the VNC port is open. # Make sure the VNC port is open.
$anvil->Network->manage_firewall(); $anvil->Network->manage_firewall();
# Add the server to the cluster. # If we're not the peer, add the server to the cluster.
add_server_to_cluster($anvil); if (not $anvil->data->{job}{peer_mode})
{
add_server_to_cluster($anvil);
}
# Update the database by calling select scan agents # Update the database by calling select scan agents
$anvil->Job->update_progress({ $anvil->Job->update_progress({
@ -368,8 +371,9 @@ sub add_server_to_cluster
# Is our peer in the cluster? For that matter, are we? # Is our peer in the cluster? For that matter, are we?
my $problem = $anvil->Cluster->add_server({ my $problem = $anvil->Cluster->add_server({
debug => 2, debug => 2,
server_name => $anvil->data->{job}{server_name}, server_name => $anvil->data->{job}{server_name},
ok_if_exists => 1,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }});
if ($problem) if ($problem)

Loading…
Cancel
Save