]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
RBD: remove non-layering support for antiquated versions
authorJon Bernard <jobernar@redhat.com>
Mon, 23 Feb 2015 21:04:54 +0000 (16:04 -0500)
committerJon Bernard <jobernar@redhat.com>
Fri, 27 Feb 2015 17:34:25 +0000 (12:34 -0500)
RBD layering was first included in Bobtail (Jan 2013) and all current
Cinder users are expected to have upgraded to a newer version by now.

This patch removes the logic necessary to accommodate Ceph versions that
predate Bobtail.

Change-Id: I335414868c0d0c8c5b15ca0aea9ab32bceeed6ac

cinder/tests/test_rbd.py
cinder/volume/drivers/rbd.py

index 233655e6bac0b5c1ee2568e9e541cf5b2e0d8e68..e3aee6b1c3bbaa41afcc8b7bc8cff39e52d29656 100644 (file)
@@ -160,23 +160,18 @@ class RBDTestCase(test.TestCase):
         client = self.mock_client.return_value
         client.__enter__.return_value = client
 
-        with mock.patch.object(self.driver, '_supports_layering') as \
-                mock_supports_layering:
-            mock_supports_layering.return_value = True
-
-            self.driver.create_volume(self.volume)
-
-            chunk_size = self.cfg.rbd_store_chunk_size * units.Mi
-            order = int(math.log(chunk_size, 2))
-            args = [client.ioctx, str(self.volume_name),
-                    self.volume_size * units.Gi, order]
-            kwargs = {'old_format': False,
-                      'features': self.mock_rbd.RBD_FEATURE_LAYERING}
-            self.mock_rbd.RBD.return_value.create.assert_called_once_with(
-                *args, **kwargs)
-            client.__enter__.assert_called_once_with()
-            client.__exit__.assert_called_once_with(None, None, None)
-            mock_supports_layering.assert_called_once_with()
+        self.driver.create_volume(self.volume)
+
+        chunk_size = self.cfg.rbd_store_chunk_size * units.Mi
+        order = int(math.log(chunk_size, 2))
+        args = [client.ioctx, str(self.volume_name),
+                self.volume_size * units.Gi, order]
+        kwargs = {'old_format': False,
+                  'features': self.mock_rbd.RBD_FEATURE_LAYERING}
+        self.mock_rbd.RBD.return_value.create.assert_called_once_with(
+            *args, **kwargs)
+        client.__enter__.assert_called_once_with()
+        client.__exit__.assert_called_once_with(None, None, None)
 
     @common_mocks
     def test_manage_existing_get_size(self):
@@ -243,29 +238,6 @@ class RBDTestCase(test.TestCase):
         self.assertEqual(RAISED_EXCEPTIONS,
                          [self.mock_rbd.ImageExists])
 
-    @common_mocks
-    def test_create_volume_no_layering(self):
-        client = self.mock_client.return_value
-        client.__enter__.return_value = client
-
-        with mock.patch.object(self.driver, '_supports_layering') as \
-                mock_supports_layering:
-            mock_supports_layering.return_value = False
-
-            self.driver.create_volume(self.volume)
-
-            chunk_size = self.cfg.rbd_store_chunk_size * units.Mi
-            order = int(math.log(chunk_size, 2))
-            args = [client.ioctx, str(self.volume_name),
-                    self.volume_size * units.Gi, order]
-            kwargs = {'old_format': True,
-                      'features': 0}
-            self.mock_rbd.RBD.return_value.create.assert_called_once_with(
-                *args, **kwargs)
-            client.__enter__.assert_called_once_with()
-            client.__exit__.assert_called_once_with(None, None, None)
-            mock_supports_layering.assert_called_once_with()
-
     @common_mocks
     def test_delete_backup_snaps(self):
         self.driver.rbd.Image.remove_snap = mock.Mock()
index 36ac6900230f8a5ea4efd6b521b08d6f32558b46..108165a02cf89d3f466c362d25fe5c979d3dd6fb 100644 (file)
@@ -381,9 +381,6 @@ class RBDDriver(driver.VolumeDriver):
             self._update_volume_stats()
         return self._stats
 
-    def _supports_layering(self):
-        return hasattr(self.rbd, 'RBD_FEATURE_LAYERING')
-
     def _get_clone_depth(self, client, volume_name, depth=0):
         """Returns the number of ancestral clones (if any) of the given volume.
         """
@@ -497,20 +494,16 @@ class RBDDriver(driver.VolumeDriver):
 
         LOG.debug("creating volume '%s'" % (volume['name']))
 
-        old_format = True
-        features = 0
         chunk_size = CONF.rbd_store_chunk_size * units.Mi
         order = int(math.log(chunk_size, 2))
-        if self._supports_layering():
-            old_format = False
-            features = self.rbd.RBD_FEATURE_LAYERING
+        features = self.rbd.RBD_FEATURE_LAYERING
 
         with RADOSClient(self) as client:
             self.rbd.RBD().create(client.ioctx,
                                   encodeutils.safe_encode(volume['name']),
                                   size,
                                   order,
-                                  old_format=old_format,
+                                  old_format=False,
                                   features=features)
 
     def _flatten(self, pool, volume_name):
@@ -689,8 +682,7 @@ class RBDDriver(driver.VolumeDriver):
         with RBDVolumeProxy(self, snapshot['volume_name']) as volume:
             snap = encodeutils.safe_encode(snapshot['name'])
             volume.create_snap(snap)
-            if self._supports_layering():
-                volume.protect_snap(snap)
+            volume.protect_snap(snap)
 
     def delete_snapshot(self, snapshot):
         """Deletes an rbd snapshot."""
@@ -699,11 +691,10 @@ class RBDDriver(driver.VolumeDriver):
         volume_name = encodeutils.safe_encode(snapshot['volume_name'])
         snap_name = encodeutils.safe_encode(snapshot['name'])
         with RBDVolumeProxy(self, volume_name) as volume:
-            if self._supports_layering():
-                try:
-                    volume.unprotect_snap(snap_name)
-                except self.rbd.ImageBusy:
-                    raise exception.SnapshotIsBusy(snapshot_name=snap_name)
+            try:
+                volume.unprotect_snap(snap_name)
+            except self.rbd.ImageBusy:
+                raise exception.SnapshotIsBusy(snapshot_name=snap_name)
             volume.remove_snap(snap_name)
 
     def retype(self, context, volume, new_type, diff, host):
@@ -858,9 +849,8 @@ class RBDDriver(driver.VolumeDriver):
             args = ['rbd', 'import',
                     '--pool', self.configuration.rbd_pool,
                     '--order', order,
-                    tmp.name, volume['name']]
-            if self._supports_layering():
-                args.append('--new-format')
+                    tmp.name, volume['name'],
+                    '--new-format']
             args.extend(self._ceph_args())
             self._try_execute(*args)
         self._resize(volume)