From bea98f6f8525308e926cf430b13fba6762f86c96 Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Thu, 6 Jun 2019 22:14:53 +0300 Subject: [PATCH] Reduce number of fields in notification data It is very important to prevent sending huge messages via rpc. Notification data has a lot of potentially large fields, such as output, spec and etc. Most of them are useless as a part of notification message so we should omit them. Change-Id: I0762a465742fcb1d1dc8d4d00d81cf8288b842ca Signed-off-by: Oleg Ovcharuk --- mistral/engine/tasks.py | 15 ++++++++++++++- mistral/engine/workflows.py | 14 +++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mistral/engine/tasks.py b/mistral/engine/tasks.py index b4d5cd81b..08102c260 100644 --- a/mistral/engine/tasks.py +++ b/mistral/engine/tasks.py @@ -76,10 +76,23 @@ class Task(object): notifier = notif.get_notifier(cfg.CONF.notifier.type) event = events.identify_task_event(old_task_state, new_task_state) + def _convert_to_notification_data(): + return { + "id": self.task_ex.id, + "name": self.task_ex.name, + "workflow_name": self.task_ex.workflow_name, + "workflow_namespace": self.task_ex.workflow_namespace, + "workflow_id": self.task_ex.workflow_id, + "state": self.task_ex.state, + "state_info": self.task_ex.state_info, + "type": self.task_ex.type, + "project_id": self.task_ex.project_id + } + def _send_notification(): notifier.notify( self.task_ex.id, - self.task_ex.to_dict(), + _convert_to_notification_data(), event, self.task_ex.updated_at, publishers diff --git a/mistral/engine/workflows.py b/mistral/engine/workflows.py index d3bb7ccc4..aa97ee328 100644 --- a/mistral/engine/workflows.py +++ b/mistral/engine/workflows.py @@ -74,10 +74,22 @@ class Workflow(object): notifier = notif.get_notifier(cfg.CONF.notifier.type) + def _convert_to_notification_data(): + return { + "id": self.wf_ex.id, + "name": self.wf_ex.name, + "workflow_name": self.wf_ex.workflow_name, + "workflow_namespace": self.wf_ex.workflow_namespace, + "workflow_id": self.wf_ex.workflow_id, + "state": self.wf_ex.state, + "state_info": self.wf_ex.state_info, + "project_id": self.wf_ex.project_id + } + def _send_notification(): notifier.notify( self.wf_ex.id, - self.wf_ex.to_dict(), + _convert_to_notification_data(), event, self.wf_ex.updated_at, publishers