From 0135d50659a27f7de0c746ce15d0c5f4bf0cce22 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 26 Sep 2024 12:31:12 +0900 Subject: [PATCH] Reject volume extension of in-use volume regardless of multiattach Cinder v3 API does not allow volumes in use to be extended. Drop the logic to allow this operation which was added for v2 api. Story: 2011229 Task: 51083 Change-Id: If2096e739cbb9de78c81840bfba5665893d791f1 --- heat/engine/resources/openstack/cinder/volume.py | 7 +++---- heat/tests/openstack/cinder/test_volume.py | 6 +----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/heat/engine/resources/openstack/cinder/volume.py b/heat/engine/resources/openstack/cinder/volume.py index 14ff244751..ef41355824 100644 --- a/heat/engine/resources/openstack/cinder/volume.py +++ b/heat/engine/resources/openstack/cinder/volume.py @@ -368,9 +368,7 @@ class CinderVolume(vb.BaseVolume, sh.SchedulerHintsMixin): def _ready_to_extend_volume(self): vol = self.client().volumes.get(self.resource_id) - expected_status = ( - 'available', 'in-use') if vol.multiattach else ('available',) - + expected_status = ('available',) if vol.status in expected_status: LOG.debug("Volume %s is ready to extend.", vol.id) return True @@ -382,7 +380,8 @@ class CinderVolume(vb.BaseVolume, sh.SchedulerHintsMixin): LOG.debug("Volume %s is being extended", vol.id) return False - if vol.status != 'available': + expected_status = ('available',) + if vol.status not in expected_status: LOG.info("Resize failed: Volume %(vol)s " "is in %(status)s state.", {'vol': vol.id, 'status': vol.status}) diff --git a/heat/tests/openstack/cinder/test_volume.py b/heat/tests/openstack/cinder/test_volume.py index a137b226a2..3d658e86c7 100644 --- a/heat/tests/openstack/cinder/test_volume.py +++ b/heat/tests/openstack/cinder/test_volume.py @@ -1388,10 +1388,7 @@ class CinderVolumeTest(vt_base.VolumeTestCase): extra_get_mocks=[ vt_base.FakeVolume('extending'), vt_base.FakeVolume('reserved'), - vt_base.FakeVolume('in-use', - multiattach=True), - vt_base.FakeVolume('in-use', - multiattach=False), + vt_base.FakeVolume('in-use'), vt_base.FakeVolume('available')]) stack = utils.parse_stack(self.t, stack_name=self.stack_name) @@ -1401,7 +1398,6 @@ class CinderVolumeTest(vt_base.VolumeTestCase): self.assertEqual(False, rsrc._ready_to_extend_volume()) self.assertEqual(False, rsrc._ready_to_extend_volume()) - self.assertEqual(True, rsrc._ready_to_extend_volume()) self.assertEqual(False, rsrc._ready_to_extend_volume()) self.assertEqual(True, rsrc._ready_to_extend_volume())