NSX|V: Fix delete cascade for deleted loadbalancers
In case a loadbalancer was alrady deleted from neutron & nsx but not
from octavia, delete cascade fails to find binding entries.
Fixing that and also adding some logs in the delete cascade logic to make
debugging easier.
Change-Id: Id385366436eda75ad07dc073c5027791efb4d3d9
(cherry picked from commit 1745835153
)
This commit is contained in:
parent
da96a4a0d1
commit
60f212fba8
@ -147,6 +147,13 @@ class EdgeHealthMonitorManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
lb_id = hm['pool']['loadbalancer_id']
|
lb_id = hm['pool']['loadbalancer_id']
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
|
if not lb_binding:
|
||||||
|
# Don't fail deletion if the resource is already gone
|
||||||
|
LOG.warning("Couldn't find LB %s binding during HM deletion",
|
||||||
|
lb_id)
|
||||||
|
completor(success=True)
|
||||||
|
return
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
|
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
|
@ -170,6 +170,12 @@ class EdgeMemberManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
lb_id = self._get_pool_lb_id(member)
|
lb_id = self._get_pool_lb_id(member)
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
|
if not lb_binding:
|
||||||
|
# Don't fail deletion if the resource is already gone
|
||||||
|
LOG.warning("Couldn't find LB %s binding during member deletion",
|
||||||
|
lb_id)
|
||||||
|
completor(success=True)
|
||||||
|
return
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, member['pool_id'])
|
context.session, lb_id, member['pool_id'])
|
||||||
edge_id = lb_binding['edge_id']
|
edge_id = lb_binding['edge_id']
|
||||||
|
@ -157,14 +157,19 @@ class EdgePoolManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
|
|||||||
|
|
||||||
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
lb_binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
|
||||||
context.session, lb_id)
|
context.session, lb_id)
|
||||||
|
if not lb_binding:
|
||||||
|
# Don't fail deletion if the resource is already gone
|
||||||
|
LOG.warning("Couldn't find LB %s binding during pool deletion",
|
||||||
|
lb_id)
|
||||||
|
completor(success=True)
|
||||||
|
return
|
||||||
|
edge_id = lb_binding['edge_id']
|
||||||
|
|
||||||
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
pool_binding = nsxv_db.get_nsxv_lbaas_pool_binding(
|
||||||
context.session, lb_id, pool['id'])
|
context.session, lb_id, pool['id'])
|
||||||
|
|
||||||
edge_id = lb_binding['edge_id']
|
|
||||||
if not pool_binding:
|
if not pool_binding:
|
||||||
completor(success=True)
|
completor(success=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
edge_pool_id = pool_binding['edge_pool_id']
|
edge_pool_id = pool_binding['edge_pool_id']
|
||||||
|
|
||||||
listeners_to_update = []
|
listeners_to_update = []
|
||||||
|
@ -335,8 +335,14 @@ class NSXOctaviaListenerEndpoint(object):
|
|||||||
listener_dict[listener['id']] = listener
|
listener_dict[listener['id']] = listener
|
||||||
for policy in listener.get('l7policies', []):
|
for policy in listener.get('l7policies', []):
|
||||||
for rule in policy.get('rules', []):
|
for rule in policy.get('rules', []):
|
||||||
|
LOG.info("Delete cascade: deleting l7 rule of lb %s",
|
||||||
|
loadbalancer['id'])
|
||||||
self.l7rule.delete_cascade(ctx, rule, dummy_completor)
|
self.l7rule.delete_cascade(ctx, rule, dummy_completor)
|
||||||
|
LOG.info("Delete cascade: deleting l7 policy of lb %s",
|
||||||
|
loadbalancer['id'])
|
||||||
self.l7policy.delete_cascade(ctx, policy, dummy_completor)
|
self.l7policy.delete_cascade(ctx, policy, dummy_completor)
|
||||||
|
LOG.info("Delete cascade: deleting listener of lb %s",
|
||||||
|
loadbalancer['id'])
|
||||||
self.listener.delete_cascade(ctx, listener, dummy_completor)
|
self.listener.delete_cascade(ctx, listener, dummy_completor)
|
||||||
for pool in loadbalancer.get('pools', []):
|
for pool in loadbalancer.get('pools', []):
|
||||||
if not pool.get('loadbalancer'):
|
if not pool.get('loadbalancer'):
|
||||||
@ -352,11 +358,17 @@ class NSXOctaviaListenerEndpoint(object):
|
|||||||
for member in pool.get('members', []):
|
for member in pool.get('members', []):
|
||||||
if not member.get('pool'):
|
if not member.get('pool'):
|
||||||
member['pool'] = pool
|
member['pool'] = pool
|
||||||
|
LOG.info("Delete cascade: deleting old_member of lb %s",
|
||||||
|
loadbalancer['id'])
|
||||||
self.member.delete_cascade(ctx, member, dummy_completor)
|
self.member.delete_cascade(ctx, member, dummy_completor)
|
||||||
if pool.get('healthmonitor'):
|
if pool.get('healthmonitor'):
|
||||||
pool['healthmonitor']['pool'] = pool
|
pool['healthmonitor']['pool'] = pool
|
||||||
|
LOG.info("Delete cascade: deleting HM of lb %s",
|
||||||
|
loadbalancer['id'])
|
||||||
self.healthmonitor.delete_cascade(
|
self.healthmonitor.delete_cascade(
|
||||||
ctx, pool['healthmonitor'], dummy_completor)
|
ctx, pool['healthmonitor'], dummy_completor)
|
||||||
|
LOG.info("Delete cascade: deleting pool of lb %s",
|
||||||
|
loadbalancer['id'])
|
||||||
self.pool.delete_cascade(ctx, pool, dummy_completor)
|
self.pool.delete_cascade(ctx, pool, dummy_completor)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error('NSX driver loadbalancer_delete_cascade failed to '
|
LOG.error('NSX driver loadbalancer_delete_cascade failed to '
|
||||||
|
Loading…
Reference in New Issue
Block a user