Skip to content

Action registration does not enforce unique position parameters in metadata #3317

@LindsayHill

Description

@LindsayHill

ST2 allows actions to be registered when they have non-unique position values.

For example, this action metadata will get successfully registered:

---
  name: "pause"
  runner_type: "run-python"
  description: "Action to pause current thread of workflow/sub-workflow."
  enabled: true
  entry_point: "pause.py"
  parameters:
    max_pause:
      type: "integer"
      description: "Maximum length of time to pause (Seconds)"
      required: true
      position: 0
    random:
      type: "boolean"
      description: "Randomize pause for current flow/sub-flow to a max of max_pause. "
      required: false
      default: false
      position: 0

This is the output when registering the action:

[vagrant@st2vagrant actions]$ sudo st2ctl reload --register-actions
Registering content...[flags = --register-actions]
2017-03-28 22:00:54,093 INFO [-] Connecting to database "st2" @ "0.0.0.0:27017" as user "None".
2017-03-28 22:00:54,217 INFO [-] =========================================================
2017-03-28 22:00:54,217 INFO [-] ############## Registering runners ######################
2017-03-28 22:00:54,218 INFO [-] =========================================================
2017-03-28 22:00:54,625 INFO [-] Registered 13 runners.
2017-03-28 22:00:54,625 INFO [-] =========================================================
2017-03-28 22:00:54,625 INFO [-] ############## Registering actions ######################
2017-03-28 22:00:54,625 INFO [-] =========================================================
2017-03-28 22:00:59,885 INFO [-] Registered 176 actions.
##### st2 components status #####
st2actionrunner PID: 1328
st2actionrunner PID: 1342
st2actionrunner PID: 1351
st2actionrunner PID: 1356
st2actionrunner PID: 1370
st2actionrunner PID: 1378
st2actionrunner PID: 1383
st2actionrunner PID: 1393
st2actionrunner PID: 1400
st2actionrunner PID: 1413
st2api PID: 1108
st2api PID: 2026
st2stream PID: 1112
st2stream PID: 2014
st2auth PID: 1131
st2auth PID: 11580
st2garbagecollector PID: 1110
st2notifier PID: 1115
st2resultstracker PID: 1109
st2rulesengine PID: 1137
st2sensorcontainer PID: 1116
st2chatops is not running.
mistral-server PID: 1113
mistral-api PID: 1129
mistral-api PID: 18458
mistral-api PID: 18459
[vagrant@st2vagrant actions]$

It appears to be stored with overlapping positional values:

[vagrant@st2vagrant actions]$st2 action get core.pause
+-------------+--------------------------------------------------------------+
| Property    | Value                                                        |
+-------------+--------------------------------------------------------------+
| id          | 58b70897c4da5f6aa779b82f                                     |
| uid         | action:core:pause                                            |
| ref         | core.pause                                                   |
| pack        | core                                                         |
| name        | pause                                                        |
| description | Action to pause current thread of workflow/sub-workflow.     |
| enabled     | True                                                         |
| entry_point | pause.py                                                     |
| runner_type | run-python                                                   |
| parameters  | {                                                            |
|             |     "max_pause": {                                           |
|             |         "position": 0,                                       |
|             |         "required": true,                                    |
|             |         "type": "integer",                                   |
|             |         "description": "Maximum length of time to pause      |
|             | (Seconds)"                                                   |
|             |     },                                                       |
|             |     "random": {                                              |
|             |         "default": false,                                    |
|             |         "position": 0,                                       |
|             |         "required": false,                                   |
|             |         "type": "boolean",                                   |
|             |         "description": "Randomize pause for current flow     |
|             | /sub-flow to a max of max_pause. "                           |
|             |     }                                                        |
|             | }                                                            |
| notify      |                                                              |
| tags        |                                                              |
+-------------+--------------------------------------------------------------+
[vagrant@st2vagrant actions]$

Expected behavior: If using the position parameter, users should have to use unique values. This should fail validation at action registration, with some sort of helpful error message.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions