glance image-download error

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

Bug Description

When use command ' glance image-download --file xxx.raw <image-id>' to download the image, it will fail with error code 500. glance-api log info as below:

 File "/opt/stack/glance/glance/common/wsgi.py", line 794, in __call__
    response = self.process_request(req)
  File "/opt/stack/glance/glance/api/middleware/cache.py", line 180, in process_request
    return method(request, image_id, image_iterator, image_metadata)
  File "/opt/stack/glance/glance/api/middleware/cache.py", line 235, in _process_v2_request
    self._verify_metadata(image_meta)
  File "/opt/stack/glance/glance/api/middleware/cache.py", line 75, in _verify_metadata
    image_meta['size'] = self.cache.get_image_size(image_meta['id'])
TypeError: 'ImageTarget' object does not support item assignment

This should be fixed.

jiaopengju (pj-jiao)
Changed in glance:
assignee: nobody → jiaopengju (pj-jiao)
status: New → In Progress
Revision history for this message
jiaopengju (pj-jiao) wrote :

The way to reproduce this bug.

1. Create a nova instance which boot from volume or snapshot.
2. Do snapshot of the nova instance, this will generate a new image with id xxx.
3. Use command 'glance image-download --file 134.raw xxx' to download the image.
4. Error occurred.

Revision history for this message
Abhishek Kekane (abhishek-kekane) wrote :

Even user doesn't specify --file option then also this issue is reproducible.

1. Create a nova instance which boot from volume or snapshot.
2. Do snapshot of the nova instance, this will generate a new image with id xxx.
3. Use command 'glance image-download xxx'

Revision history for this message
Abhishek Kekane (abhishek-kekane) wrote :

I have simply created 0 size file and uploaded it to glance, then if you try to download that file then also you will face mentioned issue.

Steps:

1. touch temp_file.txt
2. glance image-create --container-format ami --disk-format ami --name empty --file temp_file.txt
3. glance image-download 3879621b-17c1-4beb-9d57-6a93e14cbe0f --file abcd

Revision history for this message
Abhishek Kekane (abhishek-kekane) wrote :
Changed in glance:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/460280
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=94306a686b504abfca3fa36e9cd22b05c385a329
Submitter: Jenkins
Branch: master

commit 94306a686b504abfca3fa36e9cd22b05c385a329
Author: Pengju Jiao <email address hidden>
Date: Thu Apr 27 03:02:25 2017 +0800

    Fix glance image-download error

    When use command 'glance image-download --file xxx.raw <image-id>'
    to download the image, it will fail with error code 500. It shows
    "TypeError:'ImageTarget' object does not support item assignment"
    in glance-api's log.

    It is because that when instance snapshot of volume-backed instance
    is uploaded to glance, image size is set to 0 from nova. While
    downloading that snapshot with using image-download call it tries
    to get the image size from the cache where it fails as image is
    instance of policy.ImageTarget. Made change to set image size
    on image_meta.target if image is a policy.ImageTarget.

    Change-Id: I1a08baa465d3927b721678a5a7ab5f54304993d6
    Co-Authored-By: Abhishek Kekane <email address hidden>
    Co-Authored-By: Eric Fried <email address hidden>
    Closes-Bug: #1686488

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

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