Merge "Fix 500 from image-import on queued images"
This commit is contained in:
commit
ee874a4dea
|
@ -107,6 +107,8 @@ class ImagesController(object):
|
|||
except exception.Forbidden as e:
|
||||
LOG.debug("User not permitted to create image import task.")
|
||||
raise webob.exc.HTTPForbidden(explanation=e.msg)
|
||||
except exception.Conflict as e:
|
||||
raise webob.exc.HTTPConflict(explanation=e.msg)
|
||||
|
||||
return image_id
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ class _ImportToStore(task.Task):
|
|||
# implementation
|
||||
image = self.image_repo.get(self.image_id)
|
||||
image.status = 'importing'
|
||||
self.image_repo.save(image)
|
||||
self.image_repo.save(image, from_state='uploading')
|
||||
|
||||
# NOTE(flaper87): Let's dance... and fall
|
||||
#
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import datetime
|
||||
import eventlet
|
||||
import uuid
|
||||
|
||||
import glance_store as store
|
||||
|
@ -599,6 +600,18 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, request, UUID4)
|
||||
|
||||
def test_image_import_raises_conflict(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
# NOTE(abhishekk): Due to
|
||||
# https://bugs.launchpad.net/glance/+bug/1712463 taskflow is not
|
||||
# executing. Once it is fixed instead of mocking spawn_n method
|
||||
# we should mock execute method of _ImportToStore task.
|
||||
with mock.patch.object(eventlet.GreenPool, 'spawn_n',
|
||||
side_effect=exception.Conflict):
|
||||
self.assertRaises(webob.exc.HTTPConflict,
|
||||
self.controller.import_image, request, UUID4,
|
||||
{})
|
||||
|
||||
def test_create(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
image = {'name': 'image-1'}
|
||||
|
|
Loading…
Reference in New Issue