Skip to content

Commit

Permalink
Merge "svc_monitor: recover properly from missing LR on SNAT creation…
Browse files Browse the repository at this point in the history
…" into R3.2
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jun 1, 2018
2 parents f1c093f + 3a7c08e commit 0290a62
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/config/svc-monitor/svc_monitor/snat_agent.py
Expand Up @@ -183,7 +183,7 @@ def _add_snat_instance(self, router_obj):
si_obj.set_service_template(st_obj)

if si_created:
self._vnc_lib.service_instance_create(si_obj)
si_uuid = self._vnc_lib.service_instance_create(si_obj)
else:
self._vnc_lib.service_instance_update(si_obj)

Expand All @@ -198,16 +198,26 @@ def _add_snat_instance(self, router_obj):
rt_created = True
rt_obj.set_routes(RouteTableType.factory([route_obj]))
if rt_created:
self._vnc_lib.route_table_create(rt_obj)
rt_uuid = self._vnc_lib.route_table_create(rt_obj)
else:
self._vnc_lib.route_table_update(rt_obj)
rt_uuid = rt_obj.uuid

# Associate route table to logical router
vnc_rtr_obj.add_route_table(rt_obj)

# Add logical gateway virtual network
vnc_rtr_obj.set_service_instance(si_obj)
self._vnc_lib.logical_router_update(vnc_rtr_obj)
try:
self._vnc_lib.logical_router_update(vnc_rtr_obj)
except vnc_exc.NoIdError:
self.logger.warning("Logical router '%s' (%s) has disappear. "
"Add SNAT instance failed." % (router_obj.get_fq_name_str(), router_obj.uuid))
# cleanup what was created in the meantime
self._vnc_lib.route_table_delete(id=rt_uuid)
self.delete_snat_vn(si_obj)
self._vnc_lib.service_instance_delete(id=si_uuid)
return
# end add_snat_instance

def delete_snat_vn(self, si_obj):
Expand All @@ -217,7 +227,6 @@ def delete_snat_vn(self, si_obj):
try:
vn_obj = self._vnc_lib.virtual_network_read(fq_name=vn_fq_name)
except vnc_exc.NoIdError:

self.logger.debug("Unable to find virtual network %s. " \
"Delete of SNAT instance %s failed." % \
(vn_name, si_obj.name))
Expand Down

0 comments on commit 0290a62

Please sign in to comment.