diff --git a/cinder/tests/unit/volume/drivers/test_infinidat.py b/cinder/tests/unit/volume/drivers/test_infinidat.py index ef7302255df..166527f5257 100644 --- a/cinder/tests/unit/volume/drivers/test_infinidat.py +++ b/cinder/tests/unit/volume/drivers/test_infinidat.py @@ -103,6 +103,7 @@ class InfiniboxDriverTestCaseBase(test.TestCase): def _infinibox_mock(self): result = mock.Mock() self._mock_volume = mock.Mock() + self._mock_volume.get_size.return_value = 1 * units.Gi self._mock_volume.has_children.return_value = False self._mock_volume.get_logical_units.return_value = [] self._mock_volume.create_child.return_value = self._mock_volume @@ -299,6 +300,7 @@ class InfiniboxDriverTestCase(InfiniboxDriverTestCaseBase): def test_extend_volume(self): self.driver.extend_volume(test_volume, 2) + self._mock_volume.resize.assert_called_with(1 * units.Gi) def test_extend_volume_api_fail(self): self._mock_volume.resize.side_effect = self._raise_infinisdk diff --git a/cinder/volume/drivers/infinidat.py b/cinder/volume/drivers/infinidat.py index 0b2c0e99a87..47c44154973 100644 --- a/cinder/volume/drivers/infinidat.py +++ b/cinder/volume/drivers/infinidat.py @@ -536,8 +536,9 @@ class InfiniboxVolumeDriver(san.SanISCSIDriver): @infinisdk_to_cinder_exceptions def extend_volume(self, volume, new_size): """Extend the size of a volume.""" - volume = self._get_infinidat_volume(volume) - volume.resize(new_size * capacity.GiB) + infinidat_volume = self._get_infinidat_volume(volume) + size_delta = new_size * capacity.GiB - infinidat_volume.get_size() + infinidat_volume.resize(size_delta) @infinisdk_to_cinder_exceptions def create_snapshot(self, snapshot): diff --git a/releasenotes/notes/fix-extend-volume-939e30f2e9e516bc.yaml b/releasenotes/notes/fix-extend-volume-939e30f2e9e516bc.yaml new file mode 100644 index 00000000000..8e2a6dd43fe --- /dev/null +++ b/releasenotes/notes/fix-extend-volume-939e30f2e9e516bc.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + [`bug 1772421 `_] + INFINIDAT fixed a bug in volume extension feature where volumes + were not extended to target size but added the given target size. +