Merge "Only send traceback to users when in debug mode"

This commit is contained in:
Jenkins 2013-09-16 20:11:41 +00:00 committed by Gerrit Code Review
commit 9ce68af5fb
3 changed files with 11 additions and 4 deletions

View File

@ -22,6 +22,9 @@ Cinder's faultwrapper
import traceback
import webob
from oslo.config import cfg
cfg.CONF.import_opt('debug', 'heat.openstack.common.log')
from heat.common import exception
from heat.openstack.common import log as logging
@ -81,7 +84,8 @@ class FaultWrapper(wsgi.Middleware):
if isinstance(ex, exception.HTTPExceptionDisguise):
# An HTTP exception was disguised so it could make it here
# let's remove the disguise and set the original HTTP exception
trace = ''.join(traceback.format_tb(ex.tb))
if cfg.CONF.debug:
trace = ''.join(traceback.format_tb(ex.tb))
ex = ex.exc
webob_exc = ex
@ -92,7 +96,7 @@ class FaultWrapper(wsgi.Middleware):
message = str(ex.message)
if not trace:
if cfg.CONF.debug and not trace:
trace = str(ex)
if trace.find('\n') > -1:
unused, trace = trace.split('\n', 1)

View File

@ -647,6 +647,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.m.VerifyAll()
def test_create_err_stack_bad_reqest(self):
cfg.CONF.set_override('debug', True)
template = {u'Foo': u'bar'}
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,

View File

@ -27,7 +27,7 @@ class FaultMiddlewareTest(HeatTestCase):
msg = wrapper._error(heat_exc.StackNotFound(stack_name='a'))
expected = {'code': 404,
'error': {'message': 'The Stack (a) could not be found.',
'traceback': 'None\n',
'traceback': None,
'type': 'StackNotFound'},
'explanation': 'The resource could not be found.',
'title': 'Not Found'}
@ -39,7 +39,7 @@ class FaultMiddlewareTest(HeatTestCase):
expected = {'code': 500,
'error': {'message': 'Response from Keystone does '
'not contain a Heat endpoint.',
'traceback': 'None\n',
'traceback': None,
'type': 'NoServiceEndpoint'},
'explanation': 'The server has either erred or is '
'incapable of performing the requested '
@ -48,6 +48,8 @@ class FaultMiddlewareTest(HeatTestCase):
self.assertEqual(msg, expected)
def test_remote_exception(self):
# We want tracebacks
cfg.CONF.set_override('debug', True)
error = heat_exc.StackNotFound(stack_name='a')
exc_info = (type(error), error, None)
serialized = rpc_common.serialize_remote_exception(exc_info)