* Updated Remote->call() to remove the 'background' parameter as it wasn't working. * Updated anvil-manage-server-storage to use 'anvil-manage-server-storage' to adjust resources in a way that doesn't block. Signed-off-by: digimer <mkelly@alteeve.ca>main
parent
7fbed10864
commit
1b8b0bc493
8 changed files with 202 additions and 74 deletions
@ -0,0 +1,32 @@ |
||||
.\" Manpage for the Anvil! storage groups |
||||
.\" Contact mkelly@alteeve.com to report issues, concerns or suggestions. |
||||
.TH anvil-special-operations "8" "Jun 30 2023" "Anvil! Intelligent Availability™ Platform" |
||||
.SH NAME |
||||
anvil-special-operations \- This program is generally meant to be used by other programs. |
||||
.SH SYNOPSIS |
||||
.B anvil-special-operations |
||||
\fI\,<command> \/\fR[\fI\,options\/\fR] |
||||
.SH DESCRIPTION |
||||
This tool is used, generally by other parts of the Anvil!, the accomplish tasks that generally can't be accomplished by direct system calls. It's a general purpose tool meant to solve specific corner cases. |
||||
.TP |
||||
.SH OPTIONS |
||||
.TP |
||||
\-?, \-h, \fB\-\-help\fR |
||||
Show this man page. |
||||
.TP |
||||
\fB\-\-log-secure\fR |
||||
When logging, record sensitive data, like passwords. |
||||
.TP |
||||
\-v, \-vv, \-vvv |
||||
Set the log level to 1, 2 or 3 respectively. Be aware that level 3 generates a significant amount of log data. |
||||
.SS "Commands:" |
||||
.TP |
||||
\fB\-\-task\fR |
||||
This is the task being requested. Current optiopns are: |
||||
.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. |
||||
.IP |
||||
.SH AUTHOR |
||||
Written by Madison Kelly, Alteeve staff and the Anvil! project contributors. |
||||
.SH "REPORTING BUGS" |
||||
Report bugs to users@clusterlabs.org |
@ -0,0 +1,120 @@ |
||||
#!/usr/bin/perl |
||||
# |
||||
# This program has no specific purpose. It's a general program for performing certain special tasks that |
||||
# can't be done otherwise in a reliable or efficient way. |
||||
# |
||||
# Exit codes; |
||||
# 0 = Normal exit. |
||||
# 1 = No database connection. |
||||
|
||||
|
||||
use strict; |
||||
use warnings; |
||||
use Anvil::Tools; |
||||
require POSIX; |
||||
use Text::Diff; |
||||
use Data::Dumper; |
||||
|
||||
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0]; |
||||
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0]; |
||||
if (($running_directory =~ /^\./) && ($ENV{PWD})) |
||||
{ |
||||
$running_directory =~ s/^\./$ENV{PWD}/; |
||||
} |
||||
|
||||
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete. |
||||
$| = 1; |
||||
|
||||
my $anvil = Anvil::Tools->new(); |
||||
|
||||
# Read switches (target ([user@]host[:port]) and the file with the target's password. |
||||
$anvil->Get->switches({list => [ |
||||
"task", |
||||
"resource", |
||||
], man => $THIS_FILE}); |
||||
$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->Database->connect(); |
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"}); |
||||
if (not $anvil->data->{sys}{database}{connections}) |
||||
{ |
||||
# No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try |
||||
# 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'}) |
||||
{ |
||||
$anvil->Job->clear(); |
||||
$anvil->Job->get_job_details({debug => 2}); |
||||
$anvil->Job->update_progress({ |
||||
progress => 1, |
||||
job_picked_up_by => $$, |
||||
job_picked_up_at => time, |
||||
message => "message_0311", |
||||
}); |
||||
} |
||||
if ($anvil->data->{switches}{task} eq "refresh-drbd-resource") |
||||
{ |
||||
refresh_drbd_resource($anvil); |
||||
} |
||||
|
||||
$anvil->nice_exit({exit_code => 0}); |
||||
|
||||
|
||||
############################################################################################################# |
||||
# Functions # |
||||
############################################################################################################# |
||||
|
||||
# This function is needed to call 'drbdadm adjust <res>' in a background call from a remote host. This is |
||||
# needed for adding new volumes to an existing resource, as the call from 'drbdadm adjust <res>' won't return |
||||
# until the call is run on all hosts. |
||||
sub refresh_drbd_resource |
||||
{ |
||||
my ($anvil) = @_; |
||||
|
||||
my $resource = $anvil->data->{switches}{resource}; |
||||
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { resource => $resource }}); |
||||
|
||||
if (not $resource) |
||||
{ |
||||
# No resource. |
||||
$anvil->Job->update_progress({ |
||||
progress => 100, |
||||
message => "error_0419", |
||||
job_status => "failed", |
||||
}); |
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => 'err', key => "error_0419"}); |
||||
$anvil->nice_exit({exit_code => 1}); |
||||
} |
||||
|
||||
$anvil->Job->update_progress({ |
||||
progress => 10, |
||||
message => "message_0312,!!resource!".$resource."!!", |
||||
}); |
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "message_0312", variables => { resource => $resource }}); |
||||
|
||||
my $shell_call = $anvil->data->{path}{exe}{drbdadm}." adjust ".$resource; |
||||
$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, |
||||
}}); |
||||
|
||||
$anvil->Job->update_progress({ |
||||
progress => 100, |
||||
message => "message_0313,!!resource!".$resource."!!", |
||||
}); |
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "message_0313", variables => { resource => $resource }}); |
||||
|
||||
$anvil->nice_exit({exit_code => 0}); |
||||
|
||||
return(0); |
||||
} |
Loading…
Reference in new issue