Have sec scan retries actually work
Until this change, if `ping` raised an exception, we wouldn't retry properly
This commit is contained in:
parent
08e34c5c48
commit
45179216af
2 changed files with 16 additions and 6 deletions
|
@ -763,7 +763,7 @@ a:focus {
|
|||
}
|
||||
|
||||
.config-setup-tool .service-verification-error {
|
||||
white-space: pre;
|
||||
white-space: pre-wrap;
|
||||
margin-top: 10px;
|
||||
margin-left: 36px;
|
||||
margin-bottom: 20px;
|
||||
|
|
|
@ -24,13 +24,23 @@ class SecurityScannerValidator(BaseValidator):
|
|||
# We have to wait for JWT proxy to restart with the newly generated key.
|
||||
max_tries = 5
|
||||
response = None
|
||||
last_exception = None
|
||||
|
||||
while max_tries > 0:
|
||||
response = api.ping()
|
||||
if response.status_code == 200:
|
||||
return
|
||||
try:
|
||||
response = api.ping()
|
||||
last_exception = None
|
||||
if response.status_code == 200:
|
||||
return
|
||||
except Exception as ex:
|
||||
last_exception = ex
|
||||
|
||||
time.sleep(1)
|
||||
max_tries = max_tries - 1
|
||||
|
||||
message = 'Expected 200 status code, got %s: %s' % (response.status_code, response.text)
|
||||
raise ConfigValidationException('Could not ping security scanner: %s' % message)
|
||||
if last_exception is not None:
|
||||
message = str(last_exception)
|
||||
raise ConfigValidationException('Could not ping security scanner: %s' % message)
|
||||
else:
|
||||
message = 'Expected 200 status code, got %s: %s' % (response.status_code, response.text)
|
||||
raise ConfigValidationException('Could not ping security scanner: %s' % message)
|
||||
|
|
Reference in a new issue