* Updated Cluster->add_server() to set the preferred host based first on if the server is running on a node, and if not, on the primary node (where before it defaulted to node 1).

* Updated DRBD->delete_resource() to call scan-drbd and scan-lvm to ensure that the database is updated with the newly freed resources.
* Updated anvil-delete-server and anvil-provision-server to call select scan agents to ensure freed resources are immediately recorded.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 2 years ago
parent 929806cef7
commit b6a249d5e7
  1. 69
      Anvil/Tools/Cluster.pm
  2. 15
      Anvil/Tools/DRBD.pm
  3. 2
      share/words.xml
  4. 21
      tools/anvil-delete-server
  5. 38
      tools/anvil-provision-server

@ -226,11 +226,11 @@ sub add_server
my $host_name = $anvil->Get->host_name();
my $server_state = defined $anvil->data->{server}{location}{$server_name}{status} ? $anvil->data->{server}{location}{$server_name}{status} : "";
my $server_host = defined $anvil->data->{server}{location}{$server_name}{host_name} ? $anvil->data->{server}{location}{$server_name}{host_name} : "";
my $target_role = $server_state eq "running" ? "started" : "stopped";
my $target_role = $server_host ? "started" : "stopped"; # Don't use state as it could be 'paused' if caught during initialization.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
host_name => $host_name,
server_state => $server_state,
server_host => $server_host,
server_host => $server_host,
target_role => $target_role,
}});
@ -262,17 +262,70 @@ sub add_server
return_code => $return_code,
}});
my $constraint_command = $anvil->data->{path}{exe}{pcs}." -f ".$pcs_file." constraint location ".$server_name." prefers ";
if (($server_state eq "running") && ($server_host ne $host_name))
### NOTE: The higher the constraint score, the more preferred the host is.
# Which sub-node do we want to run the server on?
my $run_on_host_name = "";
my $backup_host_name = "";
my $target_host_uuid = $anvil->Cluster->get_primary_host_uuid({debug => 2, anvil_uuid => $anvil_uuid});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { target_host_uuid => $target_host_uuid }});
if ($target_role eq "started")
{
# Set the peer as primary.
$constraint_command .= $local_name."=100 ".$peer_name."=200";
# Run on the current host.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server_host => $server_host,
host_name => $host_name,
}});
if ($server_host eq $host_name)
{
# Run here
$run_on_host_name = $local_name;
$backup_host_name = $peer_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
run_on_host_name => $run_on_host_name,
backup_host_name => $backup_host_name,
}});
}
else
{
# Run on the
$run_on_host_name = $peer_name;
$backup_host_name = $local_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
run_on_host_name => $run_on_host_name,
backup_host_name => $backup_host_name,
}});
}
}
else
{
# Set us as primary.
$constraint_command .= $local_name."=200 ".$peer_name."=100";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
target_host_uuid => $target_host_uuid,
peer_host_uuid => $peer_host_uuid,
}});
if ($target_host_uuid eq $peer_host_uuid)
{
# Run on the
$run_on_host_name = $peer_name;
$backup_host_name = $local_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
run_on_host_name => $run_on_host_name,
backup_host_name => $backup_host_name,
}});
}
else
{
# Run here
$run_on_host_name = $local_name;
$backup_host_name = $peer_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
run_on_host_name => $run_on_host_name,
backup_host_name => $backup_host_name,
}});
}
}
my $constraint_command = $anvil->data->{path}{exe}{pcs}." -f ".$pcs_file." constraint location ".$server_name." prefers ".$run_on_host_name."=200 ".$backup_host_name."=100";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { constraint_command => $constraint_command }});
undef $output;

@ -676,6 +676,21 @@ sub delete_resource
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "job_0134", variables => { file_path => $definition_file }});
}
# Call scan-lvm and scan-drbd to make sure the databases are updated.
foreach my $agent ("scan-drbd", "scan-lvm")
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
my $shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output,
return_code => $return_code,
}});
}
return(0);
}

@ -1549,6 +1549,7 @@ Note: This is a permanent action! If you protect this server again later, a full
<key name="job_0461"><![CDATA[ > File name: [#!variable!name!#], file UUID: [#!variable!uuid!#], size: [#!variable!size!#]]]></key>
<key name="job_0462"><![CDATA[ --driver-disc - (optional) A driver disc to be added as a second optical drive. Valid options are above.]]></key>
<key name="job_0463">Enabling the enable-safe-start daemon.</key>
<key name="job_0464">Calling select ScanCore scan agents to ensure the database is updated.</key>
<!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key>
@ -2390,6 +2391,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0737">The job: [#!variable!command!#] (with job UUID: [#!variable!job_uuid!#]) is being skipped for now, already started a job (started job_uuid: [#!variable!started_job!#]) with this command on this loop.</key>
<key name="log_0738">There are no databases available at this time.</key>
<key name="log_0739">The server: [#!variable!server!#] needs it's pacemaker configuration updated. Running: [#!variable!command!#].</key>
<key name="log_0740">Running the scan-agent: [#!variable!agent!#] now to ensure that the database has an updated view of resources.</key>
<!-- 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>

@ -240,6 +240,27 @@ WHERE
unlink $resource_file;
}
# Call scan-cluster, scan-network and scan-server to make sure the databases are updated.
$anvil->Job->update_progress({
progress => 90,
message => "job_0464",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0464"});
foreach my $agent ("scan-cluster", "scan-network", "scan-server")
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
my $shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
$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});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
}
# We're done
$anvil->Job->update_progress({
progress => 100,
message => "job_0216",

@ -324,6 +324,26 @@ sub run_jobs
# Add the server to the cluster.
add_server_to_cluster($anvil);
# Update the database by calling select scan agents
$anvil->Job->update_progress({
progress => 95,
message => "job_0464",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0464"});
foreach my $agent ("scan-drbd", "scan-cluster", "scan-network", "scan-server")
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
my $shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
$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});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
}
# Done!
$anvil->Job->update_progress({
progress => 100,
@ -1408,6 +1428,24 @@ sub create_lv
$anvil->nice_exit({exit_code => 1});
}
# Call scan-lvm now to make sure we've recorded this LV.
$anvil->Job->update_progress({
progress => 28,
message => "job_0464",
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0464"});
my $agent = "scan-lvm";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
$shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
# Report
$anvil->Job->update_progress({
progress => 30,

Loading…
Cancel
Save