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 <vgvoleg@gmail.com>
This commit is contained in:
Oleg Ovcharuk 2019-06-06 22:14:53 +03:00
parent f85caa02c9
commit bea98f6f85
2 changed files with 27 additions and 2 deletions

View File

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

View File

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