Merge "Fix 500 from stage call on non-existing image"

This commit is contained in:
Zuul 2017-12-01 23:48:09 +00:00 committed by Gerrit Code Review
commit deff5cd876
2 changed files with 9 additions and 0 deletions

View File

@ -304,6 +304,9 @@ class ImageDataController(object):
msg = _("The image %s has data on staging") % image_id
raise webob.exc.HTTPConflict(explanation=msg)
except exception.NotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.msg)
except glance_store.StorageFull as e:
msg = _("Image storage media "
"is full: %s") % encodeutils.exception_to_unicode(e)

View File

@ -473,6 +473,12 @@ class TestImagesController(base.StoreClearingUnitTest):
request, image_id, 'YYYYYYY', 7)
self.assertEqual('queued', self.image_repo.saved_image.status)
def test_image_stage_non_existent_image(self):
request = unit_test_utils.get_fake_request()
self.image_repo.result = exception.NotFound()
self.assertRaises(webob.exc.HTTPNotFound, self.controller.stage,
request, str(uuid.uuid4()), 'ABC', 3)
class TestImageDataDeserializer(test_utils.BaseTestCase):