diff --git a/cinder/tests/unit/volume/drivers/dell_emc/powerstore/test_volume_create_from_source.py b/cinder/tests/unit/volume/drivers/dell_emc/powerstore/test_volume_create_from_source.py index 48fa7d8c6bf..4e2920b94d5 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/powerstore/test_volume_create_from_source.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/powerstore/test_volume_create_from_source.py @@ -19,6 +19,7 @@ from cinder import exception from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit.volume.drivers.dell_emc import powerstore +from cinder.volume.drivers.dell_emc.powerstore import client class TestVolumeCreateFromSource(powerstore.TestPowerStoreDriver): @@ -114,3 +115,26 @@ class TestVolumeCreateFromSource(powerstore.TestPowerStoreDriver): self.source_volume ) self.assertIn("Failed to extend PowerStore volume", error.msg) + + @mock.patch("requests.request") + def test_create_snapshot_limit_reached(self, mock_create_snap_limit): + snapshot_limit_reached_response = { + 'errorCode': 0, + 'message': 'messages', + 'messages': [ + { + 'code': client.TOO_MANY_SNAPS_ERROR, + } + ] + } + mock_create_snap_limit.return_value = powerstore.MockResponse( + snapshot_limit_reached_response, rc=400) + error = self.assertRaises( + exception.SnapshotLimitReached, + self.driver.adapter.create_volume_from_source, + self.volume, + self.source_volume + ) + self.assertIn( + "Exceeded the configured limit of 32 snapshots per volume.", + error.msg) diff --git a/cinder/volume/drivers/dell_emc/powerstore/client.py b/cinder/volume/drivers/dell_emc/powerstore/client.py index dba9a1ac378..a98df5bca94 100644 --- a/cinder/volume/drivers/dell_emc/powerstore/client.py +++ b/cinder/volume/drivers/dell_emc/powerstore/client.py @@ -31,6 +31,8 @@ from cinder.volume.drivers.dell_emc.powerstore import utils LOG = logging.getLogger(__name__) VOLUME_NOT_MAPPED_ERROR = "0xE0A08001000F" SESSION_ALREADY_FAILED_OVER_ERROR = "0xE0201005000C" +TOO_MANY_SNAPS_ERROR = "0xE0A040010003" +MAX_SNAPS_IN_VTREE = 32 class PowerStoreClient(object): @@ -271,6 +273,10 @@ class PowerStoreClient(object): "entity": entity, "entity_id": entity_id, }) LOG.error(msg) + if ("messages" in response and + response["messages"][0]["code"] == TOO_MANY_SNAPS_ERROR): + raise exception.SnapshotLimitReached( + set_limit=MAX_SNAPS_IN_VTREE) raise exception.VolumeBackendAPIException(data=msg) return response["id"] diff --git a/releasenotes/notes/bug-1962824-ff0cac0d35021f84.yaml b/releasenotes/notes/bug-1962824-ff0cac0d35021f84.yaml new file mode 100644 index 00000000000..bb9323775e8 --- /dev/null +++ b/releasenotes/notes/bug-1962824-ff0cac0d35021f84.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + PowerStore driver `bug #1962824 + `_: Fixed Cinder + volume caching mechanism for the driver. Now the driver + correctly raises ``exception.SnapshotLimitReached`` when maximum + snapshots are created for a given volume and the volume cache is + invalidated to allow a new row of fast volume clones.