]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Re-raise exceptions in upload-to-image
authorJon Bernard <jobernar@redhat.com>
Fri, 11 Apr 2014 14:44:55 +0000 (10:44 -0400)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 14:08:50 +0000 (22:08 +0800)
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)

cinder/api/contrib/volume_actions.py

index 2961112684f8fe2d22a62c0f7695b569922d41d7..22cb24eea18da979eba08218ba118ee0fd0473a8 100644 (file)
@@ -264,6 +264,8 @@ class VolumeActionsController(wsgi.Controller):
             msg = "%(err_type)s: %(err_msg)s" % {'err_type': error.exc_type,
                                                  'err_msg': error.value}
             raise webob.exc.HTTPBadRequest(explanation=msg)
+        except Exception as error:
+            raise webob.exc.HTTPBadRequest(explanation=unicode(error))
         return {'os-volume_upload_image': response}
 
     @wsgi.action('os-extend')