aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
authorCiprian Barbu <ciprian.barbu@enea.com>2017-03-02 19:27:24 +0200
committerCiprian Barbu <ciprian.barbu@enea.com>2017-03-03 17:24:20 +0200
commit430b7e154f847b0dfb99c8419a999074e175e1e7 (patch)
treef82bf346dfb3988fcc6cbd7c823e8b9ac83202e6 /functest/utils
parenta5cb507c061738a50ca358147a135a1c4498ff22 (diff)
Add extra check to avoid double delete of instances
JIRA: FUNCTEST-748 Sometimes Openstack doesn't handle deletion in a timely manner which can lead to openstack_clean to think there are leftovers from a previous test when in fact the instances are pending deletion. This patch tries to better handle this kind of situation that would otherwise result in a double free and eventually <class 'nova.exception.InstanceInvalidState'> (HTTP 500) Change-Id: Id0d9b61d8380e9b12fc7acd46cd84260714f4baf Signed-off-by: Ciprian Barbu <ciprian.barbu@enea.com>
Diffstat (limited to 'functest/utils')
-rwxr-xr-xfunctest/utils/openstack_clean.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index 15a8f33d..ce61fcac 100755
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -49,9 +49,14 @@ def remove_instances(nova_client, default_instances):
for instance in instances:
instance_name = getattr(instance, 'name')
instance_id = getattr(instance, 'id')
+ instance_status = getattr(instance, 'status')
+ instance_state = getattr(instance, 'OS-EXT-STS:task_state')
+
logger.debug("'%s', ID=%s " % (instance_name, instance_id))
if (instance_id not in default_instances and
- instance_name not in default_instances.values()):
+ instance_name not in default_instances.values() and
+ instance_status != 'DELETED' and
+ (instance_status != 'BUILD' or instance_state != 'deleting')):
logger.debug("Removing instance '%s' ..." % instance_id)
if os_utils.delete_instance(nova_client, instance_id):
logger.debug(" > Request sent.")