Have sec scan retries actually work

Until this change, if `ping` raised an exception, we wouldn't retry properly
This commit is contained in:
Joseph Schorr 2017-03-29 16:19:46 -04:00
parent 08e34c5c48
commit 45179216af
2 changed files with 16 additions and 6 deletions

View file

@ -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;

View file

@ -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)