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

Bug #794582 reported by Christoph Thiel on 2011-06-08
This bug affects 2 people
Affects Status Importance Assigned to Milestone
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/

def show(self, req, id):
        res = Response(app_iter=image_iterator(),
        # 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!

Christoph Thiel (cthiel-suse) wrote : 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.

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) on 2011-06-30
Changed in glance:
milestone: diablo-2 → diablo-3
Jay Pipes (jaypipes) on 2011-07-26
Changed in glance:
milestone: diablo-3 → diablo-4
Jay Pipes (jaypipes) on 2011-08-24
Changed in glance:
assignee: Jay Pipes (jaypipes) → nobody
Jay Pipes (jaypipes) on 2011-08-25
Changed in glance:
milestone: diablo-4 → diablo-rbp
Thierry Carrez (ttx) on 2011-09-12
Changed in glance:
milestone: diablo-rbp → 2011.3
Jay Pipes (jaypipes) on 2011-09-15
Changed in glance:
assignee: nobody → Brian Waldon (bcwaldon)
Brian Waldon (bcwaldon) on 2011-09-15
Changed in glance:
status: Confirmed → In Progress

Submitter: Jenkins
Branch: master

 status fixcommitted

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

Submitter: Jenkins
Branch: milestone-proposed

 status fixcommitted

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) on 2011-09-22
Changed in glance:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers