From f9901ca92770a879a28c17f28814f6c93204f2fc Mon Sep 17 00:00:00 2001 From: Lee Yarwood Date: Thu, 28 Jan 2021 12:37:59 +0000 Subject: [PATCH] glance: Remove [glance]/allowed_direct_url_schemes This option was deprecated during Queens and can be removed now. A single test is fully removed as it is no longer possible to hit the usecase while an additional two tests are modified to test the recently introduced rbd direct download usecase. Change-Id: I5e8bbc078266d81d64c2073a828b6ff394e4f0e1 --- nova/conf/glance.py | 23 --------- nova/image/glance.py | 6 +-- nova/tests/unit/image/test_glance.py | 49 +++---------------- ...d_direct_url_schemes-93d34d95dd84d2c8.yaml | 5 ++ 4 files changed, 12 insertions(+), 71 deletions(-) create mode 100644 releasenotes/notes/remove-glance-allowed_direct_url_schemes-93d34d95dd84d2c8.yaml diff --git a/nova/conf/glance.py b/nova/conf/glance.py index 88381604117e..1be766c9f0c2 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 7060b7d96614..870e1cd9a002 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 5de409bfcaad..163a6ddc60b3 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 000000000000..41f122c5954e --- /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.