Running image-import call on queued image without container and disk format returns 500 internal server error

Bug #1733810 reported by Abhishek Kekane on 2017-11-22
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
High
Abhishek Kekane

Bug Description

If you run image-import api on any image which is in queued state and doesn't have container-format and disk-format set will return 500 error as it raises ValueError: Properties disk_format, container_format must be set prior to saving data. Ideally it should return HTTP 400 BadRequest 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 an image without container format and disk-format
    $ glance image-create --name cirros_image
2. Ensure image is in queued 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 09:04:17 devstack <email address hidden>[14229]: pdict['tenant'] = self.tenant
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi [None req-4d0baee8-445e-4ed0-82b8-966e71636ddf admin admin] Caught error: Properties disk_format, container_format must be set prior to saving data.: ValueError: Properties disk_format, container_format must be set prior to saving data.
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi Traceback (most recent call last):
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1222, in __call__
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi request, **action_args)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/wsgi.py", line 1261, in dispatch
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return method(*args, **kwargs)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/common/utils.py", line 363, in wrapped
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return func(self, req, *args, **kwargs)
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi import_task.run(task_executor)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 238, in run
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.base.run(executor)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/notifier.py", line 581, in run
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi super(TaskProxy, self).run(executor)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 238, in run
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.base.run(executor)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 238, in run
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.base.run(executor)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/__init__.py", line 439, in run
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi executor.begin_processing(self.task_id)
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi super(TaskExecutor, self).begin_processing(task_id)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/__init__.py", line 63, in begin_processing
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self._run(task_id, task.type)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/taskflow_executor.py", line 181, in _run
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.task_repo.save(task)
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi self.force_reraise()
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi six.reraise(self.type_, self.value, self.tb)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/async/taskflow_executor.py", line 172, in _run
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi engine.run()
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi for _state in self.run_iter(timeout=timeout):
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi failure.Failure.reraise_if_any(er_failures)
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi failures[0].reraise()
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi six.reraise(*self._exc_info)
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi result = task.execute(**arguments)
Nov 22 09:04:17 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 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi image.status = 'importing'
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi return setattr(getattr(self, target), attr, value)
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi File "/opt/stack/glance/glance/domain/__init__.py", line 165, in status
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi raise ValueError(msg % ', '.join(missing))
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi ValueError: Properties disk_format, container_format must be set prior to saving data.
Nov 22 09:04:17 devstack <email address hidden>[14229]: ERROR glance.common.wsgi

summary: - Running image-import call on queued image returns 500 internal server
- error
+ Running image-import call on queued image without container and disk
+ format returns 500 internal server error
Changed in glance:
assignee: nobody → Abhishek Kekane (abhishek-kekane)

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

Changed in glance:
status: New → In Progress
Changed in glance:
importance: Undecided → High
milestone: none → queens-2

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

commit d8bcf8ba13a05f9dcd395ac2064c9099c759147a
Author: Abhishek Kekane <email address hidden>
Date: Fri Nov 24 05:18:44 2017 +0000

    Fix 500 on ValueError during image-import

    ValueError is being raised during image-import,
    and it's not being caught, leading to a 500. So this
    change catches the ValueError and raises a HTTPBadRequest.

    Change-Id: Ide4ca9492b9296c74f8302d2d12e385bb5ad663b
    Closes-Bug: #1733810

Changed in glance:
status: In Progress → Fix Released

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  Edit
Everyone can see this information.

Other bug subscribers