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
This commit is contained in:
parent
22206030fe
commit
2cbcd6f41b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user