Running image-import call on active image returns 500 internal server error

Bug #1733803 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 you run image-import api on any image which is in active state will return 500 error as it raises InvalidImageStatusTransition because Image status transition from active to importing is not allowed.

Ideally it should return HTTP 409 Conflict error to the user.

Prerequisites:
1. Ensure you have latest version of python-glanceclient (version 2.8.0) installed
2. Due to isssue [1] to execute taskflow you need to modify line [2] as shown below and restart glance-api service
   - pool.spawn_n(import_task.run, task_executor)
   + import_task.run(task_executor)
   [1] https://bugs.launchpad.net/glance/+bug/1712463
   [2] https://github.com/openstack/glance/blob/master/glance/api/v2/images.py#L106

Steps to reporoduce:
1. Create image and upload data to it
    $ glance image-create --container-format ami --disk-format ami --name cirros_image --file cirros-0.3.4-x86_64-blank.img
2. Ensure image is in active state
3. Run image-import call
   $ glance image-import <ID of image created in 1st step> --import-method glance-direct

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

Glance API Logs:

Nov 22 07:21:01 devstack <email address hidden>[14229]: pdict['tenant'] = self.tenant
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi [None req-2abf2e90-c810-44d4-bc21-ab8f0e6cc8de admin admin] Caught error: Image status transition from active to importing is not allowed: InvalidImageStatusTransition: Image status transition from active to importing is not allowed
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi Traceback (most recent call last):
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1222, in __call__
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi request, **action_args)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1261, in dispatch
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return method(*args, **kwargs)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/utils.py", line 363, in wrapped
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return func(self, req, *args, **kwargs)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/api/v2/images.py", line 107, in import_image
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi import_task.run(task_executor)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 238, in run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.base.run(executor)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/notifier.py", line 581, in run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi super(TaskProxy, self).run(executor)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 238, in run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.base.run(executor)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 238, in run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.base.run(executor)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/__init__.py", line 439, in run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi executor.begin_processing(self.task_id)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/taskflow_executor.py", line 143, in begin_processing
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi super(TaskExecutor, self).begin_processing(task_id)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/__init__.py", line 63, in begin_processing
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self._run(task_id, task.type)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/taskflow_executor.py", line 181, in _run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.task_repo.save(task)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.force_reraise()
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi six.reraise(self.type_, self.value, self.tb)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/taskflow_executor.py", line 172, in _run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi engine.run()
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/taskflow/engines/action_engine/engine.py", line 247, in run
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi for _state in self.run_iter(timeout=timeout):
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/taskflow/engines/action_engine/engine.py", line 340, in run_iter
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi failure.Failure.reraise_if_any(er_failures)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/taskflow/types/failure.py", line 336, in reraise_if_any
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi failures[0].reraise()
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/taskflow/types/failure.py", line 343, in reraise
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi six.reraise(*self._exc_info)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/taskflow/engines/action_engine/executor.py", line 53, in _execute_task
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi result = task.execute(**arguments)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/flows/api_image_import.py", line 196, in execute
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi image.status = 'importing'
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/__init__.py", line 151, in status
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi raise e
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi InvalidImageStatusTransition: Image status transition from active to importing is not allowed
Nov 22 07:21:01 devstack <email address hidden>[14229]: ERROR glance.common.wsgi

Changed in glance:
assignee: nobody → Abhishek Kekane (abhishek-kekane)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

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

Changed in glance:
status: New → In Progress
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/523015
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=579a0f95b8492572ae01a8450a159f9082eb4a16
Submitter: Zuul
Branch: master

commit 579a0f95b8492572ae01a8450a159f9082eb4a16
Author: Abhishek Kekane <email address hidden>
Date: Mon Nov 27 04:37:06 2017 +0000

    Fix 500 from image-import on 'active' image

    If you run image-import api on any image which is in active state
    will return 500 error as it raises InvalidImageStatusTransition
    because Image status transition from active to importing is not allowed.

    Caught InvalidImageStatusTransition exception in controller and raised
    HTTConflict exception to return HTTP 409 error to the user.

    Change-Id: I3ed1e40122063fe563ba27b7b7db07f62bef2382
    Closes-Bug: #1733803

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.0b2

This issue was fixed in the openstack/glance 16.0.0.0b2 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.