Skip to content

Commit

Permalink
Fix PKIServer.undeploy_webapp()
Browse files Browse the repository at this point in the history
The PKIServer.undeploy_webapp() has been updated to check the
wait time if the is_available() returns a True or throws a
retryable exception.
  • Loading branch information
edewata committed Jun 23, 2023
1 parent 5ce3e63 commit 9bafa9e
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions base/server/python/pki/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,34 +1084,38 @@ def undeploy_webapp(
if webapp_id == 'ROOT':
path = '/'
else:
path = '/' + webapp_id
# end with backslash to avoid redirection
path = '/' + webapp_id + '/'

start_time = datetime.datetime.today()
stopped = False
counter = 0

while not stopped:
while True:
try:
time.sleep(1)
stopped = not self.is_available(path, timeout=timeout)
available = self.is_available(path, timeout=timeout)

if not available:
break # done

# continue waiting

except requests.exceptions.SSLError as e:
max_retry_error = e.args[0]
reason = getattr(max_retry_error, 'reason')
raise Exception('Server unreachable due to SSL error: %s' % reason) from e

except pki.RETRYABLE_EXCEPTIONS as e:
logger.debug('Unable to access path %s: %s', path, e)
# continue waiting

stop_time = datetime.datetime.today()
counter = (stop_time - start_time).total_seconds()
stop_time = datetime.datetime.today()
counter = (stop_time - start_time).total_seconds()

if max_wait is not None and counter >= max_wait:
raise Exception('Web application did not stop after %ds' %
max_wait) from e
if max_wait is not None and counter >= max_wait:
raise Exception('Web application did not stop after %ds' % max_wait)

logger.info(
'Waiting for web application to stop (%ds)',
int(round(counter)))
logger.info('Waiting for web application to stop (%ds)', round(counter))

logger.info('Web application stopped')

Expand Down

0 comments on commit 9bafa9e

Please sign in to comment.