Adding remote image in v2 when cache is enabled results 500 error

Bug #1533270 reported by Mike Fedosin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
In Progress
Medium
Darja Shakhray
Liberty
New
Undecided
Unassigned

Bug Description

To reproduce the issue:

1) Add an image without specifying the size
2) Enable caching
3) Get image data. This will succeed because the Content-Length is pulled from the remote store (i.e. swift). At this point, the image will be properly cached.
4) Get image data again with v2 api. This will fail with 500 error http://paste.openstack.org/show/483545/

It happens for the reason cache middleware couldn't assign value to image_meta['size'] because it expects a dictionary (as it was in v1 api), but in v2 api it's ImageTarget object.

Changed in glance:
assignee: nobody → Darja Shakhray (dshakhray)
Revision history for this message
Mike Fedosin (mfedosin) wrote :
Revision history for this message
Stuart McLaren (stuart-mclaren) wrote :

Co-incidently, this is what I was hitting when testing https://review.openstack.org/#/c/254873

  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/mnt/opt/stack/glance/glance/common/wsgi.py", line 588, in __call__
    response = req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1317, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1281, 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 "/mnt/opt/stack/glance/glance/common/wsgi.py", line 585, in __call__
    response = self.process_request(req)
  File "/mnt/opt/stack/glance/glance/api/middleware/cache.py", line 171, in process_request
    return method(request, image_id, image_iterator, image_metadata)
  File "/mnt/opt/stack/glance/glance/api/middleware/cache.py", line 226, in _process_v2_request
    self._verify_metadata(image_meta)
  File "/mnt/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

Revision history for this message
Stuart McLaren (stuart-mclaren) wrote :

So download of a standard zero size image can hit this also.

Mike Fedosin (mfedosin)
Changed in glance:
status: New → Confirmed
importance: Undecided → Medium
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/266891

Changed in glance:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on glance (master)

Change abandoned by Darja Shakhray (<email address hidden>) on branch: master
Review: https://review.openstack.org/266891
Reason: This commit is not necessary

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Ian Cordasco (<email address hidden>) on branch: master
Review: https://review.openstack.org/269277
Reason: As discussed on the other patch, this is unnecessary

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.