glance sets image size to 0 for http images -> yields connection reset error on GET

Bug #794582 reported by Christoph Thiel
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Brian Waldon

Bug Description

Adding an image via

glance --verbose add name="openSUSE 11.4 JeOS" disk_format=raw container_format=bare is_public=true location="http://localhost/openSUSE_11.4_JeOS.i686-0.0.1.raw"

will yield output like this:
Added new image with ID: 9
Returned the following metadata for the new image:
                       checksum => None
               container_format => bare
                     created_at => 2011-06-08T13:47:29
                        deleted => False
                     deleted_at => None
                    disk_format => raw
                             id => 9
                      is_public => True
                       location => http://localhost/openSUSE_11.4_JeOS.i686-0.0.1.raw
                           name => openSUSE 11.4 JeOS
                     properties => {}
                           size => 0
                         status => active
                     updated_at => 2011-06-08T13:47:29
Completed in 0.1457 sec.

Not the size of 0! With size set to 0, you won't be able to retrieve the image using http://localhost:9292/images/9 -- you'll figure out that the connection gets reset before any data (except the header) will be submitted.

This is due to glance/server.py

def show(self, req, id):
  ,,,
        res = Response(app_iter=image_iterator(),
                       content_type="application/octet-stream")
        # Using app_iter blanks content-length, so we set it here...
        res.headers.add('Content-Length', image['size'])

which will set Content-Length to 0. Uncommenting this line, will get this to work!

Revision history for this message
Christoph Thiel (cthiel-suse) wrote :

http://glance.openstack.org/glanceapi.html#adding-image-metadata-in-http-headers states:

----

* x-image-meta-size

  This header is optional.

  When present, Glance assumes that the expected size of the request body will be the value of this header. If the length in bytes of the request body does not match the value of this header, Glance will return a 400 Bad Request.

  When not present, Glance will calculate the image’s size based on the size of the request body.

----

Glance would at least need to set the size based on a HEAD-request to the location that is being added.

Revision history for this message
Jay Pipes (jaypipes) wrote :

Thanks for the bug report, Christoph! I'll add a test case and a fix for this shortly. Cheers :) -jay

Changed in glance:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Jay Pipes (jaypipes)
milestone: none → diablo-2
Thierry Carrez (ttx)
Changed in glance:
milestone: diablo-2 → diablo-3
Jay Pipes (jaypipes)
Changed in glance:
milestone: diablo-3 → diablo-4
Jay Pipes (jaypipes)
Changed in glance:
assignee: Jay Pipes (jaypipes) → nobody
Jay Pipes (jaypipes)
Changed in glance:
milestone: diablo-4 → diablo-rbp
Thierry Carrez (ttx)
Changed in glance:
milestone: diablo-rbp → 2011.3
Jay Pipes (jaypipes)
Changed in glance:
assignee: nobody → Brian Waldon (bcwaldon)
Brian Waldon (bcwaldon)
Changed in glance:
status: Confirmed → In Progress
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : A change has been merged to openstack/glance

Reviewed: https://review.openstack.org/455
Committed: http://github.com/openstack/glance/commit/ef196858801d64cef7b0ef0789e01526718bc3ce
Submitter: Jenkins
Branch: master

 status fixcommitted
 done

commit ef196858801d64cef7b0ef0789e01526718bc3ce
Author: Brian Waldon <email address hidden>
Date: Thu Sep 15 17:30:08 2011 -0400

    Fixing bug 794582 - Now able to stream http(s) images

    Change-Id: Ic04dfe32acc21ff068ef0964541c47eee41fbe3b

Changed in glance:
status: In Progress → Fix Committed
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote :

Reviewed: https://review.openstack.org/508
Committed: http://github.com/openstack/glance/commit/a0eafeec7aeb8de329bc96ac8a3fd50abf0d2c5f
Submitter: Jenkins
Branch: milestone-proposed

 status fixcommitted
 done

commit a0eafeec7aeb8de329bc96ac8a3fd50abf0d2c5f
Author: Brian Waldon <email address hidden>
Date: Thu Sep 15 17:30:08 2011 -0400

    Fixing bug 794582 - Now able to stream http(s) images

    Change-Id: Ic04dfe32acc21ff068ef0964541c47eee41fbe3b

Thierry Carrez (ttx)
Changed in glance:
status: Fix Committed → Fix Released
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.