diff --git a/cinder/tests/unit/windows/test_smbfs.py b/cinder/tests/unit/windows/test_smbfs.py index eba1e02b86d..4a49e92a285 100644 --- a/cinder/tests/unit/windows/test_smbfs.py +++ b/cinder/tests/unit/windows/test_smbfs.py @@ -236,41 +236,6 @@ class WindowsSmbFsTestCase(test.TestCase): context=mock_ctxt.get_admin_context.return_value, host='fake_host@fake_backend#pool0') - def _test_is_share_eligible(self, capacity_info, volume_size): - self._smbfs_driver._get_capacity_info = mock.Mock( - return_value=[float(x << 30) for x in capacity_info]) - self._smbfs_driver.configuration = self._FAKE_SMBFS_CONFIG - return self._smbfs_driver._is_share_eligible(self._FAKE_SHARE, - volume_size) - - def test_share_volume_above_used_ratio(self): - fake_capacity_info = (4, 1, 1) - fake_volume_size = 2 - ret_value = self._test_is_share_eligible(fake_capacity_info, - fake_volume_size) - self.assertFalse(ret_value) - - def test_eligible_share(self): - fake_capacity_info = (4, 4, 0) - fake_volume_size = 1 - ret_value = self._test_is_share_eligible(fake_capacity_info, - fake_volume_size) - self.assertTrue(ret_value) - - def test_share_volume_above_oversub_ratio(self): - fake_capacity_info = (4, 4, 7) - fake_volume_size = 2 - ret_value = self._test_is_share_eligible(fake_capacity_info, - fake_volume_size) - self.assertFalse(ret_value) - - def test_share_reserved_above_oversub_ratio(self): - fake_capacity_info = (4, 4, 10) - fake_volume_size = 1 - ret_value = self._test_is_share_eligible(fake_capacity_info, - fake_volume_size) - self.assertFalse(ret_value) - @mock.patch.object(smbfs.WindowsSmbfsDriver, '_get_local_volume_path_template') @mock.patch.object(smbfs.WindowsSmbfsDriver, '_lookup_local_volume_path') diff --git a/cinder/volume/drivers/windows/smbfs.py b/cinder/volume/drivers/windows/smbfs.py index e2f8cb4ceb1..a0021539910 100644 --- a/cinder/volume/drivers/windows/smbfs.py +++ b/cinder/volume/drivers/windows/smbfs.py @@ -218,43 +218,6 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, host=host)[1] return float(vol_sz_sum * units.Gi) - def _is_share_eligible(self, smbfs_share, volume_size_in_gib): - """Verifies SMBFS share is eligible to host volume with given size. - - First validation step: ratio of actual space (used_space / total_space) - is less than 'smbfs_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 * smbfs_oversub_ratio) to ensure enough space is - available for the new volume. - - :param smbfs_share: smbfs share - :param volume_size_in_gib: int size in GB - """ - - used_ratio = self.configuration.smbfs_used_ratio - oversub_ratio = self.configuration.smbfs_oversub_ratio - requested_volume_size = volume_size_in_gib * units.Gi - - total_size, total_available, total_allocated = \ - self._get_capacity_info(smbfs_share) - - apparent_size = max(0, total_size * oversub_ratio) - apparent_available = max(0, apparent_size - total_allocated) - used = (total_size - total_available) / total_size - - if used > used_ratio: - LOG.debug('%s is above smbfs_used_ratio.', smbfs_share) - return False - if apparent_available <= requested_volume_size: - LOG.debug('%s is above smbfs_oversub_ratio.', smbfs_share) - return False - if total_allocated / total_size >= oversub_ratio: - LOG.debug('%s reserved space is above smbfs_oversub_ratio.', - smbfs_share) - return False - return True - def local_path(self, volume): """Get volume path (mounted locally fs path) for given volume. @@ -498,13 +461,6 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, 'driver when no snapshots exist.') raise exception.InvalidVolume(msg) - extend_by = int(size_gb) - volume.size - if not self._is_share_eligible(volume.provider_location, - extend_by): - raise exception.ExtendVolumeError(reason='Insufficient space to ' - 'extend volume %s to %sG.' - % (volume.id, size_gb)) - @coordination.synchronized('{self.driver_prefix}-{volume.id}') def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image."""