* Updated anvil-update-system to check if another instance of anvil-update-system is running and, if so, exit.

* Removed the new tasks from anvil-special-operations.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent 7bd76c10dc
commit b0c54b6dae
  1. 12
      man/anvil-special-operations.8
  2. 2
      share/words.xml
  3. 3
      tools/anvil-safe-start
  4. 85
      tools/anvil-special-operations
  5. 19
      tools/anvil-update-system

@ -25,18 +25,6 @@ Set the log level to 1, 2 or 3 respectively. Be aware that level 3 generates a s
This is the task being requested. Current optiopns are: This is the task being requested. Current optiopns are:
.IP refresh-drbd-resource .IP refresh-drbd-resource
This requires \fB\-\-resource <new name>\fR, and will call 'drbdadm adjust <resource>' as a background task and then return immediately. This is required when adding a new volume to an existing resource as 'drbdadm adjust <res>' will hold until it is called on all active DRBD nodes. This blocks the caller after the first remote host call. This requires \fB\-\-resource <new name>\fR, and will call 'drbdadm adjust <resource>' as a background task and then return immediately. This is required when adding a new volume to an existing resource as 'drbdadm adjust <res>' will hold until it is called on all active DRBD nodes. This blocks the caller after the first remote host call.
.TP
.IP safe-stop
This implies \fB\-\-no\-db\fR, and will call 'anvil-safe-stop' as a background task. This is designed to ensure that a nodes leave the subcluster, and for DR host to shut down servers. This is done when the host is not yet updated, and the Striker dashboards have been upgraded with a new database schema.
.TP
.IP update-system
This implies \fB\-\-no\-db\fR, and will call 'anvil-update-system' as a background task. This allows remote machines to call for the update without risk of timing out the network connection.
.TP
Note: \fB\-\-no\-reboot\fR, \fB\-\-clear\-cache\fR, and \fB\-\-reboot\fR are all available here and passed to 'anvil-update-system'. See it's manpage for usage information.
.TP
\fB\-\-no\-db\fR
.TP
This tells the program to run without a database connection.
.IP .IP
.SH AUTHOR .SH AUTHOR
Written by Madison Kelly, Alteeve staff and the Anvil! project contributors. Written by Madison Kelly, Alteeve staff and the Anvil! project contributors.

@ -2742,7 +2742,7 @@ Are you sure that you want to delete the server: [#!variable!server_name!#]? [Ty
<key name="message_0230">The 'anvil-safe-start' tool is disabled on this node and enabled on the peer.</key> <key name="message_0230">The 'anvil-safe-start' tool is disabled on this node and enabled on the peer.</key>
<key name="message_0231">The 'anvil-safe-start' tool is disabled, exiting. Use '--force' to run anyway.</key> <key name="message_0231">The 'anvil-safe-start' tool is disabled, exiting. Use '--force' to run anyway.</key>
<key name="message_0232">The 'anvil-safe-start' tool is disabled, but '--force' was used, so proceeding.</key> <key name="message_0232">The 'anvil-safe-start' tool is disabled, but '--force' was used, so proceeding.</key>
<key name="message_0233">It appears that another instance of 'anvil-safe-start' is already runing. Please wait for it to complete (or kill it manually if needed).</key> <key name="message_0233">It appears that another instance of: [#!variable!program!#] is already runing. Please wait for it to complete (or kill it manually if needed).</key>
<key name="message_0234">Preparing to rename a server.</key> <key name="message_0234">Preparing to rename a server.</key>
<key name="message_0235">Preparing to rename stop this node.</key> <key name="message_0235">Preparing to rename stop this node.</key>
<key name="message_0236">This records how long it took to migrate a given server. The average of the last five migations is used to guess how long future migrations will take.</key> <key name="message_0236">This records how long it took to migrate a given server. The average of the last five migations is used to guess how long future migrations will take.</key>

@ -746,7 +746,8 @@ sub prerun_checks
if ($other_instances) if ($other_instances)
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0233"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0233", variables => { program => $THIS_FILE }});
sleep 2;
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
} }

@ -29,27 +29,20 @@ my $anvil = Anvil::Tools->new();
# Read switches (target ([user@]host[:port]) and the file with the target's password. # Read switches (target ([user@]host[:port]) and the file with the target's password.
$anvil->Get->switches({list => [ $anvil->Get->switches({list => [
"clear-cache",
"no-db",
"no-reboot",
"reboot",
"resource", "resource",
"task"], man => $THIS_FILE}); "task"], man => $THIS_FILE});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
if ((not $anvil->data->{switches}{'no-db'}) && ($anvil->data->{switches}{task} eq "stop-target")) $anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{ {
$anvil->Database->connect(); # No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"}); # again after we exit.
if (not $anvil->data->{sys}{database}{connections}) $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0306"});
{ sleep 10;
# No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try $anvil->nice_exit({exit_code => 1});
# again after we exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0306"});
sleep 10;
$anvil->nice_exit({exit_code => 1});
}
} }
if ($anvil->data->{switches}{'job-uuid'}) if ($anvil->data->{switches}{'job-uuid'})
@ -68,14 +61,6 @@ if ($anvil->data->{switches}{task} eq "refresh-drbd-resource")
{ {
refresh_drbd_resource($anvil); refresh_drbd_resource($anvil);
} }
elsif ($anvil->data->{switches}{task} eq "safe-stop")
{
stop_target($anvil);
}
elsif ($anvil->data->{switches}{task} eq "update-system")
{
stop_target($anvil);
}
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
@ -133,57 +118,3 @@ sub refresh_drbd_resource
return(0); return(0);
} }
# This calls 'anvil-safe-stop' on the local host as a background process. This is designed to allow remote
# machines to withdraw the system from a subcluster, or stop servers on a DR host, when the Strikers may have
# already updated and could prevent the local system from connecting to any databases.
sub stop_target
{
my ($anvil) = @_;
my $shell_call = $anvil->data->{path}{exe}{'anvil-safe-stop'}." --no-db -vv --log-secure";
$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,
background => 1,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
return(0);
}
# This calls 'anvil-safe-stop' on the local host as a background process. This is designed to allow remote
# machines to withdraw the system from a subcluster, or stop servers on a DR host, when the Strikers may have
# already updated and could prevent the local system from connecting to any databases.
sub update_target
{
my ($anvil) = @_;
my $shell_call = $anvil->data->{path}{exe}{'anvil-update-system'}." --no-db -vv --log-secure";
if ($anvil->data->{switches}{'clear-cache'})
{
$shell_call .= " --clear-cache";
}
if ($anvil->data->{switches}{'no-reboot'})
{
$shell_call .= " --no-reboot";
}
if ($anvil->data->{switches}{'reboot'})
{
$shell_call .= " --reboot";
}
$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,
background => 1,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
return(0);
}

@ -46,9 +46,6 @@ $anvil->Get->switches({list => [
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
# Log that we've started.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# Connect to DBs. # Connect to DBs.
if ($anvil->data->{switches}{'no-db'}) if ($anvil->data->{switches}{'no-db'})
{ {
@ -76,6 +73,22 @@ else
if ($anvil->data->{switches}{'job-uuid'}) if ($anvil->data->{switches}{'job-uuid'})
{ {
# See if another instance is running. If so, sleep for 10 seconds and then exit. The other instance
# could be the '--no-db' run we're about to clobber.
my $pids = $anvil->System->pids({
ignore_me => 1,
program_name => $THIS_FILE,
});
my $other_instances = @{$pids};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { other_instances => $other_instances }});
if ($other_instances)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0233", variables => { program => $THIS_FILE }});
sleep 10;
$anvil->nice_exit({exit_code => 0});
}
# Load the job details. If anything is returned, there was a problem. # Load the job details. If anything is returned, there was a problem.
my $return = $anvil->Job->get_job_details({job_uuid => $anvil->data->{switches}{'job-uuid'}}); my $return = $anvil->Job->get_job_details({job_uuid => $anvil->data->{switches}{'job-uuid'}});
if ($return) if ($return)

Loading…
Cancel
Save