From 076687f35e324ead5fdca7650a1e720b9ce0c81b Mon Sep 17 00:00:00 2001 From: iain MacDonnell Date: Thu, 22 Mar 2018 00:18:29 +0000 Subject: [PATCH] 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 --- cinder/image/image_utils.py | 4 --- cinder/tests/unit/test_image_utils.py | 45 --------------------------- 2 files changed, 49 deletions(-) diff --git a/cinder/image/image_utils.py b/cinder/image/image_utils.py index 1a9c3a20e66..a7d7b08a0aa 100644 --- a/cinder/image/image_utils.py +++ b/cinder/image/image_utils.py @@ -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 diff --git a/cinder/tests/unit/test_image_utils.py b/cinder/tests/unit/test_image_utils.py index 642f6c801a5..75ebb89b5d9 100644 --- a/cinder/tests/unit/test_image_utils.py +++ b/cinder/tests/unit/test_image_utils.py @@ -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(