-
-
Notifications
You must be signed in to change notification settings - Fork 782
Description
SUMMARY
https://docs.stackstorm.com/chatops/notifications.html#how-do-i-setup-notifications-for-orquesta Notification triggers are still emitted when notify set to [].
STACKSTORM VERSION
st2 3.5dev, on Python 3.6.9
OS, environment, install method
Linux,
Post what OS you are running this on, along with any other relevant information/
- e.g. Docker, Vagrant, Kubernetes, etc. Describe how you installed ST2
- e.g. one-line install, custom install, etc -->
Steps to reproduce the problem
orquesta-basic-meta.yaml
name: orquesta-basic
pack: examples
description: Run a local linux command
runner_type: orquesta
entry_point: workflows/orquesta-basic.yaml
enabled: true
notify:
on-complete:
routes:
- slack
message: '"@channel: Action run by {{action_context.user}} succeeded. Cmd run was {{cmd}}."'
parameters:
cmd:
required: true
type: string
timeout:
type: integer
default: 60
notify:
type: array
default: []
orquesta-basic.yaml
version: 1.0
description: A basic workflow that runs an arbitrary linux command.
input:
- cmd
- timeout
tasks:
task1:
action: examples.local-notify cmd=<% ctx(cmd) %>
next:
- when: <% succeeded() %>
publish:
- stdout: <% result().stdout %>
- stderr: <% result().stderr %>
output:
- stdout: <% ctx(stdout) %>
local-meta.yaml
description: Action that executes an arbitrary Linux command on the localhost.
enabled: true
entry_point: ''
name: local-notify
notify:
on-complete:
routes:
- slack
message: '"@channel: Action run by {{action_context.user}} succeeded. Cmd run was {{cmd}}."'
parameters:
cmd:
description: Arbitrary Linux command to be executed on the remote host(s).
required: true
type: string
sudo:
immutable: true
runner_type: "local-shell-cmd"
Expected Results
Notification trigger should be emitted only once for the workflow and not for local-notify action since notify parameter is set to an empty list.
Actual Results
What happened? What output did you get?
ST2 trace
+--------------------------+------------------+--------------------------------+-----------------------------+
| id | type | ref | updated_at |
+--------------------------+------------------+--------------------------------+-----------------------------+
| 606bf1f8c4490ad054d6b347 | execution | examples.orquesta-basic | 2021-04-06T05:30:32.941973Z |
| 606bf1fab233ed4e9db8a731 | execution | examples.local-notify | 2021-04-06T05:30:34.374090Z |
| 606bf1fb7152f7873199eb48 | trigger-instance | core.st2.generic.notifytrigger | 2021-04-06T05:30:35.664529Z |
| 606bf1fb7152f7873199eb49 | trigger-instance | core.st2.generic.actiontrigger | 2021-04-06T05:30:36.046113Z |
| 606bf1fc7152f7873199eb4b | trigger-instance | core.st2.generic.notifytrigger | 2021-04-06T05:30:36.499579Z |
| 606bf1fc7152f7873199eb4c | trigger-instance | core.st2.generic.actiontrigger | 2021-04-06T05:30:36.646045Z |
+--------------------------+------------------+--------------------------------+-----------------------------+
After some digging
https://github.com/StackStorm/st2/blob/master/st2common/st2common/services/workflows.py#L789 I guess this is where it filters the tasks and set notify parameter of live action.
if (
wf_ex_db.notify
and wf_ex_db.notify.get("config")
and wf_ex_db.notify.get("tasks")
--> and task_ex_db.task_name in wf_ex_db.notify["tasks"]
):
lv_ac_db.notify = notify_api_models.NotificationsHelper.to_model(
wf_ex_db.notify["config"]
)
However, this is overridden when action is requested at https://github.com/StackStorm/st2/blob/master/st2common/st2common/services/workflows.py#L802
# Request action execution.
--> lv_ac_db, ac_ex_db = ac_svc.request(lv_ac_db)
by https://github.com/StackStorm/st2/blob/master/st2common/st2common/services/action.py#L134
if not _is_notify_empty(action_db.notify):
--> liveaction.notify = action_db.notify