Fix cleanup for EC2 test_compute_with_volumes

Volume cleanup for test_compute_with_volumes fails when volume is in
"error" state.

cleanup part destroy_volume_wait() is to delete the volume and detach
before delete if necessary.
In destroy_volume_wait(), before detaching the volume there is checks if
volume status is not "available" but that is not sufficient enough to
guarantee that volume is attached. Volume status can be "error".

When something wrong happens with Volume and Volume is in "error"
state then, detach request will through the error as mentioned in
bug# 1310896.

Logic in destroy_volume_wait should be checking of state as "in-use" before
trying to detach volume. So that if it is in "in-use" state then detach and
go for volume delete. If not in "in-use" ("available" or  "error" etc) then
only go for volume delete.

Change-Id: I1882dbba947cc294cb4fe119db50f2a1c23b75be
Related-Bug: #1310896
This commit is contained in:
ghanshyam 2014-10-14 17:23:31 +09:00
parent dbc8e82b84
commit 308640c112
1 changed files with 4 additions and 1 deletions

View File

@ -498,7 +498,10 @@ class BotoTestCase(tempest.test.BaseTestCase):
def _volume_state():
volume.update(validate=True)
try:
if volume.status != "available":
# NOTE(gmann): Make sure volume is attached.
# Checking status as 'not "available"' is not enough to make
# sure volume is attached as it can be in "error" state
if volume.status == "in-use":
volume.detach(force=True)
except BaseException:
LOG.exception("Failed to detach volume %s" % volume)