Pass image_id to ImageDownloadFailed
When an ImageDownloadFailed exception is created in the GlanceImageService, it's being passed the context whereas what makes sense for the error message is the image_id. This patch makes the change and adds a unit test for a previous fix for Bug #1798147 (which was the real point of this patch). Change-Id: I6d8dedfd056add3414f8f4bf7f7279eae4763286 Closes-bug: #1811184
This commit is contained in:
parent
c068ce071b
commit
16b4346171
|
@ -359,7 +359,7 @@ class GlanceImageService(object):
|
|||
|
||||
if image_chunks is None:
|
||||
raise exception.ImageDownloadFailed(
|
||||
image_href=context, reason=_('image contains no data.'))
|
||||
image_href=image_id, reason=_('image contains no data.'))
|
||||
|
||||
if not data:
|
||||
return image_chunks
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import datetime
|
||||
import itertools
|
||||
import six
|
||||
|
||||
import ddt
|
||||
import glanceclient.exc
|
||||
|
@ -663,6 +664,20 @@ class TestGlanceImageService(test.TestCase):
|
|||
self.flags(glance_num_retries=1)
|
||||
service.download(self.context, image_id, writer)
|
||||
|
||||
def test_download_no_data(self):
|
||||
class MyGlanceStubClient(glance_stubs.StubGlanceClient):
|
||||
"""Returns None instead of an iterator."""
|
||||
def data(self, image_id):
|
||||
return None
|
||||
|
||||
client = MyGlanceStubClient()
|
||||
service = self._create_image_service(client)
|
||||
image_id = 'fake-image-uuid'
|
||||
e = self.assertRaises(exception.ImageDownloadFailed, service.download,
|
||||
self.context, image_id)
|
||||
self.assertIn('image contains no data', six.text_type(e))
|
||||
self.assertIn(image_id, six.text_type(e))
|
||||
|
||||
def test_client_forbidden_converts_to_imagenotauthed(self):
|
||||
class MyGlanceStubClient(glance_stubs.StubGlanceClient):
|
||||
"""A client that raises a Forbidden exception."""
|
||||
|
|
Loading…
Reference in New Issue