Merge "NSX|V3+P: Fix loadbalancer delete to support error cases"

This commit is contained in:
Zuul 2020-02-23 12:50:26 +00:00 committed by Gerrit Code Review
commit 519c9e0403
2 changed files with 36 additions and 17 deletions

View File

@ -113,8 +113,14 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
completor(success=True)
def delete(self, context, lb, completor):
router_id = lb_utils.get_router_from_network(
context, self.core_plugin, lb['vip_subnet_id'])
router_id = None
try:
router_id = lb_utils.get_router_from_network(
context, self.core_plugin, lb['vip_subnet_id'])
except n_exc.SubnetNotFound:
LOG.warning("VIP subnet %s not found while deleting "
"loadbalancer %s", lb['vip_subnet_id'], lb['id'])
service_client = self.core_plugin.nsxpolicy.load_balancer.lb_service
if not router_id:
@ -149,18 +155,22 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
{'lb': lb['id'], 'err': e})
# Make sure the vip port is not marked with a vmware device owner
port = self.core_plugin.get_port(
context.elevated(), lb['vip_port_id'])
if port.get('device_owner') == lb_const.VMWARE_LB_VIP_OWNER:
try:
try:
port = self.core_plugin.get_port(
context.elevated(), lb['vip_port_id'])
if port.get('device_owner') == lb_const.VMWARE_LB_VIP_OWNER:
self.core_plugin.update_port(
context.elevated(), lb['vip_port_id'],
{'port': {'device_id': '',
'device_owner': ''}})
except Exception as e:
# Just log the error as all other resources were deleted
LOG.error("Failed to update neutron port %s devices upon "
"loadbalancer deletion: %s", lb['vip_port_id'], e)
except n_exc.PortNotFound:
# Only log the error and continue anyway
LOG.warning("VIP port %s not found while deleting loadbalancer %s",
lb['vip_port_id'], lb['id'])
except Exception as e:
# Just log the error as all other resources were deleted
LOG.error("Failed to update neutron port %s devices upon "
"loadbalancer deletion: %s", lb['vip_port_id'], e)
completor(success=True)

View File

@ -222,13 +222,22 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager):
self.core_plugin.delete_service_router(context,
router_id)
# Make sure the vip port is not marked with a vmware device owner
port = self.core_plugin.get_port(
context.elevated(), lb['vip_port_id'])
if port.get('device_owner') == lb_const.VMWARE_LB_VIP_OWNER:
self.core_plugin.update_port(
context.elevated(), lb['vip_port_id'],
{'port': {'device_id': '',
'device_owner': ''}})
try:
port = self.core_plugin.get_port(
context.elevated(), lb['vip_port_id'])
if port.get('device_owner') == lb_const.VMWARE_LB_VIP_OWNER:
self.core_plugin.update_port(
context.elevated(), lb['vip_port_id'],
{'port': {'device_id': '',
'device_owner': ''}})
except n_exc.PortNotFound:
# Only log the error and continue anyway
LOG.warning("VIP port %s not found while deleting loadbalancer %s",
lb['vip_port_id'], lb['id'])
except Exception as e:
# Just log the error as all other resources were deleted
LOG.error("Failed to update neutron port %s devices upon "
"loadbalancer deletion: %s", lb['vip_port_id'], e)
completor(success=True)