diff --git a/nova/conf/glance.py b/nova/conf/glance.py index 8838160411..1be766c9f0 100644 --- a/nova/conf/glance.py +++ b/nova/conf/glance.py @@ -59,29 +59,6 @@ Enable glance operation retries. Specifies the number of retries when uploading / downloading an image to / from glance. 0 means no retries. -"""), - cfg.ListOpt('allowed_direct_url_schemes', - default=[], - deprecated_for_removal=True, - deprecated_since='17.0.0', - deprecated_reason=""" -This was originally added for the 'nova.image.download.file' FileTransfer -extension which was removed in the 16.0.0 Pike release. The -'nova.image.download.modules' extension point is not maintained -and there is no indication of its use in production clouds. -""", - help=""" -List of url schemes that can be directly accessed. - -This option specifies a list of url schemes that can be downloaded -directly via the direct_url. This direct_URL can be fetched from -Image metadata which can be used by nova to get the -image more efficiently. nova-compute could benefit from this by -invoking a copy when it has access to the same file system as glance. - -Possible values: - -* [file], Empty list (default) """), cfg.BoolOpt('verify_glance_signatures', default=False, diff --git a/nova/image/glance.py b/nova/image/glance.py index 7060b7d966..870e1cd9a0 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -345,11 +345,7 @@ class GlanceImageServiceV2(object): """Calls out to Glance for data and writes data.""" # First, check if image could be directly downloaded by special handler - # TODO(stephenfin): Remove check for 'allowed_direct_url_schemes' when - # we clean up tests since it's not used elsewhere - if ((CONF.glance.allowed_direct_url_schemes or - self._download_handlers) and dst_path is not None - ): + if (self._download_handlers and dst_path is not None): image = self.show(context, image_id, include_locations=True) for entry in image.get('locations', []): loc_url = entry['url'] diff --git a/nova/tests/unit/image/test_glance.py b/nova/tests/unit/image/test_glance.py index 5de409bfca..163a6ddc60 100644 --- a/nova/tests/unit/image/test_glance.py +++ b/nova/tests/unit/image/test_glance.py @@ -687,43 +687,6 @@ class TestDownloadNoDirectUri(test.NoDBTestCase): with testtools.ExpectedException(exception.ImageUnacceptable): service.download(ctx, mock.sentinel.image_id) - # TODO(stephenfin): Drop this test since it's not possible to run in - # production - @mock.patch('os.path.getsize', return_value=1) - @mock.patch('builtins.open') - @mock.patch('nova.image.glance.GlanceImageServiceV2._get_transfer_method') - @mock.patch('nova.image.glance.GlanceImageServiceV2.show') - def test_download_direct_file_uri_v2( - self, show_mock, get_tran_mock, open_mock, getsize_mock): - self.flags(allowed_direct_url_schemes=['file'], group='glance') - show_mock.return_value = { - 'locations': [ - { - 'url': 'file:///files/image', - 'metadata': mock.sentinel.loc_meta - } - ] - } - tran_mod = mock.MagicMock() - get_tran_mock.return_value = tran_mod - client = mock.MagicMock() - ctx = mock.sentinel.ctx - writer = mock.MagicMock() - open_mock.return_value = writer - service = glance.GlanceImageServiceV2(client) - res = service.download(ctx, mock.sentinel.image_id, - dst_path=mock.sentinel.dst_path) - - self.assertIsNone(res) - self.assertFalse(client.call.called) - show_mock.assert_called_once_with(ctx, - mock.sentinel.image_id, - include_locations=True) - get_tran_mock.assert_called_once_with('file') - tran_mod.assert_called_once_with(ctx, mock.ANY, - mock.sentinel.dst_path, - mock.sentinel.loc_meta) - @mock.patch('glanceclient.common.utils.IterableWithLength') @mock.patch('os.path.getsize', return_value=1) @mock.patch('builtins.open') @@ -802,11 +765,11 @@ class TestDownloadNoDirectUri(test.NoDBTestCase): # Test that we fall back to downloading to the dst_path # if the download method of the transfer module raised # an exception. - self.flags(allowed_direct_url_schemes=['file'], group='glance') + self.flags(enable_rbd_download=True, group='glance') show_mock.return_value = { 'locations': [ { - 'url': 'file:///files/image', + 'url': 'rbd://cluser/pool/image/snapshot', 'metadata': mock.sentinel.loc_meta } ] @@ -829,7 +792,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase): show_mock.assert_called_once_with(ctx, mock.sentinel.image_id, include_locations=True) - get_tran_mock.assert_called_once_with('file') + get_tran_mock.assert_called_once_with('rbd') tran_method.assert_called_once_with(ctx, mock.ANY, mock.sentinel.dst_path, mock.sentinel.loc_meta) @@ -857,11 +820,11 @@ class TestDownloadNoDirectUri(test.NoDBTestCase): # Test that we fall back to downloading to the dst_path # if no appropriate transfer module is found... # an exception. - self.flags(allowed_direct_url_schemes=['funky'], group='glance') + self.flags(enable_rbd_download=True, group='glance') show_mock.return_value = { 'locations': [ { - 'url': 'file:///files/image', + 'url': 'funky://cluser/pool/image/snapshot', 'metadata': mock.sentinel.loc_meta } ] @@ -882,7 +845,7 @@ class TestDownloadNoDirectUri(test.NoDBTestCase): show_mock.assert_called_once_with(ctx, mock.sentinel.image_id, include_locations=True) - get_tran_mock.assert_called_once_with('file') + get_tran_mock.assert_called_once_with('funky') client.call.assert_called_once_with( ctx, 2, 'data', args=(mock.sentinel.image_id,)) fsync_mock.assert_called_once_with(writer) diff --git a/releasenotes/notes/remove-glance-allowed_direct_url_schemes-93d34d95dd84d2c8.yaml b/releasenotes/notes/remove-glance-allowed_direct_url_schemes-93d34d95dd84d2c8.yaml new file mode 100644 index 0000000000..41f122c595 --- /dev/null +++ b/releasenotes/notes/remove-glance-allowed_direct_url_schemes-93d34d95dd84d2c8.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + The ``[glance]/allowed_direct_url_schemes`` config option, which was first + deprecated in the 17.0.0 (Queens) release has now been removed.