]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove deprecated options from NFS driver
authorTom Barron <tpb@dyncloud.net>
Tue, 19 Jan 2016 13:56:51 +0000 (08:56 -0500)
committerTom Barron <tpb@dyncloud.net>
Tue, 26 Jan 2016 00:10:55 +0000 (19:10 -0500)
In the Liberty release, the NFS driver deprecated the 'nfs_used_ratio'
and 'nfs_oversubscription_ratio' configuration options since equivalent
common functionality is now provided across drivers by the scheduler-aware
'reserved_percentage' and 'max_over_sucscription_ratio' configuration
options.

This commit removes these deprecated options, tests for same, and
some Liberty code that proviced backwards compatibility with respect to
these options.

DocImpact

Change-Id: Ia3af9cbe69b2342649fe378aefe6ed1e46a82b19

cinder/tests/unit/test_coho.py
cinder/tests/unit/test_hitachi_hnas_nfs.py
cinder/tests/unit/test_netapp_nfs.py
cinder/tests/unit/test_nexenta.py
cinder/tests/unit/test_nfs.py
cinder/tests/unit/test_tintri.py
cinder/tests/unit/test_zfssa.py
cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_base.py
cinder/volume/drivers/netapp/dataontap/nfs_base.py
cinder/volume/drivers/nfs.py
cinder/volume/drivers/zfssa/zfssanfs.py

index a0c724dd32469fcd1b2b1152576a74f6197cc94d..6b78171af2102cc744c37ec24357910cabe27a2c 100644 (file)
@@ -100,8 +100,6 @@ class CohoDriverTest(test.TestCase):
         self.configuration.nas_ip = None
         self.configuration.nas_share_path = None
         self.configuration.nas_mount_options = None
-        self.configuration.nfs_used_ratio = .95
-        self.configuration.nfs_oversub_ratio = 1.0
 
     def test_setup_failure_when_rpc_port_unconfigured(self):
         self.configuration.coho_rpc_port = None
index 12b403e9ecfd8c2f594f34c0918a6407c6a6124d..03165cc72cedd6702c1eedad0a82f8b33e5320ab 100644 (file)
@@ -256,8 +256,6 @@ class HDSNFSDriverTest(test.TestCase):
         self.configuration.nas_ip = None
         self.configuration.nas_share_path = None
         self.configuration.nas_mount_options = None
-        self.configuration.nfs_used_ratio = .95
-        self.configuration.nfs_oversub_ratio = 1.0
 
         self.driver = nfs.HDSNFSDriver(configuration=self.configuration)
         self.driver.do_setup("")
index 4a66240708d5a3f47b45dc9009902b6d459d3666..19e0136072c3b4bddcd24766333d78f6e362d54f 100644 (file)
@@ -89,8 +89,6 @@ def create_configuration():
     configuration.nfs_mount_point_base = '/mnt/test'
     configuration.nfs_mount_options = None
     configuration.nas_mount_options = None
-    configuration.nfs_used_ratio = .95
-    configuration.nfs_oversub_ratio = 1.0
     configuration.netapp_server_hostname = CONNECTION_INFO['hostname']
     configuration.netapp_transport_type = CONNECTION_INFO['transport_type']
     configuration.netapp_server_port = CONNECTION_INFO['port']
index 9709b093934fe9c4c640c0f9a3caccf5ea92e0e1..572126b5d828dc08a460e5ab51d5096b7ead3f63 100644 (file)
@@ -348,8 +348,6 @@ class TestNexentaNfsDriver(test.TestCase):
         self.cfg.nexenta_nms_cache_volroot = False
         self.cfg.nfs_mount_attempts = 3
         self.cfg.reserved_percentage = 20
-        self.cfg.nfs_used_ratio = .95
-        self.cfg.nfs_oversub_ratio = 1.0
         self.cfg.max_over_subscription_ratio = 20.0
         self.nms_mock = mock.Mock()
         for mod in ('appliance', 'folder', 'server', 'volume', 'netstorsvc',
index ca3724bb5003b71e0efc55354e2d1f97dd217d45..4985a052520a3a8b9d610920d6e83e56e10193db 100644 (file)
@@ -330,8 +330,6 @@ class NfsDriverTestCase(test.TestCase):
         self.configuration.reserved_percentage = 5
         self.configuration.nfs_shares_config = None
         self.configuration.nfs_sparsed_volumes = True
-        self.configuration.nfs_used_ratio = 0.95
-        self.configuration.nfs_oversub_ratio = 1.0
         self.configuration.nfs_reserved_percentage = 5.0
         self.configuration.nfs_mount_point_base = self.TEST_MNT_POINT_BASE
         self.configuration.nfs_mount_options = None
@@ -751,8 +749,8 @@ class NfsDriverTestCase(test.TestCase):
     @ddt.data(True, False)
     def test_update_volume_stats(self, thin):
 
-        self._driver.over_subscription_ratio = 20.0
-        self._driver.reserved_percentage = 5.0
+        self._driver.configuration.max_over_subscription_ratio = 20.0
+        self._driver.configuration.reserved_percentage = 5.0
         self._driver.configuration.nfs_sparsed_volumes = thin
 
         remotefs_volume_stats = {
@@ -787,44 +785,6 @@ class NfsDriverTestCase(test.TestCase):
         self.assertEqual(expected, self._driver._stats)
         self.assertEqual(thin, mock_get_provisioned_capacity.called)
 
-    @ddt.data({'nfs_oversub_ratio': 1.0},
-              {'nfs_oversub_ratio': 1.5})
-    @ddt.unpack
-    def test_get_over_subscription_ratio(self, nfs_oversub_ratio):
-        self.configuration.nfs_oversub_ratio = nfs_oversub_ratio
-        self._driver.configuration = self.configuration
-        self.mock_object(nfs, 'LOG')
-
-        oversub_ratio = self._driver._get_over_subscription_ratio()
-
-        if nfs_oversub_ratio == 1.0:
-            self.assertEqual(1.0, oversub_ratio)
-            self.assertFalse(nfs.LOG.warn.called)
-        else:
-            self.assertEqual(nfs_oversub_ratio, oversub_ratio)
-            self.assertTrue(nfs.LOG.warn.called)
-
-    @ddt.data({'nfs_used_ratio': 0.95, 'nfs_reserved_percentage': 0.05},
-              {'nfs_used_ratio': 0.80, 'nfs_reserved_percentage': 0.20})
-    @ddt.unpack
-    def test_get_reserved_percentage(self, nfs_used_ratio,
-                                     nfs_reserved_percentage):
-        self.configuration.nfs_used_ratio = nfs_used_ratio
-        self.configuration.nfs_reserved_percentage = nfs_reserved_percentage
-        self._driver.configuration = self.configuration
-        self.mock_object(nfs, 'LOG')
-
-        reserved_percentage = self._driver._get_reserved_percentage()
-
-        if nfs_used_ratio == 0.95:
-            self.assertEqual(self._driver.configuration.reserved_percentage,
-                             reserved_percentage)
-            self.assertFalse(nfs.LOG.warn.called)
-        else:
-            expected = (1 - self._driver.configuration.nfs_used_ratio) * 100
-            self.assertEqual(expected, reserved_percentage)
-            self.assertTrue(nfs.LOG.warn.called)
-
     def _check_is_share_eligible(self, total_size, total_available,
                                  total_allocated, requested_volume_size):
         with mock.patch.object(self._driver, '_get_capacity_info')\
@@ -846,7 +806,7 @@ class NfsDriverTestCase(test.TestCase):
                                                       total_allocated,
                                                       requested_volume_size))
 
-    def test_is_share_eligible_above_used_ratio(self):
+    def test_share_eligibility_with_reserved_percentage(self):
         total_size = 100.0 * units.Gi
         total_available = 4.0 * units.Gi
         total_allocated = 96.0 * units.Gi
@@ -1074,33 +1034,6 @@ class NfsDriverDoSetupTestCase(test.TestCase):
         config.append_config_values(nfs.nfs_opts)
         self.configuration = config
 
-    def test_init_should_throw_error_if_oversub_ratio_less_than_zero(self):
-        """__init__ should throw error if nfs_oversub_ratio is less than 0."""
-
-        self.override_config('nfs_oversub_ratio', -1)
-
-        with self.assertRaisesRegex(exception.InvalidConfigurationValue,
-                                    ".*'nfs_oversub_ratio' invalid.*"):
-            nfs.NfsDriver(configuration=self.configuration)
-
-    def test_init_should_throw_error_if_used_ratio_less_than_zero(self):
-        """__init__ should throw error if nfs_used_ratio is less than 0."""
-
-        self.override_config('nfs_used_ratio', -1)
-
-        with self.assertRaisesRegex(exception.InvalidConfigurationValue,
-                                    ".*'nfs_used_ratio' invalid.*"):
-            nfs.NfsDriver(configuration=self.configuration)
-
-    def test_init_should_throw_error_if_used_ratio_greater_than_one(self):
-        """__init__ should throw error if nfs_used_ratio is greater than 1."""
-
-        self.override_config('nfs_used_ratio', 2)
-
-        with self.assertRaisesRegex(exception.InvalidConfigurationValue,
-                                    ".*'nfs_used_ratio' invalid.*"):
-            nfs.NfsDriver(configuration=self.configuration)
-
     def test_setup_should_throw_error_if_shares_config_not_configured(self):
         """do_setup should throw error if shares config is not configured."""
 
index c4abe165db19fb52710f1f4e18f4d660e82f49cb..69e8340aa1a18d992002e384ecab7506ca33c2d0 100644 (file)
@@ -56,8 +56,6 @@ class TintriDriverTestCase(test.TestCase):
         configuration.nfs_mount_point_base = '/mnt/test'
         configuration.nfs_mount_options = None
         configuration.nas_mount_options = None
-        configuration.nfs_used_ratio = 0.95
-        configuration.nfs_oversub_ratio = 1.0
         return configuration
 
     def fake_stubs(self):
index 83709c493dc76515bbf33697a5d50e412c8e1a7a..a581bd111231fe48cf7efa6e7aa1c2fe5e67130a 100644 (file)
@@ -766,8 +766,6 @@ class TestZFSSANFSDriver(test.TestCase):
         self.configuration.zfssa_nfs_share_compression = nfs_compression
         self.configuration.zfssa_nfs_mount_options = ''
         self.configuration.zfssa_rest_timeout = '30'
-        self.configuration.nfs_oversub_ratio = 1
-        self.configuration.nfs_used_ratio = 1
         self.configuration.zfssa_enable_local_cache = True
         self.configuration.zfssa_cache_directory = zfssa_cache_dir
 
index 07c0d7ee12bc903bbe9e5074b3f5e79c515a1d7f..cfcc79826c92f7fb21ce99892a71b9d699ba4a79 100644 (file)
@@ -41,8 +41,8 @@ class NetAppNfsDriverTestCase(test.TestCase):
         configuration = mock.Mock()
         configuration.reserved_percentage = 0
         configuration.nfs_mount_point_base = '/mnt/test'
-        configuration.nfs_used_ratio = 1.0
-        configuration.nfs_oversub_ratio = 1.1
+        configuration.reserved_percentage = 0
+        configuration.max_over_subscription_ratio = 1.1
 
         kwargs = {'configuration': configuration}
 
@@ -70,7 +70,7 @@ class NetAppNfsDriverTestCase(test.TestCase):
         expected_free_capacity_gb = (na_utils.round_down(
             fake.AVAILABLE_BYTES / units.Gi, '0.01'))
         expected_reserved_percentage = round(
-            100 * (1 - self.driver.configuration.nfs_used_ratio))
+            self.driver.configuration.reserved_percentage)
 
         result = self.driver._get_share_capacity_info(fake.NFS_SHARE)
 
@@ -375,7 +375,7 @@ class NetAppNfsDriverTestCase(test.TestCase):
                                return_value=(
                                    total_bytes, available_bytes)):
             with mock.patch.object(self.driver,
-                                   'over_subscription_ratio',
+                                   'max_over_subscription_ratio',
                                    over):
                 with mock.patch.object(self.driver,
                                        'reserved_percentage',
@@ -404,7 +404,7 @@ class NetAppNfsDriverTestCase(test.TestCase):
         mock_get_capacity.return_value = (total_bytes, available_bytes)
 
         with mock.patch.object(self.driver,
-                               'over_subscription_ratio',
+                               'max_over_subscription_ratio',
                                over):
             with mock.patch.object(self.driver,
                                    'reserved_percentage',
index 4f758dbfcaa65a51456f0c69f9a8c9c34ce4aca5..7a24ee3bfad75eeab6a65702ccde45dc2aca6aac 100644 (file)
@@ -709,7 +709,7 @@ class NetAppNfsDriver(driver.ManageableVD,
         reserved = int(round(total_size * reserved_ratio))
         available = max(0, total_available - reserved)
         if thin:
-            available = available * self.over_subscription_ratio
+            available = available * self.max_over_subscription_ratio
 
         return available >= requested_size
 
@@ -761,7 +761,8 @@ class NetAppNfsDriver(driver.ManageableVD,
 
         capacity = dict()
         capacity['reserved_percentage'] = self.reserved_percentage
-        capacity['max_over_subscription_ratio'] = self.over_subscription_ratio
+        capacity['max_over_subscription_ratio'] = (
+            self.max_over_subscription_ratio)
         total_size, total_available = self._get_capacity_info(nfs_share)
         capacity['total_capacity_gb'] = na_utils.round_down(
             total_size / units.Gi, '0.01')
index e80e907ed052e3c4997dc2bebd0db6e35e98718e..de4c3c00b672602687c5d2ebc785b6cd54707bc9 100644 (file)
@@ -21,7 +21,6 @@ from os_brick.remotefs import remotefs as remotefs_brick
 from oslo_concurrency import processutils as putils
 from oslo_config import cfg
 from oslo_log import log as logging
-from oslo_log import versionutils
 from oslo_utils import units
 import six
 
@@ -32,12 +31,10 @@ from cinder import utils
 from cinder.volume import driver
 from cinder.volume.drivers import remotefs
 
-VERSION = '1.3.0'
+VERSION = '1.3.1'
 
 LOG = logging.getLogger(__name__)
 
-NFS_USED_RATIO_DEFAULT = 0.95
-NFS_OVERSUB_RATIO_DEFAULT = 1.0
 
 nfs_opts = [
     cfg.StrOpt('nfs_shares_config',
@@ -48,23 +45,6 @@ nfs_opts = [
                 help=('Create volumes as sparsed files which take no space.'
                       'If set to False volume is created as regular file.'
                       'In such case volume creation takes a lot of time.')),
-    # TODO(tbarron): remove nfs_used_ratio in the Mitaka release.
-    cfg.FloatOpt('nfs_used_ratio',
-                 default=NFS_USED_RATIO_DEFAULT,
-                 help=('Percent of ACTUAL usage of the underlying volume '
-                       'before no new volumes can be allocated to the volume '
-                       'destination. Note that this option is deprecated '
-                       'in favor of "reserved_percentage" and will be removed '
-                       'in the Mitaka release.')),
-    # TODO(tbarron): remove nfs_oversub_ratio in the Mitaka release.
-    cfg.FloatOpt('nfs_oversub_ratio',
-                 default=NFS_OVERSUB_RATIO_DEFAULT,
-                 help=('This will compare the allocated to available space on '
-                       'the volume destination.  If the ratio exceeds this '
-                       'number, the destination will no longer be valid. '
-                       'Note that this option is deprecated in favor of '
-                       '"max_over_subscription_ratio" and will be removed '
-                       'in the Mitaka release.')),
     cfg.StrOpt('nfs_mount_point_base',
                default='$state_path/mnt',
                help=('Base dir containing mount points for NFS shares.')),
@@ -121,8 +101,9 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
             nfs_mount_options=opts)
 
         self._sparse_copy_volume_data = True
-        self.reserved_percentage = self._get_reserved_percentage()
-        self.over_subscription_ratio = self._get_over_subscription_ratio()
+        self.reserved_percentage = self.configuration.reserved_percentage
+        self.max_over_subscription_ratio = (
+            self.configuration.max_over_subscription_ratio)
 
     def do_setup(self, context):
         """Any initialization the volume driver does while starting."""
@@ -227,10 +208,10 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
         """Verifies NFS share is eligible to host volume with given size.
 
         First validation step: ratio of actual space (used_space / total_space)
-        is less than 'nfs_used_ratio'. Second validation step: apparent space
+        is less than used_ratio. Second validation step: apparent space
         allocated (differs from actual space used when using sparse files)
         and compares the apparent available
-        space (total_available * nfs_oversub_ratio) to ensure enough space is
+        space (total_available * oversub_ratio) to ensure enough space is
         available for the new volume.
 
         :param nfs_share: NFS share
@@ -245,8 +226,7 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
         # this requires either pool support for the generic NFS
         # driver or limiting each NFS backend driver to a single share.
 
-        # 'nfs_used_ratio' is deprecated, so derive used_ratio from
-        # reserved_percentage.
+        # derive used_ratio from reserved percentage
         if share_info is None:
             total_size, total_available, total_allocated = (
                 self._get_capacity_info(nfs_share))
@@ -257,10 +237,11 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
         used_percentage = 100 - self.reserved_percentage
         used_ratio = used_percentage / 100.0
 
-        oversub_ratio = self.over_subscription_ratio
         requested_volume_size = volume_size_in_gib * units.Gi
 
-        apparent_size = max(0, share_info['total_size'] * oversub_ratio)
+        apparent_size = max(0, share_info['total_size'] *
+                            self.max_over_subscription_ratio)
+
         apparent_available = max(0, apparent_size -
                                  share_info['total_allocated'])
 
@@ -273,14 +254,18 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
             # available space but be within our oversubscription limit
             # therefore allowing this share to still be selected as a valid
             # target.
-            LOG.debug('%s is above nfs_used_ratio', nfs_share)
+            LOG.debug('%s is not eligible - used ratio exceeded.',
+                      nfs_share)
             return False
         if apparent_available <= requested_volume_size:
-            LOG.debug('%s is above nfs_oversub_ratio', nfs_share)
+            LOG.debug('%s is not eligible - insufficient (apparent) available '
+                      'space.',
+                      nfs_share)
             return False
         if share_info['total_allocated'] / share_info['total_size'] >= (
-                oversub_ratio):
-            LOG.debug('%s reserved space is above nfs_oversub_ratio',
+                self.max_over_subscription_ratio):
+            LOG.debug('%s is not eligible - utilization exceeds max '
+                      'over subscription ratio.',
                       nfs_share)
             return False
         return True
@@ -449,52 +434,9 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
             provisioned_capacity = round(global_capacity - global_free, 2)
 
         data['provisioned_capacity_gb'] = provisioned_capacity
-        data['max_over_subscription_ratio'] = self.over_subscription_ratio
+        data['max_over_subscription_ratio'] = self.max_over_subscription_ratio
         data['reserved_percentage'] = self.reserved_percentage
         data['thin_provisioning_support'] = thin_enabled
         data['thick_provisioning_support'] = not thin_enabled
 
         self._stats = data
-
-    def _get_over_subscription_ratio(self):
-        legacy_oversub_ratio = self.configuration.nfs_oversub_ratio
-        if legacy_oversub_ratio == NFS_OVERSUB_RATIO_DEFAULT:
-            return self.configuration.max_over_subscription_ratio
-
-        # Honor legacy option if its value is not the default.
-        msg = _LW("The option 'nfs_oversub_ratio' is deprecated and will "
-                  "be removed in the Mitaka release.  Please set "
-                  "'max_over_subscription_ratio = %s' instead.") % (
-                      self.configuration.nfs_oversub_ratio)
-        versionutils.report_deprecated_feature(LOG, msg)
-
-        if not self.configuration.nfs_oversub_ratio > 0:
-            msg = _("NFS config 'nfs_oversub_ratio' invalid.  Must be > 0: "
-                    "%s.") % self.configuration.nfs_oversub_ratio
-            LOG.error(msg)
-            raise exception.InvalidConfigurationValue(msg)
-
-        return legacy_oversub_ratio
-
-    def _get_reserved_percentage(self):
-        legacy_used_ratio = self.configuration.nfs_used_ratio
-        legacy_reserved_ratio = 1 - legacy_used_ratio
-        legacy_percentage = legacy_reserved_ratio * 100
-        if legacy_used_ratio == NFS_USED_RATIO_DEFAULT:
-            return self.configuration.reserved_percentage
-
-        # Honor legacy option if its value is not the default.
-        msg = _LW("The option 'nfs_used_ratio' is deprecated and will "
-                  "be removed in the Mitaka release.  Please set "
-                  "'reserved_percentage = %d' instead.") % (
-                      legacy_percentage)
-        versionutils.report_deprecated_feature(LOG, msg)
-
-        if not ((self.configuration.nfs_used_ratio > 0) and
-                (self.configuration.nfs_used_ratio <= 1)):
-            msg = _("NFS config 'nfs_used_ratio' invalid.  Must be > 0 "
-                    "and <= 1.0: %s.") % self.configuration.nfs_used_ratio
-            LOG.error(msg)
-            raise exception.InvalidConfigurationValue(msg)
-
-        return legacy_percentage
index 3cb3cd4815d5bacf84b8ef87a0f77255ffb0776e..fdbb05b2692482dba2bfff6dac9cf447ab1465f8 100644 (file)
@@ -92,16 +92,9 @@ class ZFSSANFSDriver(nfs.NfsDriver):
         self._stats = None
 
     def do_setup(self, context):
-        if not self.configuration.nfs_oversub_ratio > 0:
-            msg = _("NFS config 'nfs_oversub_ratio' invalid. Must be > 0: "
-                    "%s") % self.configuration.nfs_oversub_ratio
-            LOG.error(msg)
-            raise exception.NfsException(msg)
-
-        if ((not self.configuration.nfs_used_ratio > 0) and
-                (self.configuration.nfs_used_ratio <= 1)):
-            msg = _("NFS config 'nfs_used_ratio' invalid. Must be > 0 "
-                    "and <= 1.0: %s") % self.configuration.nfs_used_ratio
+        if not self.configuration.max_over_subscription_ratio > 0:
+            msg = _("Config 'max_over_subscription_ratio' invalid. Must be > "
+                    "0: %s") % self.configuration.max_over_subscription_ratio
             LOG.error(msg)
             raise exception.NfsException(msg)
 
@@ -551,8 +544,10 @@ class ZFSSANFSDriver(nfs.NfsDriver):
         data['QoS_support'] = False
         data['reserved_percentage'] = 0
 
-        if ratio_used > self.configuration.nfs_used_ratio or \
-           ratio_used >= self.configuration.nfs_oversub_ratio:
+        used_percentage_limit = 100 - self.configuration.reserved_percentage
+        used_ratio_limit = used_percentage_limit / 100.0
+        if (ratio_used > used_ratio_limit or
+                ratio_used >= self.configuration.max_over_subscription_ratio):
             data['reserved_percentage'] = 100
 
         data['total_capacity_gb'] = float(capacity) / units.Gi