Don't disguise CFN API exceptions
The exception disguise wrapper is for the native API which uses the faultwrap filter to process the response. For HeatAPIException subclasses (which are only raised by the CFN/CW API's) we need to raise the unwrapped exception or the client sees a 500 response. Change-Id: Iebfbc76d5cb26aa9ee61c5192d7fecc596aa83b9 Closes-Bug: #1291079
This commit is contained in:
parent
ba48137e24
commit
31d18df403
|
@ -81,7 +81,6 @@ class XMLResponseSerializer(object):
|
|||
eltree = etree.Element(root)
|
||||
self.object_to_element(data.get(root), eltree)
|
||||
response = etree.tostring(eltree)
|
||||
logger.debug("XML response : %s" % response)
|
||||
return response
|
||||
|
||||
def default(self, response, result):
|
||||
|
|
|
@ -40,6 +40,7 @@ import routes.middleware
|
|||
import webob.dec
|
||||
import webob.exc
|
||||
|
||||
from heat.api.aws import exception as aws_exception
|
||||
from heat.common import exception
|
||||
from heat.common import serializers
|
||||
from heat.openstack.common import gettextutils
|
||||
|
@ -625,6 +626,11 @@ class Resource(object):
|
|||
# won't make it into the pipeline app that serializes errors
|
||||
raise exception.HTTPExceptionDisguise(http_exc)
|
||||
except webob.exc.HTTPException as err:
|
||||
if isinstance(err, aws_exception.HeatAPIException):
|
||||
# The AWS compatible API's don't use faultwrap, so
|
||||
# we want to detect the HeatAPIException subclasses
|
||||
# and raise rather than wrapping in HTTPExceptionDisguise
|
||||
raise
|
||||
if not isinstance(err, webob.exc.HTTPError):
|
||||
# Some HTTPException are actually not errors, they are
|
||||
# responses ready to be sent back to the users, so we don't
|
||||
|
|
|
@ -20,6 +20,7 @@ from oslo.config import cfg
|
|||
import stubout
|
||||
import webob
|
||||
|
||||
from heat.api.aws import exception as aws_exception
|
||||
from heat.common import exception
|
||||
from heat.common import wsgi
|
||||
from heat.tests.common import HeatTestCase
|
||||
|
@ -229,6 +230,9 @@ class ResourceExceptionHandlingTest(HeatTestCase):
|
|||
('client_exceptions', dict(
|
||||
exception=exception.StackResourceLimitExceeded,
|
||||
exception_catch=exception.StackResourceLimitExceeded)),
|
||||
('aws_exception', dict(
|
||||
exception=aws_exception.HeatAccessDeniedError,
|
||||
exception_catch=aws_exception.HeatAccessDeniedError)),
|
||||
('webob_bad_request', dict(
|
||||
exception=webob.exc.HTTPBadRequest,
|
||||
exception_catch=exception.HTTPExceptionDisguise)),
|
||||
|
|
Loading…
Reference in New Issue