Glance v2: HTTP500 when updating image with locations

Bug #1257507 reported by Alex Meade
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
High
Feilong Wang

Bug Description

curl -i -X PATCH -H "X-Auth-Token: $AUTH_TOKEN" -H 'Content-Type: application/openstack-images-v2.1-json-patch' -H 'User-Agent: python-glanceclient' -d '[{"path": "/locations", "value": [{"url":"swift+http://service:glance:password@localhost:5000/v2.0/glance/d0d90e9b-82f2-43c4-9e12-232de00fa8ea", "metadata": {}}], "op": "replace"}]' http://localhost:9292/v2/images/7b724ba6-6451-4280-85e4-1c46b3e6e5b5

HTTP/1.1 500 Internal Server Error

2013-12-03 22:14:39.298 12510 INFO glance.wsgi.server [85024f66-9dd2-4289-98a2-f4b9f6426aae 1c3848b015f94b70866ea33fa52945f0 54bc4959075343ff80f460b77e783a49] Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 389, 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 581, 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 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 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/lib/python2.7/dist-packages/paste/urlmap.py", line 203, in __call__
    return app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
    return resp(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 599, in __call__
    request, **action_args)
  File "/opt/stack/glance/glance/common/wsgi.py", line 618, in dispatch
    return method(*args, **kwargs)
  File "/opt/stack/glance/glance/common/utils.py", line 422, in wrapped
    return func(self, req, *args, **kwargs)
  File "/opt/stack/glance/glance/api/v2/images.py", line 119, in update
    change_method(req, image, change)
  File "/opt/stack/glance/glance/api/v2/images.py", line 149, in _do_replace
    self._do_replace_locations(image, value)
  File "/opt/stack/glance/glance/api/v2/images.py", line 228, in _do_replace_locations
    image.locations = value
  File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
    return setattr(getattr(self, target), attr, value)
  File "/opt/stack/glance/glance/domain/proxy.py", line 23, in set_attr
    return setattr(getattr(self, target), attr, value)
  File "/opt/stack/glance/glance/api/policy.py", line 227, in locations
    self.image.locations = new_locations
  File "/opt/stack/glance/glance/quota/__init__.py", line 195, in locations
    self.context, self.image.size * len(value), self.db_api,
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

2013-12-03 22:14:39.301 12510 INFO glance.wsgi.server [85024f66-9dd2-4289-98a2-f4b9f6426aae 1c3848b015f94b70866ea33fa52945f0 54bc4959075343ff80f460b77e783a49] localhost - - [03/Dec/2013 22:14:39] "PATCH /v2/images/7b724ba6-6451-4280-85e4-1c46b3e6e5b5 HTTP/1.1" 500 139 0.421279

Feilong Wang (flwang)
Changed in glance:
status: New → Confirmed
assignee: nobody → Fei Long Wang (flwang)
Revision history for this message
Feilong Wang (flwang) wrote :

@ameade, good catch. And I can reprodce it in my local environment. My test steps is as below. Please let me know if you did as the same way.

1. Create an image without specifying the data or location
2. Update locations against the image just create with PATCH

After investigated the code, I think the root cause is there is no image size when check the quota. So we will run into the TypeError exception.

Revision history for this message
Feilong Wang (flwang) wrote :
Feilong Wang (flwang)
Changed in glance:
status: Confirmed → In Progress
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/60777

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

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

commit ad755f98437bb129aad9de663260d6cc04340e42
Author: Fei Long Wang <email address hidden>
Date: Mon Dec 9 16:40:48 2013 +0800

    Fixes HTTP 500 when updating image with locations for V2

    Based on current implement, user will run into 500 error during
    updating locations for a queued image. The root cause is we're
    trying to calculate the overall size with current image size and
    the number of locations. This fix will get the correct image size
    from backend store if current image size is not available.

    Fixes bug 1257507

    Change-Id: Ia4ac73e36211d475752ee9f4995fc3768fb2981a

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
milestone: none → icehouse-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: icehouse-2 → 2014.1
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.