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
This commit is contained in:
Lee Yarwood 2021-01-28 12:37:59 +00:00
parent b34a1ca645
commit f9901ca927
4 changed files with 12 additions and 71 deletions

View File

@ -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,

View File

@ -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']

View File

@ -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)

View File

@ -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.