Skip to content

action_ref referential integrity not validated for action-alias #4372

@nzlosh

Description

@nzlosh
SUMMARY

When action-alias files are parsed and inserted into the database, invalid action_ref references are silently accepted.

ISSUE TYPE

Pick one below and delete the rest:

  • Bug Report
STACKSTORM VERSION
st2 2.9dev, on Python 2.7.6```:


##### OS / ENVIRONMENT / INSTALL METHOD
```lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty

Install method: dev source installation

STEPS TO REPRODUCE

Add an action-alias to a pack that references a non-existent action and reload st2.

Simple example

---
name: "disable_upgrade"
description: "Disable the automatic package upgrade for a farm."
action_ref: "st2dm_upgrade_pkg.disable_upgrade"
formats:
  - display: "apu disable <role>"
    representation:
      - "apu disable {{role}}"
ack:
  enabled: true
  format: "StackStorm execution id `{{ execution.id }}`."
  append_url: true
result:
  enabled: true
  format: "{{ execution }}"
EXPECTED RESULTS

It would be useful to report a referential integrity error/warning when the action-alias file is parsed and references a non-existent action.

ACTUAL RESULTS

We see there is no pack named st2dm_upgrade_pkg.

st2 pack list 
+----------------------+----------------------+-------------------------------+---------+-------------------------------+
| ref                  | name                 | description                   | version | author                        |
+----------------------+----------------------+-------------------------------+---------+-------------------------------+
| chatops              | chatops              | Chatops integration pack      | 0.2.0   | Kirill Enykeev                |
| core                 | core                 | Basic core actions.           | 1.0.0   | StackStorm, Inc.              |
| linux                | linux                | Generic linux actions         | 1.0.0   | Stackstorm Inc                |
| packs                | packs                | Pack management               | 1.0.0   | StackStorm, Inc.              |
|                      |                      | functionality.                |         |                               |
| st2dm_apu            | st2dm_apu            | Automatic Package Upgrade     | 2.0.0   | Infrastructure Squad          |
|                      |                      | (APU) proccess.               |         |                               |
+----------------------+----------------------+-------------------------------+---------+-------------------------------+

Here we see the action-aliases defined to st2dm_apu of which disable_upgrade is used to show the problem.

st2 action-alias list                                                                    
+-----------------------------------+------------+--------------------------------------+---------+
| ref                               | pack       | description                          | enabled |
+-----------------------------------+------------+--------------------------------------+---------+
| st2dm_apu.disable_upgrade         | st2dm_apu  | Disable the automatic package        | True    |
|                                   |            | upgrade for a farm.                  |         |
| st2dm_apu.enable_upgrade          | st2dm_apu  | Enable the automatic package upgrade | True    |
|                                   |            | for a farm.                          |         |
| st2dm_apu.reset_upgrade           | st2dm_apu  | Reset the automatic package upgrade  | True    |
|                                   |            | on a farm.                           |         |
| st2dm_apu.start_upgrade           | st2dm_apu  | Start the automatic package upgrade  | True    |
|                                   |            | on a farm.                           |         |
| st2dm_apu.stop_upgrade            | st2dm_apu  | Stop the automatic package upgrade   | True    |
|                                   |            | on a farm.                           |         |
+-----------------------------------+------------+--------------------------------------+---------+

Here we see st2dm_apu.disable_upgade action alias is available with an action_ref that points to a non-existent action.

st2 action-alias get st2dm_apu.disable_upgrade
+-------------+--------------------------------------------------------------+
| Property    | Value                                                        |
+-------------+--------------------------------------------------------------+
| id          | 5bb37fb7d506c3cfe9c26276                                     |
| ref         | st2dm_apu.disable_upgrade                                    |
| pack        | st2dm_apu                                                    |
| name        | disable_upgrade                                              |
| description | Disable the automatic package upgrade for a farm.            |
| enabled     | True                                                         |
| action_ref  | st2dm_upgrade_pkg.disable_upgrade                            |
| formats     | [                                                            |
|             |     {                                                        |
|             |         "representation": [                                  |
|             |             "apu disable {{role}}"                           |
|             |         ],                                                   |
|             |         "display": "apu disable <role>"                      |
|             |     }                                                        |
|             | ]                                                            |
| ack         | {                                                            |
|             |     "append_url": true,                                      |
|             |     "enabled": true,                                         |
|             |     "format": "StackStorm execution id `{{ execution.id      |
|             | }}`."                                                        |
|             | }                                                            |
| extra       |                                                              |
| result      | {                                                            |
|             |     "enabled": true,                                         |
|             |     "format": "{{ execution }}"                              |
|             | }                                                            |
| uid         | action:st2dm_apu:disable_upgrade                             |
+-------------+--------------------------------------------------------------+

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions