From dd43e222e3efa30b4849e45c3adc2ffad206afa1 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Wed, 14 Jun 2017 23:56:29 -0700 Subject: [PATCH] NSX|V: treat edge cases with edge deletions - When doing a deletion is a async task we create a new context to deal with that deletion - We add some additional logs Change-Id: I9a707d1292858428ab51295167360bfa26513430 --- vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py | 6 ++++++ vmware_nsx/plugins/nsx_v/vshield/edge_utils.py | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py b/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py index b072b11781..d35b44c207 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py @@ -17,6 +17,7 @@ import random import time from neutron_lib import constants as lib_const +from neutron_lib import context as q_context from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils @@ -530,9 +531,14 @@ class EdgeApplianceDriver(object): LOG.error("Failed to resize edge: %s", e.response) def delete_edge(self, context, router_id, edge_id, dist=False): + LOG.debug("Deleting edge %s", edge_id) + if context is None: + context = q_context.get_admin_context() try: + LOG.debug("Deleting router binding %s", router_id) nsxv_db.delete_nsxv_router_binding(context.session, router_id) if not dist: + LOG.debug("Deleting vnic bindings for edge %s", edge_id) nsxv_db.clean_edge_vnic_binding(context.session, edge_id) except sa_exc.NoResultFound: LOG.warning("Router Binding for %s not found", router_id) diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py index 104de20e20..96efee1818 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py @@ -292,7 +292,7 @@ class EdgeManager(object): context.session, router_binding['router_id'], status=constants.PENDING_DELETE) self._get_worker_pool().spawn_n( - self.nsxv_manager.delete_edge, q_context.get_admin_context(), + self.nsxv_manager.delete_edge, None, router_binding['router_id'], router_binding['edge_id'], dist=(router_binding['edge_type'] == nsxv_constants.VDR_EDGE)) @@ -308,7 +308,7 @@ class EdgeManager(object): LOG.debug("Start deleting extra edge: %s in pool", binding['edge_id']) self._get_worker_pool().spawn_n( - self.nsxv_manager.delete_edge, q_context.get_admin_context(), + self.nsxv_manager.delete_edge, None, binding['router_id'], binding['edge_id'], dist=(binding['edge_type'] == nsxv_constants.VDR_EDGE)) @@ -775,7 +775,7 @@ class EdgeManager(object): # delete edge self._get_worker_pool().spawn_n( self.nsxv_manager.delete_edge, - q_context.get_admin_context(), + None, router_id, edge_id, dist=dist) return @@ -814,7 +814,7 @@ class EdgeManager(object): # delete edge self._get_worker_pool().spawn_n( self.nsxv_manager.delete_edge, - q_context.get_admin_context(), + None, router_id, edge_id, dist=dist) def _allocate_dhcp_edge_appliance(self, context, resource_id,