summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2021-09-08 11:50:17 -0700
committerDan Smith <dansmith@redhat.com>2021-09-08 11:50:17 -0700
commit4ee400accae414b9d4d08a3388c2e23be1b00bd4 (patch)
tree116ac1cac7d367a154c24b091e3f416dc28fdb1c
parent929190a6afd0a1593e62abb8024c339713b52b98 (diff)
downloadglance-4ee400accae414b9d4d08a3388c2e23be1b00bd4.tar.gz
Make signature verification go back to 'queued'
The image state diagram shows that for v2, any image upload failure results in the image going back to 'queued' state. The old v1 path used the 'killed' state, which is no longer value in image list operations for v2. The signature verification error was sending the image back to killed state still, which results in the user losing visibility to the image entirely. This removes the one last way we can get an image into killed state, but there may still be images in the DB that have been orphaned in this way, so some cleanup routine will be necesssary. Change-Id: I9330cc42900dd019e9132c1f4e49eb9eff4f3fc9 Related-Bug: #1924612
-rw-r--r--glance/api/v2/image_data.py18
-rw-r--r--glance/tests/unit/v2/test_image_data_resource.py2
2 files changed, 2 insertions, 18 deletions
diff --git a/glance/api/v2/image_data.py b/glance/api/v2/image_data.py
index e6d07ad7f..1f8c2519b 100644
--- a/glance/api/v2/image_data.py
+++ b/glance/api/v2/image_data.py
@@ -105,22 +105,6 @@ class ImageDataController(object):
self._restore(image_repo, image)
- def _delete(self, image_repo, image):
- """Delete the image.
-
- :param image_repo: The instance of ImageRepo
- :param image: The image that will be deleted
- """
- try:
- if image_repo and image:
- image.status = 'killed'
- image_repo.save(image)
- except Exception as e:
- msg = (_LE("Unable to delete image %(image_id)s: %(e)s") %
- {'image_id': image.image_id,
- 'e': encodeutils.exception_to_unicode(e)})
- LOG.exception(msg)
-
@utils.mutating
def upload(self, req, image_id, data, size):
try:
@@ -301,7 +285,7 @@ class ImageDataController(object):
% {'id': image_id,
'e': encodeutils.exception_to_unicode(e)})
LOG.error(msg)
- self._delete(image_repo, image)
+ self._restore(image_repo, image)
raise webob.exc.HTTPBadRequest(explanation=msg)
except webob.exc.HTTPGone:
diff --git a/glance/tests/unit/v2/test_image_data_resource.py b/glance/tests/unit/v2/test_image_data_resource.py
index eb376670d..1b63a5a5a 100644
--- a/glance/tests/unit/v2/test_image_data_resource.py
+++ b/glance/tests/unit/v2/test_image_data_resource.py
@@ -379,7 +379,7 @@ class TestImagesController(base.StoreClearingUnitTest):
self.image_repo.result = image
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.upload,
request, unit_test_utils.UUID1, 'YYYY', 4)
- self.assertEqual('killed', self.image_repo.saved_image.status)
+ self.assertEqual('queued', self.image_repo.saved_image.status)
def test_image_size_limit_exceeded(self):
request = unit_test_utils.get_fake_request()