uncaught exception in upload-to-image with invalid container format

Bug #1308689 reported by Jon Bernard
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Jon Bernard
Icehouse
Fix Released
Medium
Chuck Short

Bug Description

When an invalid container format is specified in an upload-to-image command, cinder-api logs an exception because the error returned from glance is first seen by the wsgi fault wrapper.

Ideally, the exception would be caught and turned into a helpful user message that indicates what went wrong.

Command:

$ cinder upload-to-image --container-format utterly-invalid-format-name 468ee750-a154-4610-8b18-f330593033f7 from-cinder
ERROR: The server could not comply with the request since it is either malformed or otherwise incorrect. (HTTP 400) (Request-ID: req-f19bad2f-c39d-40a2-a3cc-6db9b9fe64cd)

Logs (cinder-api):

2014-04-16 17:52:15.520 DEBUG glanceclient.common.http [req-f19bad2f-c39d-40a2-a3cc-6db9b9fe64cd 0c584884e8994df8bdf7449442f25972 d5ab5c34a8534b26ae7b7a7882c51b01] Request returned failure status: 400 from (pid=2306) _http_request /opt/st>
2014-04-16 17:52:15.520 ERROR cinder.api.middleware.fault [req-f19bad2f-c39d-40a2-a3cc-6db9b9fe64cd 0c584884e8994df8bdf7449442f25972 d5ab5c34a8534b26ae7b7a7882c51b01] Caught error: 400 Bad Request
Invalid container format 'utterly-invalid-format-name' for image.
    (HTTP 400)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault Traceback (most recent call last):
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/api/middleware/fault.py", line 75, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return req.get_response(self.application)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/request.py", line 1296, in send
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault application, catch_exc_info=False)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/request.py", line 1260, in call_application
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault app_iter = application(self.environ, start_response)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/python-keystoneclient/keystoneclient/middleware/auth_token.py", line 615, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return self.app(env, start_response)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/routes/middleware.py", line 131, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault response = self.app(environ, start_response)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return resp(environ, start_response)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 130, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault resp = self.call_func(req, *args, **self.kwargs)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/usr/lib/python2.7/site-packages/webob/dec.py", line 195, in call_func
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return self.func(req, *args, **kwargs)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/api/openstack/wsgi.py", line 895, in __call__
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault content_type, body, accept)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/api/openstack/wsgi.py", line 943, in _process_stack
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault action_result = self.dispatch(meth, request, action_args)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/api/openstack/wsgi.py", line 1019, in dispatch
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return method(req=request, **action_args)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/api/contrib/volume_actions.py", line 258, in _volume_upload_image
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault force)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/volume/api.py", line 75, in wrapped
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return func(self, context, target_obj, *args, **kwargs)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/volume/api.py", line 714, in copy_volume_to_image
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault recv_metadata = self.image_service.create(context, metadata)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/image/glance.py", line 286, in create
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault **sent_service_image_meta)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/cinder/cinder/image/glance.py", line 158, in call
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return getattr(client.images, method)(*args, **kwargs)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/python-glanceclient/glanceclient/v1/images.py", line 255, in create
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault 'POST', '/v1/images', headers=hdrs, body=image_data)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/python-glanceclient/glanceclient/common/http.py", line 313, in raw_request
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault return self._http_request(url, method, **kwargs)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault File "/opt/stack/python-glanceclient/glanceclient/common/http.py", line 249, in _http_request
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault raise exc.from_response(resp, body_str)
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault HTTPBadRequest: 400 Bad Request
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault Invalid container format 'utterly-invalid-fomat-name' for image.
2014-04-16 17:52:15.520 TRACE cinder.api.middleware.fault (HTTP 400)

Jon Bernard (jbernard)
Changed in cinder:
assignee: nobody → Jon Bernard (jbernard)
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/88063

Changed in cinder:
status: New → In Progress
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/88063
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=6673a1d6b33ca72062d35450f97de43bf550b705
Submitter: Jenkins
Branch: master

commit 6673a1d6b33ca72062d35450f97de43bf550b705
Author: Jon Bernard <email address hidden>
Date: Fri Apr 11 10:44:55 2014 -0400

    Re-raise exceptions in upload-to-image

    This patch catches any exceptions returned from Glance during an
    upload-to-image operation and re-raises them so that the user can see
    the failure message and make the appropriate adjustments. More
    specifically, this addresses an invalid container format.

    For example, the following command:

        $ cinder upload-to-image --container-format foobar ...

    Goes from:

        ERROR: The server could not comply with the request since it is
               either malformed or otherwise incorrect. (HTTP 400)
               (Request-ID: req-f19bad2f-c39d-40a2-a3cc-6db9b9fe64cd)

    To:

        ERROR: 400 Bad Request
        Invalid container format 'foobar' for image.
            (HTTP 400) (HTTP 400)
            (Request-ID: req-47cb2772-78c4-48b7-87ce-fb124ecfa989)

    Closes-Bug: #1308689
    Change-Id: If18851e0b9f5c242f84b1eab928b42d809335d80

Changed in cinder:
status: In Progress → Fix Committed
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to cinder (stable/icehouse)

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/89563

Mike Perez (thingee)
tags: added: icehouse-backport-potential
Changed in cinder:
milestone: none → juno-1
Alan Pevec (apevec)
Changed in cinder:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (stable/icehouse)

Reviewed: https://review.openstack.org/89563
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=1815c725f8d9f7770d0757e724f1f0111c64dc2f
Submitter: Jenkins
Branch: stable/icehouse

commit 1815c725f8d9f7770d0757e724f1f0111c64dc2f
Author: Jon Bernard <email address hidden>
Date: Fri Apr 11 10:44:55 2014 -0400

    Re-raise exceptions in upload-to-image

    This patch catches any exceptions returned from Glance during an
    upload-to-image operation and re-raises them so that the user can see
    the failure message and make the appropriate adjustments. More
    specifically, this addresses an invalid container format.

    For example, the following command:

        $ cinder upload-to-image --container-format foobar ...

    Goes from:

        ERROR: The server could not comply with the request since it is
               either malformed or otherwise incorrect. (HTTP 400)
               (Request-ID: req-f19bad2f-c39d-40a2-a3cc-6db9b9fe64cd)

    To:

        ERROR: 400 Bad Request
        Invalid container format 'foobar' for image.
            (HTTP 400) (HTTP 400)
            (Request-ID: req-47cb2772-78c4-48b7-87ce-fb124ecfa989)

    Closes-Bug: #1308689
    Change-Id: If18851e0b9f5c242f84b1eab928b42d809335d80
    (cherry picked from commit 6673a1d6b33ca72062d35450f97de43bf550b705)

Thierry Carrez (ttx)
Changed in cinder:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: juno-1 → 2014.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.