Doing a GET on v2/images/{id}/file fails

Bug #1183049 reported by Eddie Sheffield
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
High
Paul Bourke

Bug Description

(Using Devstack, Glance code as of 2013-05-20)

When attempting to download image data using the V2 api, an error occurs:

Sample CURL:

curl -i -X GET -H 'Content-Type: application/octet-stream' -H "X-Auth-Token: $OS_AUTH_TOKEN" http://162.209.48.224:9292/v2/images/eddedf52-790d-470c-82d6-963479a3d6f9/file --verbose

Result:

* About to connect() to 162.209.48.224 port 9292 (#0)
* Trying 162.209.48.224...
* connected
* Connected to 162.209.48.224 (162.209.48.224) port 9292 (#0)
> GET /v2/images/eddedf52-790d-470c-82d6-963479a3d6f9/file HTTP/1.1
> Host: 162.209.48.224:9292
> Accept: */*
> User-Agent: python-glanceclient
> Content-Type: application/octet-stream
> X-Auth-Token: ...
>
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 500 Internal Server Error
HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain
Content-Type: text/plain
< Content-Length: 2511
Content-Length: 2511
< Date: Wed, 22 May 2013 18:36:09 GMT
Date: Wed, 22 May 2013 18:36:09 GMT
< Connection: close
Connection: close

<
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 382, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 367, in __call__
    response = req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1296, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1260, in call_application
    app_iter = application(self.environ, start_response)
  File "/opt/stack/python-keystoneclient/keystoneclient/middleware/auth_token.py", line 456, in __call__
    return self.app(env, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 367, in __call__
    response = req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1296, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1260, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/glance/glance/common/wsgi.py", line 364, in __call__
    response = self.process_request(req)
  File "/opt/stack/glance/glance/api/middleware/cache.py", line 118, in process_request
    return method(request, image_id, image_iterator)
  File "/opt/stack/glance/glance/api/middleware/cache.py", line 172, in _process_v2_request
    self._verify_metadata(image_meta)
  File "/opt/stack/glance/glance/api/middleware/cache.py", line 72, in _verify_metadata
    image_meta['size'] = self.cache.get_image_size(image_id)
NameError: global name 'image_id' is not defined
* Closing connection #0

Looking at the _verify_metadata method, the image_id is indeed not defined. This should likely be passed as a parameter.

https://github.com/openstack/glance/blob/master/glance/api/middleware/cache.py#L60

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/30268

Changed in glance:
assignee: nobody → Paul Bourke (pauldbourke)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/30268
Committed: http://github.com/openstack/glance/commit/6bd7a9d57e0ce45911888becaf944b0c324efdf3
Submitter: Jenkins
Branch: master

commit 6bd7a9d57e0ce45911888becaf944b0c324efdf3
Author: Paul Bourke <email address hidden>
Date: Thu May 23 13:12:29 2013 +0000

    Fix undefined variable in cache

    A function to verify metadata in the cache middleware was falling over
    for GETs on images with a missing size.

    Fixes bug 1183049

    Change-Id: I2da75e5e5aca12d20a10cace2a3779e4041161b2

Changed in glance:
status: In Progress → Fix Committed
Changed in glance:
importance: Undecided → Critical
importance: Critical → High
Thierry Carrez (ttx)
Changed in glance:
milestone: none → havana-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: havana-2 → 2013.2
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.