Browse Source

Merge "Fix cuncurrency problem in wait_for_cloud_init_status function"

changes/82/763482/16
Zuul 5 months ago committed by Gerrit Code Review
parent
commit
534329600d
  1. 17
      tobiko/openstack/nova/_cloud_init.py

17
tobiko/openstack/nova/_cloud_init.py

@ -26,7 +26,7 @@ LOG = log.getLogger(__name__)
CLOUD_INIT_TRANSIENT_STATES = {
'done': tuple(['running'])
'done': ('running',)
}
CLOUD_INIT_OUTPUT_FILE = '/var/log/cloud-init-output.log'
@ -199,14 +199,21 @@ def wait_for_cloud_init_status(
timeout=timeout,
tail=tail)
actual_status: typing.Optional[str]
for attempt in tobiko.retry(timeout=timeout,
interval=sleep_interval,
default_timeout=1200.,
default_interval=5.):
actual_status = get_cloud_init_status(ssh_client=ssh_client,
timeout=attempt.time_left)
if actual_status in expected_states:
break
try:
actual_status = get_cloud_init_status(ssh_client=ssh_client,
timeout=attempt.time_left)
except sh.ShellCommandFailed:
LOG.exception('Unable to get cloud-init status')
actual_status = None
else:
if actual_status in expected_states:
break
if attempt.is_last:
raise WaitForCloudInitTimeoutError(

Loading…
Cancel
Save