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}"
class OctaviaClientException(tobiko.TobikoException,
exceptions.OctaviaClientException):
message = "Octavia client error: {reason}"
OctaviaClientException = exceptions.OctaviaClientException

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