]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
ScaleIO extend volume round up capacity
authorXing Yang <xing.yang@emc.com>
Mon, 16 Nov 2015 04:50:59 +0000 (23:50 -0500)
committerXing Yang <xing.yang@emc.com>
Mon, 16 Nov 2015 09:21:03 +0000 (04:21 -0500)
ScaleIO only supports volumes with a granularity of 8 GB.
In extend volume, we need to round up the volume to the
nearest size that is a granularity of 8 GBs.

Change-Id: I1d1340fa6d31f89a0c166e66c7c84583dbfe5102
Closes-Bug: #1519613

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

index 42dc498a2d7b3da33a0fe1dbaee74c361e1e8890..730401fc12d52456b98cca9236a55e7e3c4f9858 100644 (file)
@@ -93,10 +93,7 @@ class TestExtendVolume(scaleio.TestScaleIODriver):
         self.driver.configuration.set_override('sio_round_volume_capacity',
                                                override=False)
         self.set_https_response_mode(self.RESPONSE_MODE.Valid)
-        self.assertRaises(exception.VolumeBackendAPIException,
-                          self.driver.extend_volume,
-                          self.volume,
-                          self.BAD_SIZE)
+        self.driver.extend_volume(self.volume, self.BAD_SIZE)
 
     def test_extend_volume_bad_size_round(self):
         self.driver.configuration.set_override('sio_round_volume_capacity',
index b9cb44ae20ae3e34f31a37c906e4ba01052128d2..26c2ec4dd6da0230d6b88c7594bfdb4537600fa3 100644 (file)
@@ -522,10 +522,11 @@ class ScaleIODriver(driver.VolumeDriver):
         return verify_cert
 
     def extend_volume(self, volume, new_size):
-        """Extends the size of an existing available ScaleIO volume."""
-
-        self._check_volume_size(new_size)
+        """Extends the size of an existing available ScaleIO volume.
 
+        This action will round up the volume to the nearest size that is
+        a granularity of 8 GBs.
+        """
         vol_id = volume['provider_id']
         LOG.info(_LI(
             "ScaleIO extend volume: volume %(volname)s to size %(new_size)s."),
@@ -539,7 +540,20 @@ class ScaleIODriver(driver.VolumeDriver):
                    "/api/instances/Volume::%(vol_id)s"
                    "/action/setVolumeSize") % req_vars
         LOG.info(_LI("Change volume capacity request: %s."), request)
-        volume_new_size = new_size
+
+        # 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)
+
+        round_volume_capacity = self.configuration.sio_round_volume_capacity
+        if (not round_volume_capacity and not new_size % 8 == 0):
+            LOG.warning(_LW("ScaleIO only supports volumes with a granularity "
+                            "of 8 GBs. The new volume size is: %d."),
+                        volume_new_size)
+
         params = {'sizeInGB': six.text_type(volume_new_size)}
         r = requests.post(
             request,