Update wait_for_octavia_service function

Change-Id: Ibfa03c3b7e580799004c16e8814b5042fc34d8be
This commit is contained in:
Federico Ressi 2021-10-28 13:37:28 +02:00
parent a89b220c98
commit 4e47800f30
2 changed files with 13 additions and 18 deletions

View File

@ -28,6 +28,4 @@ class TimeoutException(tobiko.TobikoException):
message = "Timeout exception: {reason}" message = "Timeout exception: {reason}"
class OctaviaClientException(tobiko.TobikoException, OctaviaClientException = exceptions.OctaviaClientException
exceptions.OctaviaClientException):
message = "Octavia client error: {reason}"

View File

@ -144,24 +144,21 @@ def wait_for_lb_to_be_updated_and_active(loadbalancer_id):
def wait_for_octavia_service(loadbalancer_id: str, def wait_for_octavia_service(loadbalancer_id: str,
waiting_msg='Waiting for the LB to become '
'functional again...',
interval: tobiko.Seconds = None, interval: tobiko.Seconds = None,
timeout: tobiko.Seconds = None, timeout: tobiko.Seconds = None,
count: int = 10): client=None):
LOG.info(waiting_msg)
for attempt in tobiko.retry(timeout=timeout, for attempt in tobiko.retry(timeout=timeout,
interval=interval, interval=interval,
count=count): default_timeout=180.,
default_interval=5.):
try: try:
octavia.list_amphorae(loadbalancer_id=loadbalancer_id) octavia.list_amphorae(loadbalancer_id=loadbalancer_id,
LOG.info('Octavia service is available!') client=client)
return except octavia.OctaviaClientException as ex:
except Exception as ex: LOG.debug(f"Error listing amphorae: {ex}")
if issubclass(octavia.OctaviaClientException, ex.__class__):
LOG.info(waiting_msg)
if attempt.is_last: if attempt.is_last:
raise raise
LOG.info('Waiting for the LB to become functional again...')
else: else:
raise ex LOG.info('Octavia service is available!')
break