diff options
author | Kevin_Zheng <zhengzhenyu@huawei.com> | 2018-04-25 11:17:14 +0800 |
---|---|---|
committer | Kevin_Zheng <zhengzhenyu@huawei.com> | 2018-06-19 16:46:46 +0800 |
commit | 2a0f2a0d270c6a5bb7c141e84a83d9d0e783ae3b (patch) | |
tree | 7dab94f8ce2b1429db7e71b2ec971fc35366ada4 /nova/exception_wrapper.py | |
parent | 8863b501b700c600afb37b2ce4019562cd06f42b (diff) | |
download | nova-2a0f2a0d270c6a5bb7c141e84a83d9d0e783ae3b.tar.gz |
Add full traceback to ExceptionPayload in versioned notifications
This patch adds full traceback to ExceptionPayload in versioned
notifications.
The instance fault field and instance-action REST API has already
provide the traceback to the admin users (controlable through policy)
and the notifications are also admin only things as they are emitted
to the message bus by default. So it is assumed that security is not
a bigger concern for the notification than for the REST API.
On the ML [1] post there was no objection to add new string field to the
ExceptionPayload that will hold the serialized traceback object.
[1] http://lists.openstack.org/pipermail/openstack-dev/2018-March/128105.html
Implements: blueprint add-full-traceback-to-error-notifications
Change-Id: Id587967ea4f9980c292492e2f659bf55fb037b28
Diffstat (limited to 'nova/exception_wrapper.py')
-rw-r--r-- | nova/exception_wrapper.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/nova/exception_wrapper.py b/nova/exception_wrapper.py index c5d932c6dc..bc4c871745 100644 --- a/nova/exception_wrapper.py +++ b/nova/exception_wrapper.py @@ -12,6 +12,7 @@ import functools import inspect +import traceback from oslo_utils import excutils @@ -27,15 +28,16 @@ CONF = nova.conf.CONF def _emit_exception_notification(notifier, context, ex, function_name, args, - source): + source, trace_back): _emit_legacy_exception_notification(notifier, context, ex, function_name, args) - _emit_versioned_exception_notification(context, ex, source) + _emit_versioned_exception_notification(context, ex, source, trace_back) @rpc.if_notifications_enabled -def _emit_versioned_exception_notification(context, ex, source): - versioned_exception_payload = exception.ExceptionPayload.from_exception(ex) +def _emit_versioned_exception_notification(context, ex, source, trace_back): + versioned_exception_payload = \ + exception.ExceptionPayload.from_exc_and_traceback(ex, trace_back) publisher = base.NotificationPublisher(host=CONF.host, source=source) event_type = base.EventType( object='compute', @@ -66,6 +68,7 @@ def wrap_exception(notifier=None, get_notifier=None, binary=None): try: return f(self, context, *args, **kw) except Exception as e: + tb = traceback.format_exc() with excutils.save_and_reraise_exception(): if notifier or get_notifier: call_dict = _get_call_dict( @@ -73,7 +76,7 @@ def wrap_exception(notifier=None, get_notifier=None, binary=None): function_name = f.__name__ _emit_exception_notification( notifier or get_notifier(), context, e, - function_name, call_dict, binary) + function_name, call_dict, binary, tb) return functools.wraps(f)(wrapped) return inner |