mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
HEAD /agents doesn't work because app has /agents link. Use GET /ping instead.
This commit is contained in:
53
bin/pt-agent
53
bin/pt-agent
@@ -965,23 +965,6 @@ sub get {
|
|||||||
return $resource_objects;
|
return $resource_objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub head {
|
|
||||||
my ($self, %args) = @_;
|
|
||||||
|
|
||||||
have_required_args(\%args, qw(
|
|
||||||
link
|
|
||||||
)) or die;
|
|
||||||
my ($link) = $args{link};
|
|
||||||
|
|
||||||
eval {
|
|
||||||
$self->_request(
|
|
||||||
method => 'HEAD',
|
|
||||||
link => $link,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
return $EVAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub post {
|
sub post {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->_set(
|
$self->_set(
|
||||||
@@ -5798,13 +5781,9 @@ sub init_agent {
|
|||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
my $code = $client->response->code;
|
my $code = $client->response->code;
|
||||||
if ( $code && $code == 404 ) {
|
if ( $code && $code == 404 ) {
|
||||||
my $agents_link = $client->entry_link . '/agents';
|
my $api_ok = ping_api(
|
||||||
$agents_link =~ s!/{2,}!/!g; # //agents doesn't work
|
client => $client,
|
||||||
my $api_ok = eval {
|
);
|
||||||
$client->head(
|
|
||||||
link => $agents_link,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
if ( $api_ok ) {
|
if ( $api_ok ) {
|
||||||
$logger->fatal("API reports agent not found: the agent has been "
|
$logger->fatal("API reports agent not found: the agent has been "
|
||||||
. "deleted, or its UUID (" . ($agent->uuid || '?') . ") "
|
. "deleted, or its UUID (" . ($agent->uuid || '?') . ") "
|
||||||
@@ -6267,13 +6246,9 @@ sub get_config {
|
|||||||
if (blessed($e)) {
|
if (blessed($e)) {
|
||||||
if ($e->isa('Percona::WebAPI::Exception::Request')) {
|
if ($e->isa('Percona::WebAPI::Exception::Request')) {
|
||||||
if ( $e->status == 404 ) {
|
if ( $e->status == 404 ) {
|
||||||
my $agents_link = $client->entry_link . '/agents';
|
my $api_ok = ping_api(
|
||||||
$agents_link =~ s!/{2,}!/!g; # //agents doesn't work
|
client => $client,
|
||||||
my $api_ok = eval {
|
);
|
||||||
$client->head(
|
|
||||||
link => $agents_link,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
if ( $api_ok ) {
|
if ( $api_ok ) {
|
||||||
stop_all_services(
|
stop_all_services(
|
||||||
lib_dir => $lib_dir,
|
lib_dir => $lib_dir,
|
||||||
@@ -9117,6 +9092,22 @@ sub too_many_agents {
|
|||||||
return scalar @pids > 10 ? 1 : 0;
|
return scalar @pids > 10 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub ping_api {
|
||||||
|
my (%args) = @_;
|
||||||
|
have_required_args(\%args, qw(
|
||||||
|
client
|
||||||
|
)) or die;
|
||||||
|
my $client = $args{client};
|
||||||
|
my $ping_link = $client->entry_link . '/ping';
|
||||||
|
$ping_link =~ s!/{2,}!/!g; # //agents doesn't work
|
||||||
|
eval {
|
||||||
|
$client->get(
|
||||||
|
link => $ping_link,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return $EVAL_ERROR ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
sub _logger {
|
sub _logger {
|
||||||
my $_logger = shift;
|
my $_logger = shift;
|
||||||
$logger = $_logger if $_logger;
|
$logger = $_logger if $_logger;
|
||||||
|
@@ -159,23 +159,6 @@ sub get {
|
|||||||
return $resource_objects;
|
return $resource_objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub head {
|
|
||||||
my ($self, %args) = @_;
|
|
||||||
|
|
||||||
have_required_args(\%args, qw(
|
|
||||||
link
|
|
||||||
)) or die;
|
|
||||||
my ($link) = $args{link};
|
|
||||||
|
|
||||||
eval {
|
|
||||||
$self->_request(
|
|
||||||
method => 'HEAD',
|
|
||||||
link => $link,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
return $EVAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
# For a successful POST, the server sets the Location header with
|
# For a successful POST, the server sets the Location header with
|
||||||
# the URI of the newly created resource.
|
# the URI of the newly created resource.
|
||||||
sub post {
|
sub post {
|
||||||
|
Reference in New Issue
Block a user