From 5a3008b75b1e0c82ccbaeee73c49977512065787 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Thu, 26 May 2016 18:28:11 +0300 Subject: [PATCH] LBaaSv2: Delete LB even when backend is broken When backend if inconsistent with the Neutron DB, we should still be able to delete the LB, while posting a proper error message. Change-Id: Ice5b2bba255297711a620f61e75cafce0115ae93 Fixes-bug: #1663602 --- .../lbaas/nsx_v/v2/loadbalancer_mgr.py | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py b/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py index 891d98e132..e1f4b3ba86 100644 --- a/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py @@ -68,23 +68,27 @@ class EdgeLoadBalancerManager(base_mgr.EdgeLoadbalancerBaseManager): @log_helpers.log_method_call def delete(self, context, lb): - try: - binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding( - context.session, lb.id) - if binding: + binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding( + context.session, lb.id) + if binding: + try: lb_common.del_vip_fw_rule(self.vcns, binding['edge_id'], binding['edge_fw_rule_id']) + except nsxv_exc.VcnsApiException as e: + LOG.error(_LE('Failed to delete loadbalancer %(lb)s FW rule. ' + 'exception is %(exc)s'), {'lb': lb.id, 'exc': e}) + try: lb_common.del_vip_as_secondary_ip(self.vcns, binding['edge_id'], lb.vip_address) - nsxv_db.del_nsxv_lbaas_loadbalancer_binding(context.session, - lb.id) - self.lbv2_driver.load_balancer.successful_completion( - context, lb, delete=True) - except nsxv_exc.VcnsApiException: - with excutils.save_and_reraise_exception(): - self.lbv2_driver.load_balancer.failed_completion(context, lb) - LOG.error(_LE('Failed to delete pool %s'), lb.id) + except Exception as e: + LOG.error(_LE('Failed to delete loadbalancer %(lb)s interface' + ' IP. exception is %(exc)s'), + {'lb': lb.id, 'exc': e}) + + nsxv_db.del_nsxv_lbaas_loadbalancer_binding(context.session, lb.id) + self.lbv2_driver.load_balancer.successful_completion(context, lb, + delete=True) @log_helpers.log_method_call def refresh(self, context, lb):