]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Pass RBD order to clone call
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 8 Mar 2016 15:43:15 +0000 (16:43 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 9 Mar 2016 16:37:59 +0000 (17:37 +0100)
For cloning of a RBD the rbd_store_chunk_size information from
the cinder.conf should be used to calculate and pass the correct
order information to the clone() call of the rbd library.

Added new test to check for correctly from rbd_store_chunk_size
calculated order while cloning.

Closes-Bug: #1489134

Change-Id: Ic5714d3e0d6961bce6ff588006661618130dca07
Co-Authored-By: Logan V <logan2211@gmail.com>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
cinder/tests/unit/test_rbd.py
cinder/volume/drivers/rbd.py

index c1f4a49041f8db7e7cd3df61f4246eccb333b195..d8a2984b005baf31f6b4c8819507cdf403c867ca 100644 (file)
@@ -861,9 +861,46 @@ class RBDTestCase(test.TestCase):
 
         self.driver._clone(self.volume_a, src_pool, src_image, src_snap)
 
+        chunk_size = self.cfg.rbd_store_chunk_size * units.Mi
+        order = int(math.log(chunk_size, 2))
+
+        args = [client_stack[0].ioctx, str(src_image), str(src_snap),
+                client_stack[1].ioctx, str(self.volume_a.name)]
+        kwargs = {'features': client.features,
+                  'order': order}
+        self.mock_rbd.RBD.return_value.clone.assert_called_once_with(
+            *args, **kwargs)
+        self.assertEqual(2, client.__enter__.call_count)
+
+    @ddt.data({'rbd_chunk_size': 1, 'order': 20},
+              {'rbd_chunk_size': 8, 'order': 23},
+              {'rbd_chunk_size': 32, 'order': 25})
+    @ddt.unpack
+    @common_mocks
+    def test_clone_different_rbd_store_chunk_size(self, rbd_chunk_size, order):
+        self.cfg.rbd_store_chunk_size = rbd_chunk_size
+        src_pool = u'images'
+        src_image = u'image-name'
+        src_snap = u'snapshot-name'
+
+        client_stack = []
+
+        def mock__enter__(inst):
+            def _inner():
+                client_stack.append(inst)
+                return inst
+            return _inner
+
+        client = self.mock_client.return_value
+        # capture both rados client used to perform the clone
+        client.__enter__.side_effect = mock__enter__(client)
+
+        self.driver._clone(self.volume_a, src_pool, src_image, src_snap)
+
         args = [client_stack[0].ioctx, str(src_image), str(src_snap),
                 client_stack[1].ioctx, str(self.volume_a.name)]
-        kwargs = {'features': client.features}
+        kwargs = {'features': client.features,
+                  'order': order}
         self.mock_rbd.RBD.return_value.clone.assert_called_once_with(
             *args, **kwargs)
         self.assertEqual(2, client.__enter__.call_count)
index 91a02133e58d42c067a118348c79f6687ee2cd9f..67c8f2816a4258585617a2e176062088ec33cbb3 100644 (file)
@@ -556,6 +556,10 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD,
         LOG.debug('cloning %(pool)s/%(img)s@%(snap)s to %(dst)s',
                   dict(pool=src_pool, img=src_image, snap=src_snap,
                        dst=volume.name))
+
+        chunk_size = self.configuration.rbd_store_chunk_size * units.Mi
+        order = int(math.log(chunk_size, 2))
+
         with RADOSClient(self, src_pool) as src_client:
             with RADOSClient(self) as dest_client:
                 self.RBDProxy().clone(src_client.ioctx,
@@ -563,7 +567,8 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD,
                                       utils.convert_str(src_snap),
                                       dest_client.ioctx,
                                       utils.convert_str(volume.name),
-                                      features=src_client.features)
+                                      features=src_client.features,
+                                      order=order)
 
     def _resize(self, volume, **kwargs):
         size = kwargs.get('size', None)