* Added PID logging as an option, and enabled it in ocf:alteeve:server

* Updated DRBD->manage_resource() to take the task 'adjust'.
* Updated ocf:alteeve:server's start_drbd_resource() to call adjust if startup of a resource isn't needd.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent 26b932f001
commit 59ade94124
  1. 1
      Anvil/Tools.pm
  2. 43
      Anvil/Tools/DRBD.pm
  3. 4
      Anvil/Tools/Log.pm
  4. 12
      ocf/alteeve/server

@ -981,6 +981,7 @@ sub _set_defaults
facility => "local0", facility => "local0",
language => "en_CA", language => "en_CA",
level => 1, level => 1,
pids => 0,
secure => 0, secure => 0,
server => "", server => "",
tag => "anvil", tag => "anvil",

@ -2451,7 +2451,7 @@ sub get_status
=head2 manage_resource =head2 manage_resource
This takes a task, C<< up >>, C<< down >>, C<< primary >>, or C<< secondary >> and a resource name and acts on the request. This takes a task, C<< up >>, C<< down >>, C<< primary >>, C<< secondary >>, or C<< adjust >> and a resource name and acts on the request.
This returns the return code from the C<< drbdadm >> call. If C<< 255 >> is returned, then we did not get the actual return code from C<< drbdadm >>. This returns the return code from the C<< drbdadm >> call. If C<< 255 >> is returned, then we did not get the actual return code from C<< drbdadm >>.
@ -2475,7 +2475,7 @@ This is the name of the resource being acted upon.
=head3 task (required) =head3 task (required)
This is the action to take. Valid tasks are: C<< up >>, C<< down >>, C<< primary >>, and C<< secondary >>. This is the action to take. Valid tasks are: C<< up >>, C<< down >>, C<< primary >>, C<< secondary >>, and C<< adjust >>.
If C<< target >> is set, this will be the user we connect to the remote machine as. If C<< target >> is set, this will be the user we connect to the remote machine as.
@ -2518,6 +2518,45 @@ sub manage_resource
return(1); return(1);
} }
# If the task is 'adjust', do just that.
if ($task eq "adjust")
{
# Reset to the values in the config and return.
my $shell_call = $anvil->data->{path}{exe}{drbdadm}." adjust ".$resource;
my $output = "";
my $return_code = 255;
if ($anvil->Network->is_local({host => $target}))
{
# Local.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
($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,
}});
}
else
{
# Remote call.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
($output, my $error, $return_code) = $anvil->Remote->call({
debug => $debug,
shell_call => $shell_call,
target => $target,
port => $port,
password => $password,
remote_user => $remote_user,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
error => $error,
output => $output,
return_code => $return_code,
}});
}
return($return_code);
}
### TODO: When taking down a resource, check to see if any machine is SyncTarget and take it/them ### TODO: When taking down a resource, check to see if any machine is SyncTarget and take it/them
### down first. See anvil-rename-server -> verify_server_is_off() for the logic. ### down first. See anvil-rename-server -> verify_server_is_off() for the logic.
### TODO: Sanity check the resource name and task requested. ### TODO: Sanity check the resource name and task requested.

@ -373,6 +373,10 @@ sub entry
$job_uuid =~ s/^(\w+?)-.*$/$1/; $job_uuid =~ s/^(\w+?)-.*$/$1/;
$string .= "[".$job_uuid."]:"; $string .= "[".$job_uuid."]:";
} }
if ($anvil->data->{defaults}{'log'}{pids})
{
$string .= "[".$$."]:";
}
if (exists $anvil->data->{'log'}{scan_agent}) if (exists $anvil->data->{'log'}{scan_agent})
{ {
$string .= "[".$anvil->data->{'log'}{scan_agent}."]:"; $string .= "[".$anvil->data->{'log'}{scan_agent}."]:";

@ -100,7 +100,8 @@ $| = 1;
# NOTE: Setting 'log_level' and 'log_secure' here will get overridden in the main lopp. Use the Log methods # NOTE: Setting 'log_level' and 'log_secure' here will get overridden in the main lopp. Use the Log methods
# in the loop as well to override defaults in code. # in the loop as well to override defaults in code.
my $anvil = Anvil::Tools->new(); my $anvil = Anvil::Tools->new();
#$anvil->Log->level({set => 2}); # Log PIDs
$anvil->data->{defaults}{'log'}{pids} = 1;
### Read or Set the environment variables ### Read or Set the environment variables
# This is the name of the server we're managing. # Example values: # This is the name of the server we're managing. # Example values:
@ -829,6 +830,15 @@ sub start_drbd_resource
} }
} }
} }
else
{
# Call an adjust to reset the config, in case something like 'allow-two-primaries' was
# enabled on one node but not the other.
$anvil->DRBD->manage_resource({
resource => $resource,
task => "adjust",
});
}
### NOTE: We always check the peer now, in case it's resource is down and ours happens to be up. ### NOTE: We always check the peer now, in case it's resource is down and ours happens to be up.
# See if we're inconsistent and, if so, if we can connect our peers. # See if we're inconsistent and, if so, if we can connect our peers.

Loading…
Cancel
Save