fix: groupdel: false positive in lock contention detection

Groups that were containing 'lock' or 'retry' in their name
would falsely trigger the /etc/passwd and /etc/group lock
contention detection, due to their presence in the output of
the system command, implying several retries that were not
needed.
This commit is contained in:
Stéphane Lesimple 2021-09-24 10:13:40 +00:00 committed by Stéphane Lesimple
parent b40a2fd6e3
commit a6488ee6fb

View file

@ -47,9 +47,14 @@ sub _sys_autoretry {
my $fnret; my $fnret;
foreach my $try (1 .. 10) { foreach my $try (1 .. 10) {
$fnret = OVH::Bastion::execute(%params); $fnret = OVH::Bastion::execute(%params);
if ( ($fnret->value && $fnret->value->{'sysret'} == 10) if (
|| ($fnret->value && $fnret->value->{'stdout'} && grep { /retry|lock/i } @{$fnret->value->{'stdout'}}) ($fnret->value && $fnret->value->{'sysret'} == 10)
|| ($fnret->value && $fnret->value->{'stderr'} && grep { /retry|lock/i } @{$fnret->value->{'stderr'}})) || (
($fnret->value && $fnret->value->{'sysret'} != 0)
&& ( ($fnret->value->{'stdout'} && grep { /retry|lock/i } @{$fnret->value->{'stdout'}})
|| ($fnret->value->{'stderr'} && grep { /retry|lock/i } @{$fnret->value->{'stderr'}}))
)
)
{ {
# too much concurrency, sleep a bit and retry # too much concurrency, sleep a bit and retry
warn_syslog('Too much concurrency on try ' warn_syslog('Too much concurrency on try '