]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
EMC ScaleIO - fix bug in extend volume
authorMatan Sabag <matan.sabag@emc.com>
Sat, 30 Jan 2016 22:09:27 +0000 (14:09 -0800)
committerMatan Sabag <matan.sabag@emc.com>
Tue, 16 Feb 2016 08:03:02 +0000 (00:03 -0800)
Our storage system works in 8GB granularity.
If User extends volume from X to Y while X==Y(mod 8)
it is redundant and fails the REST call.

DocImpact
Closes-Bug: #1539099

Change-Id: I75bc5bbffa506c4cb29d9741f8f54874290c0101

cinder/tests/unit/volume/drivers/emc/scaleio/test_extend_volume.py
cinder/volume/drivers/emc/scaleio.py

index 730401fc12d52456b98cca9236a55e7e3c4f9858..2b1ab30d3e0ffe11c4b9c134e689555edea1bd1d 100644 (file)
@@ -29,7 +29,7 @@ class TestExtendVolume(scaleio.TestScaleIODriver):
     The 7 size should be either rounded up to 8 or raise an exception
     based on the round_volume_capacity config setting.
     """
-    NEW_SIZE = 8
+    NEW_SIZE = 16
     BAD_SIZE = 7
 
     def setUp(self):
index 1772ab614440306f3394180eaa2d71015c152403..fbdb835051b17e748cd021269570206d18ea6bfb 100644 (file)
@@ -557,10 +557,10 @@ class ScaleIODriver(driver.VolumeDriver):
 
         # Round up the volume size so that it is a granularity of 8 GBs
         # because ScaleIO only supports volumes with a granularity of 8 GBs.
-        if new_size % 8 == 0:
-            volume_new_size = new_size
-        else:
-            volume_new_size = new_size + 8 - (new_size % 8)
+        volume_new_size = self._round_to_8_gran(new_size)
+        volume_real_old_size = self._round_to_8_gran(volume.size)
+        if volume_real_old_size == volume_new_size:
+            return
 
         round_volume_capacity = self.configuration.sio_round_volume_capacity
         if (not round_volume_capacity and not new_size % 8 == 0):
@@ -586,6 +586,11 @@ class ScaleIODriver(driver.VolumeDriver):
             LOG.error(msg)
             raise exception.VolumeBackendAPIException(data=msg)
 
+    def _round_to_8_gran(self, size):
+        if size % 8 == 0:
+            return size
+        return size + 8 - (size % 8)
+
     def create_cloned_volume(self, volume, src_vref):
         """Creates a cloned volume."""
         volume_id = src_vref['provider_id']