From 45179216afaa4c285eee45af7cae2af604fc9be6 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 29 Mar 2017 16:19:46 -0400 Subject: [PATCH] Have sec scan retries actually work Until this change, if `ping` raised an exception, we wouldn't retry properly --- static/css/core-ui.css | 2 +- util/config/validators/validate_secscan.py | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/static/css/core-ui.css b/static/css/core-ui.css index b080347e9..217d31de1 100644 --- a/static/css/core-ui.css +++ b/static/css/core-ui.css @@ -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; diff --git a/util/config/validators/validate_secscan.py b/util/config/validators/validate_secscan.py index 14cf0e81b..c5efd34b0 100644 --- a/util/config/validators/validate_secscan.py +++ b/util/config/validators/validate_secscan.py @@ -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)