From bb01fe9314f990accfbb1ea11c2a63b4fab1c27f Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Wed, 8 Jun 2016 15:17:16 +0300 Subject: [PATCH] [Tempest] Handle errored shares correctly using recreation logic If we allow share recreation and get some share errored making it part of CG, then we fail to create CG snapshot from CG that owns this share. Because cleanup step was not reached yet. Therefore, consider this case and delete errored shares immediately. Change-Id: Ib05598de8fbd1c9a735ca91159f3f5cfb86d8889 Closes-Bug: #1577887 --- manila_tempest_tests/tests/api/base.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py index dd90d8fa58..a599196cee 100644 --- a/manila_tempest_tests/tests/api/base.py +++ b/manila_tempest_tests/tests/api/base.py @@ -454,18 +454,28 @@ class BaseSharesTest(test.BaseTestCase): for d in data: if d["available"]: continue + client = d["kwargs"]["client"] + share_id = d["share"]["id"] try: - d["kwargs"]["client"].wait_for_share_status( - d["share"]["id"], "available") + client.wait_for_share_status(share_id, "available") d["available"] = True except (share_exceptions.ShareBuildErrorException, exceptions.TimeoutException) as e: if CONF.share.share_creation_retry_number > d["cnt"]: d["cnt"] += 1 msg = ("Share '%s' failed to be built. " - "Trying create another." % d["share"]["id"]) + "Trying create another." % share_id) LOG.error(msg) LOG.error(e) + cg_id = d["kwargs"].get("consistency_group_id") + if cg_id: + # NOTE(vponomaryov): delete errored share + # immediately in case share is part of CG. + client.delete_share( + share_id, + params={"consistency_group_id": cg_id}) + client.wait_for_resource_deletion( + share_id=share_id) d["share"] = cls._create_share( *d["args"], **d["kwargs"]) else: