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/notifications | |
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/notifications')
-rw-r--r-- | nova/notifications/objects/exception.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/nova/notifications/objects/exception.py b/nova/notifications/objects/exception.py index e0e5016f47..6ebb927b27 100644 --- a/nova/notifications/objects/exception.py +++ b/nova/notifications/objects/exception.py @@ -21,24 +21,27 @@ from nova.objects import fields @nova_base.NovaObjectRegistry.register_notification class ExceptionPayload(base.NotificationPayloadBase): # Version 1.0: Initial version - VERSION = '1.0' + # Version 1.1: Add traceback field to ExceptionPayload + VERSION = '1.1' fields = { 'module_name': fields.StringField(), 'function_name': fields.StringField(), 'exception': fields.StringField(), - 'exception_message': fields.StringField() + 'exception_message': fields.StringField(), + 'traceback': fields.StringField() } def __init__(self, module_name, function_name, exception, - exception_message): + exception_message, traceback): super(ExceptionPayload, self).__init__() self.module_name = module_name self.function_name = function_name self.exception = exception self.exception_message = exception_message + self.traceback = traceback @classmethod - def from_exception(cls, fault): + def from_exc_and_traceback(cls, fault, traceback): trace = inspect.trace()[-1] # TODO(gibi): apply strutils.mask_password on exception_message and # consider emitting the exception_message only if the safe flag is @@ -49,7 +52,8 @@ class ExceptionPayload(base.NotificationPayloadBase): function_name=trace[3], module_name=module_name, exception=fault.__class__.__name__, - exception_message=six.text_type(fault)) + exception_message=six.text_type(fault), + traceback=traceback) @base.notification_sample('compute-exception.json') |