StackStorm / StackStorm/st2

Provide readable refs for all core triggers

Open
#3,896 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CLI complexity:easy enhancement
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

Some core triggers (not all) still show unreadable UIDs as their refs:

vagrant@st2vagrant:~$ st2 rule list -a ref trigger.ref
+-----------------------------------------+--------------------------------------------+
| ref                                     | trigger.ref                                |
+-----------------------------------------+--------------------------------------------+
| chatops.notify                          | core.st2.generic.notifytrigger             |
| examples.notify_inquiry                 | core.st2.generic.inquiry                   |
| examples.notify_slack                   | core.st2.generic.notifytrigger             |
| examples.sample_rule_file_watch         | linux.f6ae8e26-ba1a-4d6b-b1c0-7bc93b1948a0 |
| examples.sample_rule_with_actiontrigger | core.st2.generic.actiontrigger             |
| examples.sample_rule_with_timer         | core.5ff0418f-d8da-4c0e-a44c-2df6c155eac2  |
| examples.sample_rule_with_webhook       | core.6ed4f7ce-88b9-4607-96fb-ea4c8c49f2c4  |
| homeautomation.reboot_openvpn           | core.7bab7732-f649-4e14-946a-215634e337ad  |
| napalm.bgp_prefix_exceeded              | core.e9ba620f-0aaf-407b-8430-4aa18dd31d1a  |
| napalm.configuration_change             | core.926804b6-24e2-4b9e-9533-9c7fb88381d0  |
| napalm.interface_down                   | core.bef48d5a-5d01-4040-b8cf-af1102063605  |
| napalm.lldp_remediate                   | napalm.LLDPNeighborDecrease                |
| testpack.test_st2kv_rule                | core.st2.generic.actiontrigger             |
| testpack.test_validate_rule             | testpack.event                             |
| testpack.testrule                       | core.02af969a-cd27-4280-b725-21097351481e  |
| unifi.notify_client_change              | unifi.ClientChange                         |
+-----------------------------------------+--------------------------------------------+
vagrant@st2vagrant:~$ st2 rule get homeautomation.reboot_openvpn
+-------------+----------------------------------------------------------+
| Property    | Value                                                    |
+-------------+----------------------------------------------------------+
| id          | 5a261efbc4da5f0ef7d2ead4                                 |
| uid         | rule:homeautomation:reboot_openvpn                       |
| ref         | homeautomation.reboot_openvpn                            |
| pack        | homeautomation                                           |
| name        | reboot_openvpn                                           |
| description | Reboot OpenVPN server daily at 4AM                       |
| enabled     | True                                                     |
| action      | {                                                        |
|             |     "ref": "vsphere.hard_reboot_vm",                     |
|             |     "parameters": {                                      |
|             |         "vmid": "56"                                     |
|             |     }                                                    |
|             | }                                                        |
| criteria    |                                                          |
| tags        |                                                          |
| trigger     | {                                                        |
|             |     "type": "core.st2.CronTimer",                        |
|             |     "ref": "core.7bab7732-f649-4e14-946a-215634e337ad",  |
|             |     "parameters": {                                      |
|             |         "timezone": "US/Pacific",                        |
|             |         "second": 0,                                     |
|             |         "minute": 0,                                     |
|             |         "hour": 4                                        |
|             |     }                                                    |
|             | }                                                        |
| type        | {                                                        |
|             |     "ref": "standard",                                   |
|             |     "parameters": {}                                     |
|             | }                                                        |
+-------------+----------------------------------------------------------+

This causes issues when trying to filter rules by trigger type, as the user will have to know this UID instead of the human readable name they put into the rule file, which is how it should be. Need to look into why these particular triggers (i.e. the aforementioned CronTimer is one examples) don't present refs identical to their names (the type` field).

In addition, the help output for the --trigger option for st2 rule list says you should use the trigger type when it seems to want the trigger ref. Normally, these are one and the same - but obviously for those that aren't, this presents a problem because again, the user is expecting to be able to use the trigger type, but must use the different ref.

So in summary:

  • Fix the core triggers so they all have human readable refs that are identical to their types
  • Fix the wording of the help output of the client to say that the ref is what's used, not the type

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the st2 rule list implementation and the --trigger help text, then trace how core trigger refs are produced for examples such as CronTimer. Make all core trigger refs match their types and update the help wording to refer to trigger refs; verify filtering and displayed refs with the rule list behavior shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.