Ensure namespace network resources are deleted even on subnet not found

OpenStackSDK is raising a SDKException when a subnet does not
exist, causing the controller to continuosly restart.
This commit protects from such scenario by ignoring when
such exception happens with certain message.

Closes-bug: 1861314

Change-Id: I82238280a2924f1979c5b0b99399c4570093b360
This commit is contained in:
Maysa Macedo 2020-01-29 17:30:25 +00:00
parent 381af76bf8
commit 7691e94ef3
1 changed files with 11 additions and 5 deletions

View File

@ -102,11 +102,17 @@ class NamespacePodSubnetDriver(default_subnet.DefaultPodSubnetDriver):
# or subnet is already detached.
LOG.debug(e.message)
pass
except os_exc.SDKException:
LOG.exception("Error deleting subnet %(subnet)s from router "
"%(router)s.",
{'subnet': subnet_id, 'router': router_id})
raise
except os_exc.SDKException as e:
# FIXME(maysams): Rely only on the NotFoundException handling
# when the bug fixed at 704998 is merged.
if "could not be found" in str(e.message):
LOG.debug(e.message)
else:
LOG.exception(
"Error deleting subnet %(subnet)s from router "
"%(router)s.", {'subnet': subnet_id, 'router':
router_id})
raise
try:
os_net.delete_network(net_id)