mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 14:39:28 +00:00
Make init_agent() stop on 403 (too many agents).
This commit is contained in:
@@ -5788,13 +5788,19 @@ sub init_agent {
|
||||
if ( $api_ok ) {
|
||||
$logger->fatal("API reports agent not found: the agent has been "
|
||||
. "deleted, or its UUID (" . ($agent->uuid || '?') . ") "
|
||||
. "is wrong. Check https://cloud.percona.com/agents for a "
|
||||
. "is wrong. Check https://cloud.percona.com/agents for the "
|
||||
. "list of active agents.");
|
||||
}
|
||||
else {
|
||||
$logger->warning("API is down.");
|
||||
}
|
||||
}
|
||||
elsif ( $code && $code == 403 ) {
|
||||
$logger->error("API reports too many agents. Check "
|
||||
. "https://cloud.percona.com/agents for the list of "
|
||||
. "installed agents, delete unused agents, and try again.");
|
||||
last;
|
||||
}
|
||||
else {
|
||||
$logger->warning($EVAL_ERROR);
|
||||
}
|
||||
|
@@ -274,6 +274,50 @@ is_deeply(
|
||||
"PUT then GET Agent"
|
||||
) or diag(Dumper($ua->{requests}));
|
||||
|
||||
# #############################################################################
|
||||
# Status 403 (too many agents) should abort further attempts.
|
||||
# #############################################################################
|
||||
|
||||
$ua->{responses}->{post} = [
|
||||
{ # 1, the fake error
|
||||
code => 403,
|
||||
},
|
||||
];
|
||||
|
||||
@ok = qw(1 1 0);
|
||||
@wait = ();
|
||||
@log = ();
|
||||
$ua->{requests} = [];
|
||||
|
||||
$output = output(
|
||||
sub {
|
||||
($got_agent) = pt_agent::init_agent(
|
||||
agent => $post_agent,
|
||||
action => 'post',
|
||||
link => "/agents",
|
||||
client => $client,
|
||||
interval => $interval,
|
||||
tries => 3,
|
||||
oktorun => $oktorun,
|
||||
);
|
||||
},
|
||||
stderr => 1,
|
||||
);
|
||||
|
||||
is(
|
||||
scalar @wait,
|
||||
0,
|
||||
"Too many agents (403): no wait"
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$ua->{requests},
|
||||
[
|
||||
'POST /agents',
|
||||
],
|
||||
"Too many agents (403): no further requests"
|
||||
) or diag(Dumper($ua->{requests}));
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
Reference in New Issue
Block a user