Fix sg cleanup: raise exception on last attemp
Related-PROD: PRODX-4003
Change-Id: I832dd8252635860a40b42a9f8c3f8de87f6ed845
diff --git a/tempest/lib/common/dynamic_creds.py b/tempest/lib/common/dynamic_creds.py
index 2cb0669..c1df32c 100644
--- a/tempest/lib/common/dynamic_creds.py
+++ b/tempest/lib/common/dynamic_creds.py
@@ -404,7 +404,8 @@
secgroups_to_delete = resp_body['security_groups']
for secgroup in secgroups_to_delete:
# Workaround for PRODX-4003
- for i in range(5):
+ attempts = 5
+ for i in range(attempts):
try:
nsg_client.delete_security_group(secgroup['id'])
break
@@ -415,8 +416,11 @@
except lib_exc.Conflict:
LOG.warning('Conflict with state of security group %s, '
'id %s.', secgroup['name'], secgroup['id'])
- time.sleep(1)
- continue
+ if i == attempts - 1:
+ raise
+ else:
+ time.sleep(1)
+ continue
def _clear_isolated_net_resources(self):
client = self.routers_admin_client