Properly handle failures during resource cleanup
The current code that cleans-up network resouces from the dynamic
credentials provider does not account for failures during the
cleanup itself (apart from 404).
When the cleanup is triggered by a failure during the setup, the
original failure is hidden which makes debugging impossible.
Catching all exceptions on cleanup, logging a warning and
re-rasing the original exception should fix that.
Fixes bug 1551264
Change-Id: I49dbb314a09fd9b49c9604bc8b5b8ed03ff218d4
diff --git a/tempest/common/dynamic_creds.py b/tempest/common/dynamic_creds.py
index a254211..db12c5b 100644
--- a/tempest/common/dynamic_creds.py
+++ b/tempest/common/dynamic_creds.py
@@ -184,12 +184,19 @@
router = self._create_router(router_name, tenant_id)
self._add_router_interface(router['id'], subnet['id'])
except Exception:
- if router:
- self._clear_isolated_router(router['id'], router['name'])
- if subnet:
- self._clear_isolated_subnet(subnet['id'], subnet['name'])
- if network:
- self._clear_isolated_network(network['id'], network['name'])
+ try:
+ if router:
+ self._clear_isolated_router(router['id'], router['name'])
+ if subnet:
+ self._clear_isolated_subnet(subnet['id'], subnet['name'])
+ if network:
+ self._clear_isolated_network(network['id'],
+ network['name'])
+ except Exception as cleanup_exception:
+ msg = "There was an exception trying to setup network " \
+ "resources for tenant %s, and this error happened " \
+ "trying to clean them up: %s"
+ LOG.warning(msg % (tenant_id, cleanup_exception))
raise
return network, subnet, router