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 protected]> 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 -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to Glance. https://bugs.launchpad.net/bugs/1733512 Title: Stage call returns 500 internal server error when image is in saving state Status in Glance: Fix Released 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 protected][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 protected][12621]: ERROR glance.common.wsgi Traceback (most recent call last): Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1222, in __call__ Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi request, **action_args) Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1261, in dispatch Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi return method(*args, **kwargs) Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/utils.py", line 363, in wrapped Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi return func(self, req, *args, **kwargs) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi self._restore(image_repo, image) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi self.force_reraise() Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi six.reraise(self.type_, self.value, self.tb) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi image.status = 'uploading' Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value) Nov 21 07:28:46 devstack [email protected][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 protected][12621]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value) Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/__init__.py", line 151, in status Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi raise e Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi InvalidImageStatusTransition: Image status transition from saving to uploading is not allowed Nov 21 07:28:46 devstack [email protected][12621]: ERROR glance.common.wsgi To manage notifications about this bug go to: https://bugs.launchpad.net/glance/+bug/1733512/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

