Skip to content

Commit

Permalink
Fixed resource leakage while SNAT cleanup
Browse files Browse the repository at this point in the history
Change-Id: Ida8082da1a43a41df34337314d35466300421461
Closes-bug: #1493266
  • Loading branch information
anbu-enovance committed Sep 8, 2015
1 parent 897cfff commit 74ad79d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/config/svc-monitor/svc_monitor/snat_agent.py
Expand Up @@ -64,7 +64,7 @@ def update_snat_instance(self, router_obj):
self._update_snat_instance(router_obj)
else:
if router_obj.service_instance:
self._delete_snat_instance(router_obj)
self.delete_snat_instance(router_obj)

router_obj.last_virtual_machine_interfaces = copy.copy(
router_obj.virtual_machine_interfaces)
Expand Down Expand Up @@ -231,7 +231,7 @@ def _add_snat_instance(self, router_obj):
self._vnc_lib.logical_router_update(vnc_rtr_obj)
# end add_snat_instance

def _delete_snat_instance(self, router_obj):
def delete_snat_instance(self, router_obj):
try:
vnc_rtr_obj = self._vnc_lib.logical_router_read(id=router_obj.uuid)
except vnc_exc.NoIdError:
Expand Down Expand Up @@ -290,17 +290,20 @@ def cleanup_snat_instance(self, lr_id, si_id):
rt_name = 'rt_' + lr_id
rt_fq_name = si_obj.get_fq_name()[0:2] + [rt_name]
try:
rt_obj = self._vnc_lib.route_table_read(fq_name=rt_fq_name)
rt_obj = self._vnc_lib.route_table_read(
fq_name=rt_fq_name,
fields=['virtual_network_back_refs'])
except vnc_exc.NoIdError:
rt_obj = None

# Delete route table
if rt_obj:
# Disassociate route table to all private networks connected
# onto that router
uuids = [ref['uuid'] for ref in
rt_obj.virtual_network_back_refs]
self._del_route_tables(uuids, rt_obj)
vn_back_refs = rt_obj.get_virtual_network_back_refs()
if vn_back_refs:
uuids = [ref['uuid'] for ref in vn_back_refs]
self._del_route_tables(uuids, rt_obj)
self._vnc_lib.route_table_delete(id=rt_obj.uuid)

# Delete service instance
Expand Down

0 comments on commit 74ad79d

Please sign in to comment.