From 2cbcd6f41ba285e06a6dded955ad0650ebebc5ce Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Fri, 13 May 2016 11:44:55 -0400 Subject: [PATCH] Improve logging of unexpected exceptions Functional tests are showing "unexpected exception" error logs for GreenletExit (although that's not obvious, because it's printed as an empty string), which is not exactly unexpected. This patch clarifies the logging to make it more obvious what's going on and reduces the severity for exit exceptions. If a truly unexpected exception occurs, it will still be logged (complete with backtrace) by one of the cleanup handlers linked to the greenthread. Change-Id: Ia59382ed8685ff04943920265511faeb81c03229 --- heat/engine/stack.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/heat/engine/stack.py b/heat/engine/stack.py index a9d4f2f62c..5d612d99db 100644 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -79,16 +79,22 @@ def reset_state_on_error(func): errmsg = None try: return func(stack, *args, **kwargs) - except BaseException as exc: + except Exception as exc: with excutils.save_and_reraise_exception(): errmsg = six.text_type(exc) LOG.error(_LE('Unexpected exception in %(func)s: %(msg)s'), {'func': func.__name__, 'msg': errmsg}) + except BaseException as exc: + with excutils.save_and_reraise_exception(): + exc_type = type(exc).__name__ + errmsg = '%s(%s)' % (exc_type, six.text_type(exc)) + LOG.info(_LI('Stopped due to %(msg)s in %(func)s'), + {'func': func.__name__, 'msg': errmsg}) finally: if stack.status == stack.IN_PROGRESS: - msg = _("Unexpected returning while IN_PROGRESS.") + rtnmsg = _("Unexpected exit while IN_PROGRESS.") stack.state_set(stack.action, stack.FAILED, - errmsg if errmsg is not None else msg) + errmsg if errmsg is not None else rtnmsg) assert errmsg is not None, "Returned while IN_PROGRESS." return handle_exceptions