Remove inappropriate directory space check

Removes an inappropriate directory space check when copying an image to
a volume. In the general case, "dest" is a block device, so it's not
appropriate to check for space in the directory containing "dest". One
exception may be the NFS driver, where dest actually is a file, but that
should be handled elsewhere (if necessary). This check has always been
inappropriate, but was silently ineffective due to a unit-comparison bug
that was recently fixed.

Change-Id: Ie5eba32f92eb1740554bfc44baf612e326d6fde5
Closes-Bug: 1756425
This commit is contained in:
iain MacDonnell 2018-03-22 00:18:29 +00:00 committed by imacdonn
parent 9e283258fe
commit 076687f35e
2 changed files with 0 additions and 49 deletions

View File

@ -489,10 +489,6 @@ def fetch_to_volume_format(context, image_service,
reason=_("fmt=%(fmt)s backed by:%(backing_file)s")
% {'fmt': fmt, 'backing_file': backing_file, })
# NOTE(e0ne): check for free space in destination directory before
# image conversion.
check_available_space(dest, data.virtual_size, image_id)
# NOTE(jdg): I'm using qemu-img convert to write
# to the volume regardless if it *needs* conversion or not
# TODO(avishay): We can speed this up by checking if the image is raw

View File

@ -1156,51 +1156,6 @@ class TestFetchToVolumeFormat(test.TestCase):
self.assertFalse(mock_copy.called)
self.assertFalse(mock_convert.called)
@mock.patch('psutil.disk_usage')
@mock.patch('cinder.image.image_utils.check_available_space')
@mock.patch('cinder.image.image_utils.convert_image')
@mock.patch('cinder.image.image_utils.volume_utils.copy_volume')
@mock.patch(
'cinder.image.image_utils.replace_xenserver_image_with_coalesced_vhd')
@mock.patch('cinder.image.image_utils.is_xenserver_format',
return_value=False)
@mock.patch('cinder.image.image_utils.fetch')
@mock.patch('cinder.image.image_utils.qemu_img_info')
@mock.patch('cinder.image.image_utils.temporary_file')
@mock.patch('cinder.image.image_utils.CONF')
def test_check_no_available_space_error(self, mock_conf, mock_temp,
mock_info, mock_fetch, mock_is_xen,
mock_repl_xen, mock_copy,
mock_convert, mock_check_space,
mock_disk_usage):
ctxt = mock.sentinel.context
image_service = mock.Mock(temp_images=None)
image_id = mock.sentinel.image_id
dest = mock.sentinel.dest
volume_format = mock.sentinel.volume_format
blocksize = mock.sentinel.blocksize
ctxt.user_id = user_id = mock.sentinel.user_id
project_id = mock.sentinel.project_id
size = 1234
run_as_root = mock.sentinel.run_as_root
mock_disk_usage.return_value = units.Gi - 1
data = mock_info.return_value
data.file_format = volume_format
data.backing_file = None
data.virtual_size = units.Gi
mock_check_space.side_effect = exception.ImageTooBig(
image_id='fake_image_id', reason='test')
self.assertRaises(
exception.ImageTooBig,
image_utils.fetch_to_volume_format,
ctxt, image_service, image_id, dest, volume_format, blocksize,
user_id=user_id, project_id=project_id, size=size,
run_as_root=run_as_root)
@mock.patch('cinder.image.image_utils.convert_image')
@mock.patch('cinder.image.image_utils.volume_utils.copy_volume')
@mock.patch(