Stage call returns 500 internal server error when image is in saving state

Bug #1733512 reported by Abhishek Kekane
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
High
Abhishek Kekane

Bug Description

If image upload (/file call) is in progress image is in saving state at that time.
If user tries to make a /stage call on same image then it returns 500 internal server error as Image transition from saving to uploading is not allowed.

Ideally it should return 409 HTTConflict error to the user.

Steps to reproduce:
1. Create image
   $ glance image-create --container-format ami --disk-format ami --name cirros_image
2. Upload data to image
   $ glance image-upload <IMAGE_ID> --file <file_name>
3. Ensure image is in saving state and run image-stage command
   $ glance image-stage <IMAGE_ID> --file <file_name>

Output:
500 Internal Server Error: The server has either erred or is incapable of performing the requested operation. (HTTP 500)

Glance API logs:

Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi [None req-f8f2ccf6-88af-4104-aa02-8077bf2670a2 admin admin] Caught error: Image status transition from saving to uploading is not allowed: InvalidImageStatusTransition: Image status transition from saving to uploading is not allowed
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi Traceback (most recent call last):
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1222, in __call__
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi request, **action_args)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1261, in dispatch
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return method(*args, **kwargs)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/utils.py", line 363, in wrapped
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return func(self, req, *args, **kwargs)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/api/v2/image_data.py", line 344, in stage
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi self._restore(image_repo, image)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi self.force_reraise()
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi six.reraise(self.type_, self.value, self.tb)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/api/v2/image_data.py", line 300, in stage
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi image.status = 'uploading'
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/__init__.py", line 151, in status
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi raise e
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi InvalidImageStatusTransition: Image status transition from saving to uploading is not allowed
Nov 21 07:28:46 devstack <email address hidden>[12621]: ERROR glance.common.wsgi

Changed in glance:
assignee: nobody → Abhishek Kekane (abhishek-kekane)
Changed in glance:
status: New → In Progress
Revision history for this message
Abhishek Kekane (abhishek-kekane) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/521457

Changed in glance:
importance: Undecided → High
milestone: none → queens-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/521457
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=7d005079f360c490e915b4f862295de9cb1c8e7e
Submitter: Zuul
Branch: master

commit 7d005079f360c490e915b4f862295de9cb1c8e7e
Author: Abhishek Kekane <email address hidden>
Date: Mon Nov 20 07:38:29 2017 +0000

    Fix 500 from duplicate stage call

    1. When user calls stage command again then it fails with 500 internal
    server error. This is because after stage call image status changes
    to 'uploading' and for second call it again tries to set status to
    'uploading' and fails with 'InvalidImageStatusTransition: Image
    status transition from uploading to uploading is not allowed'
    exception which is not caught at the controller side.

    2. If image upload (/file call) is in progress image is in saving
    state at that time. If user tries to make a /stage call on same image
    then it returns 500 internal server error as Image transition from
    saving to uploading is not allowed.

    Caught 'InvalidImageStatusTransition' and return 409 HTTPConflict
    resonse status.

    Change-Id: Ie66d3e3474b38b2f6c8d31f5c1fb252d45cbd3c9
    Closes-Bug: #1733274
    Closes-Bug: #1733512

Changed in glance:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/glance 16.0.0.0b3

This issue was fixed in the openstack/glance 16.0.0.0b3 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.