]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Set LVM driver default overprovisioning ratio to 1.0
authorEric Harney <eharney@redhat.com>
Wed, 13 Jan 2016 15:29:50 +0000 (10:29 -0500)
committerEric Harney <eharney@redhat.com>
Tue, 19 Jan 2016 16:15:33 +0000 (16:15 +0000)
This introduces a config option, 'lvm_max_over_subscription_ratio',
which allows overriding the global max_over_subscription_ratio.

This is needed because the way we handle configuration with
multi-backend does not allow setting a value which will be applied
to each LVM backend without manually setting it in each backend,
and it would be better to default to a safe overprovisioning
ratio for the LVM driver.  It is often used in smaller deployments
and POCs which may not have all of the capacity monitoring
infrastructure used with other drivers, so overprovisioning should
be an opt-in capability rather than opt-out.

Partial-Bug: #1472803
DocImpact: new config option lvm_max_over_subscription_ratio

Change-Id: I5a214462b573d00d26086512821b4f8cc1db4fc3

cinder/tests/unit/test_volume.py
cinder/volume/drivers/lvm.py

index 44dea0bd47df466657798b50ec2fec4a70ee3bf8..35058060938cff761cd1ac3ac5a483ca21bf03db 100644 (file)
@@ -6620,6 +6620,7 @@ class GenericVolumeDriverTestCase(DriverTestCase):
         db.volume_destroy(self.context, dest_vol['id'])
 
 
+@ddt.ddt
 class LVMVolumeDriverTestCase(DriverTestCase):
     """Test case for VolumeDriver"""
     driver_name = "cinder.volume.drivers.lvm.LVMVolumeDriver"
@@ -7375,6 +7376,26 @@ class LVMVolumeDriverTestCase(DriverTestCase):
         ret = self.volume.driver.unmanage(volume)
         self.assertEqual(ret, None)
 
+    # Global setting, LVM setting, expected outcome
+    @ddt.data((10.0, 2.0, 2.0))
+    @ddt.data((10.0, None, 10.0))
+    @ddt.unpack
+    def test_lvm_max_over_subscription_ratio(self,
+                                             global_value,
+                                             lvm_value,
+                                             expected_value):
+        configuration = conf.Configuration(fake_opt, 'fake_group')
+        configuration.max_over_subscription_ratio = global_value
+        configuration.lvm_max_over_subscription_ratio = lvm_value
+
+        fake_vg = mock.Mock(fake_lvm.FakeBrickLVM('cinder-volumes', False,
+                                                  None, 'default'))
+        lvm_driver = lvm.LVMVolumeDriver(configuration=configuration,
+                                         vg_obj=fake_vg, db=db)
+
+        self.assertEqual(expected_value,
+                         lvm_driver.configuration.max_over_subscription_ratio)
+
 
 class ISCSITestCase(DriverTestCase):
     """Test Case for ISCSIDriver"""
index 0f7a147cf12a1310799b5d779599f6e2c897f091..34a9172e1a02ac0976b97a23856a87829c90e262 100644 (file)
@@ -60,7 +60,15 @@ volume_opts = [
                help='LVM conf file to use for the LVM driver in Cinder; '
                     'this setting is ignored if the specified file does '
                     'not exist (You can also specify \'None\' to not use '
-                    'a conf file even if one exists).')
+                    'a conf file even if one exists).'),
+    cfg.FloatOpt('lvm_max_over_subscription_ratio',
+                 # This option exists to provide a default value for the
+                 # LVM driver which is different than the global default.
+                 default=1.0,
+                 help='max_over_subscription_ratio setting for the LVM '
+                      'driver.  If set, this takes precedence over the '
+                      'general max_over_subscription_ratio option.  If '
+                      'None, the general option is used.')
 ]
 
 CONF = cfg.CONF
@@ -101,6 +109,10 @@ class LVMVolumeDriver(driver.VolumeDriver):
         self.protocol = self.target_driver.protocol
         self._sparse_copy_volume = False
 
+        if self.configuration.lvm_max_over_subscription_ratio is not None:
+            self.configuration.max_over_subscription_ratio = \
+                self.configuration.lvm_max_over_subscription_ratio
+
     def _sizestr(self, size_in_g):
         return '%sg' % size_in_g