Create image API should not expose any trace when the image location is wrong

Bug #1185055 reported by Feilong Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Low
Feilong Wang

Bug Description

Issue: Glance image create API returns traces instead of HTTP error

X-Auth-Token: ****

x-image-meta-name: test-image-sce-88
x-image-meta-disk-format: qcow2
x-image-meta-container-format: bare
x-glance-api-copy-from: http://192.168.56.101:8080/myapp222/cirros.img (note: the image location is fake)

Post body: {}

The response entity got from openstack is as following,

the error message is 'Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 383, 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 451, 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 589, in __call__ request, **action_args) File "/opt/stack/glance/glance/common/wsgi.py", line 606, in dispatch return method(*args, **kwargs) File "/opt/stack/glance/glance/common/utils.py", line 418, in wrapped return func(self, req, *args, **kwargs) File "/opt/stack/glance/glance/api/v1/images.py", line 697, in create location_uri = image_meta.get('location') AttributeError: 'NoneType' object has no attribute 'get' '. The service responded with the following status: 500 - Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/eventlet/wsgi.py", line 383, 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 451, 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 589, in __call__ request, **action_args) File "/opt/stack/glance/glance/common/wsgi.py", line 606, in dispatch return method(*args, **kwargs) File "/opt/stack/glance/glance/common/utils.py", line 418, in wrapped return func(self, req, *args, **kwargs) File "/opt/stack/glance/glance/api/v1/images.py", line 697, in create location_uri = image_meta.get('location') AttributeError: 'NoneType' object has no attribute 'get'

Expected result:
Glance should return a firiendly API response for API users.

Feilong Wang (flwang)
Changed in glance:
assignee: nobody → Fei Long Wang (flwang)
status: New → 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/30987

Revision history for this message
Iccha Sethi (iccha-sethi) wrote :

Based on conversations in irc with Fei, we decided that the root cause of the issue was the user providing data and a bad copy from location at the same time. We must be capturing that and throwing the appropriate exception to the user.

And if there are other cases where this can occur, a generic catch to catch the trace makes sense.

Changed in glance:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/30987
Committed: http://github.com/openstack/glance/commit/1e1bcfd505c2096537bb8c24f3cc98656a92032d
Submitter: Jenkins
Branch: master

commit 1e1bcfd505c2096537bb8c24f3cc98656a92032d
Author: Fei Long Wang <email address hidden>
Date: Thu May 30 11:26:28 2013 +0800

    Fixes exposing trace during calling image create API

    Now Glance will return trace instead of standard HTTP error
    during create image with bad location and nonempty body.
    The root cause is nonempty request body will make add image
    as synchronous action instead of queuing it. And then, the
    image upload will fail due to the bad location. As a result,
    user will run into the exception trace instead of friendly
    HTTP error.

    Based on current design, it's invalid to provide multiple
    image sources in one request. So this fix is adding an
    explicit check to make sure there is only one image source.

    Fixes bug: 1185055

    Change-Id: I204aa14fa35e50aeb29b6dc22bbf5bbc66a2fb42

Changed in glance:
status: In Progress → Fix Committed
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.