From d157402791ff8cb57e01362b8708a3aa8892c7fb Mon Sep 17 00:00:00 2001 From: Ignatious Johnson Christopher Date: Fri, 22 May 2015 16:40:12 -0700 Subject: [PATCH] Retrying to create nova-docker in cases where the openstack servrices are starting up after reboot. Change-Id: Ie36a6f52ad5dbbbb371b2295c1f26268a90ffcc2 Closes-Bug: 1456891 --- fabfile/tasks/provision.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fabfile/tasks/provision.py b/fabfile/tasks/provision.py index 0d2886ac1..3cfbe78e8 100644 --- a/fabfile/tasks/provision.py +++ b/fabfile/tasks/provision.py @@ -919,14 +919,19 @@ def setup_nova_aggregate_node(*args): while retry: with settings(warn_only=True): aggregate_list = sudo("(source /etc/contrail/openstackrc; nova aggregate-list)") - if aggregate_list.failed: - sleep(6) - retry -= 1 - continue - break - if hypervisor not in aggregate_list: - sudo("(source /etc/contrail/openstackrc; nova aggregate-create %s nova/%s)" % (hypervisor, hypervisor)) - sudo("(source /etc/contrail/openstackrc; nova aggregate-add-host %s %s)" % (hypervisor, host_name)) + if aggregate_list.failed: # Services might be starting up after reboot + sleep(6) + retry -= 1 + continue + aggregate_details = sudo("(source /etc/contrail/openstackrc;nova aggregate-details %s)" % hypervisor) + if host_name not in aggregate_details: + if hypervisor not in aggregate_list: + create = sudo("(source /etc/contrail/openstackrc; nova aggregate-create %s nova/%s)" % (hypervisor, hypervisor)) + if create.failed: # Services might be starting up after reboot + continue + if sudo("(source /etc/contrail/openstackrc; nova aggregate-add-host %s %s)" % (hypervisor, host_name)).failed: + continue # Services might be starting up after reboot + break # Stop retrying as the aggregate is created and compute is added. @roles('openstack') @task