From e0b7c115351fd3177bbc9474962147c0416d5a01 Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Tue, 4 Sep 2018 21:07:39 +0530 Subject: [PATCH] EMC ScaleIO driver does not honor create from snapshot volume size create_volume_from_snapshot can specify a volume size larger than the orginal snapshot. Current code does not appear to handle this size difference. This patch addresses the issue. Change-Id: Ifa247ef0eec00c23afe6f875107a06f756bc180e Closes-Bug: #1560649 --- .../scaleio/test_create_volume_from_snapshot.py | 5 +++++ cinder/volume/drivers/dell_emc/scaleio/driver.py | 10 +++++++++- releasenotes/notes/bug-1560649-d4f3ff71fe4ddb89.yaml | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-1560649-d4f3ff71fe4ddb89.yaml diff --git a/cinder/tests/unit/volume/drivers/dell_emc/scaleio/test_create_volume_from_snapshot.py b/cinder/tests/unit/volume/drivers/dell_emc/scaleio/test_create_volume_from_snapshot.py index 9623b2ca03d..5cefcc8b26f 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/scaleio/test_create_volume_from_snapshot.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/scaleio/test_create_volume_from_snapshot.py @@ -98,3 +98,8 @@ class TestCreateVolumeFromSnapShot(scaleio.TestScaleIODriver): def test_create_volume_from_snapshot(self): self.set_https_response_mode(self.RESPONSE_MODE.Valid) self.driver.create_volume_from_snapshot(self.volume, self.snapshot) + + def test_create_volume_from_snapshot_larger(self): + self.set_https_response_mode(self.RESPONSE_MODE.Valid) + self.volume.size = 2 + self.driver.create_volume_from_snapshot(self.volume, self.snapshot) diff --git a/cinder/volume/drivers/dell_emc/scaleio/driver.py b/cinder/volume/drivers/dell_emc/scaleio/driver.py index b00ed6c4b95..e3a7c5fe3c2 100644 --- a/cinder/volume/drivers/dell_emc/scaleio/driver.py +++ b/cinder/volume/drivers/dell_emc/scaleio/driver.py @@ -788,7 +788,15 @@ class ScaleIODriver(driver.VolumeDriver): {'volname': volume_id, 'snapname': snapname}) - return self._snapshot_volume(volume_id, snapname) + ret = self._snapshot_volume(volume_id, snapname) + if volume.size > snapshot.volume_size: + LOG.info("Extending volume %(vol)s to size %(size)s", + {'vol': ret['provider_id'], + 'size': volume.size}) + self._extend_volume(ret['provider_id'], + snapshot.volume_size, volume.size) + + return ret @staticmethod def _get_headers(): diff --git a/releasenotes/notes/bug-1560649-d4f3ff71fe4ddb89.yaml b/releasenotes/notes/bug-1560649-d4f3ff71fe4ddb89.yaml new file mode 100644 index 00000000000..a6a5562e898 --- /dev/null +++ b/releasenotes/notes/bug-1560649-d4f3ff71fe4ddb89.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Dell EMC Scale IO Driver: Fixes `bug 1560649 + ` + for creating volumes with sizes greater than that of the + original snapshot.