Fixes cleaning up HA Neutron objects 85/20185/1
authorTim Rozet <trozet@redhat.com>
Thu, 1 Sep 2016 19:05:07 +0000 (15:05 -0400)
committerTim Rozet <trozet@redhat.com>
Thu, 1 Sep 2016 19:05:07 +0000 (15:05 -0400)
This fixes a race condition where the cleanup method is trying to remove
HA networks, while Neutron is also trying to remove the network - after
the HA router is removed.  This only applies to installations where
Neutron L3 HA is enabled (nosdn cases only).

JIRA: FUNCTEST-454

Change-Id: If06b6f6297e99dcce4b0f2aff8ec80b47488ee90
Signed-off-by: Tim Rozet <trozet@redhat.com>
utils/openstack_clean.py

index 8aba763..3b937c9 100755 (executable)
@@ -202,9 +202,20 @@ def remove_networks(neutron_client, default_networks, default_routers):
     else:
         remove_routers(neutron_client, routers, default_routers)
 
+    # trozet: wait for Neutron to auto-cleanup HA networks when HA router is
+    #  deleted
+    time.sleep(5)
+
     # remove networks
     if network_ids is not None:
         for net_id in network_ids:
+            networks = os_utils.get_network_list(neutron_client)
+            if networks is None:
+                logger.debug("No networks left to remove")
+                break
+            elif not any(network['id'] == net_id for network in networks):
+                logger.debug("Network %s has already been removed" % net_id)
+                continue
             logger.debug("Removing network %s ..." % net_id)
             if os_utils.delete_neutron_net(neutron_client, net_id):
                 logger.debug("  > Done!")