SMBFS: remove redundant check
Previously, we had to check the available storage of a specific share when creating/extending volumes. Now that the scheduler is aware of the share capacities (exposed via pools) and that extend requests are routed through the scheduler, we can drop those checks. Change-Id: I6eb64516c361c3938a953c83f8e4c3d6eae643ab
This commit is contained in:
parent
f1372d3063
commit
c2a42e014c
@ -236,41 +236,6 @@ class WindowsSmbFsTestCase(test.TestCase):
|
|||||||
context=mock_ctxt.get_admin_context.return_value,
|
context=mock_ctxt.get_admin_context.return_value,
|
||||||
host='fake_host@fake_backend#pool0')
|
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,
|
@mock.patch.object(smbfs.WindowsSmbfsDriver,
|
||||||
'_get_local_volume_path_template')
|
'_get_local_volume_path_template')
|
||||||
@mock.patch.object(smbfs.WindowsSmbfsDriver, '_lookup_local_volume_path')
|
@mock.patch.object(smbfs.WindowsSmbfsDriver, '_lookup_local_volume_path')
|
||||||
|
@ -218,43 +218,6 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin,
|
|||||||
host=host)[1]
|
host=host)[1]
|
||||||
return float(vol_sz_sum * units.Gi)
|
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):
|
def local_path(self, volume):
|
||||||
"""Get volume path (mounted locally fs path) for given 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.')
|
'driver when no snapshots exist.')
|
||||||
raise exception.InvalidVolume(msg)
|
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}')
|
@coordination.synchronized('{self.driver_prefix}-{volume.id}')
|
||||||
def copy_volume_to_image(self, context, volume, image_service, image_meta):
|
def copy_volume_to_image(self, context, volume, image_service, image_meta):
|
||||||
"""Copy the volume to the specified image."""
|
"""Copy the volume to the specified image."""
|
||||||
|
Loading…
Reference in New Issue
Block a user