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
This commit is contained in:
Kevin_Zheng
2018-04-25 11:17:14 +08:00
parent 8863b501b7
commit 2a0f2a0d27
20 changed files with 188 additions and 77 deletions

View File

@@ -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