st2 icon indicating copy to clipboard operation
st2 copied to clipboard

Configs not loading lists from kv store

Open bishopbm1 opened this issue 4 years ago • 2 comments

SUMMARY

When registering a config with a list parameter that is referenced from the Key Value store, it is not being loaded properly which makes the register-configs command fail.

STACKSTORM VERSION

# st2 --version
st2 3.2.0, on Python 2.7.5
OS, environment, install method
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 (Maipo)

Installed with puppet module

Problem

Config schema: https://github.com/EncoreTechnologies/stackstorm-patching_roulette/blob/master/config.schema.yaml

We have the Key Value store values:

st2 key get patching_roulette.members
+------------------+--------------------------------+
| Property         | Value                          |
+------------------+--------------------------------+
| name             | patching_roulette.members      |
| value            | ["test_user_1", "test_user_2"] |
| secret           | False                          |
| encrypted        | False                          |
| scope            | st2kv.system                   |
| expire_timestamp |                                |
+------------------+--------------------------------+

# st2 key get patching_roulette.assignments
+------------------+--------------------------------------------+
| Property         | Value                                      |
+------------------+--------------------------------------------+
| name             | patching_roulette.assignments              |
| value            | ["test_assignment_1", "test_assignment_2"] |
| secret           | False                                      |
| encrypted        | False                                      |
| scope            | st2kv.system                               |
| expire_timestamp |                                            |
+------------------+--------------------------------------------+

The config:

# cat /opt/stackstorm/configs/patching_roulette.yaml 
---
members: "{{ st2kv.system.patching_roulette.members }}"
assignments: "{{ st2kv.system.patching_roulette.assignments }}"

And when we try to register it produces this error:

 st2ctl reload --register-configs
Registering content...[flags = --config-file /etc/st2/st2.conf --register-configs]
2020-05-18 11:35:03,345 INFO [-] Connecting to database "st2" @ "127.0.0.1:27017" as user "stackstorm".
2020-05-18 11:35:03,353 INFO [-] Successfully connected to database "st2" @ "127.0.0.1:27017" as user "stackstorm".
2020-05-18 11:35:04,053 INFO [-] =========================================================
2020-05-18 11:35:04,053 INFO [-] ############## Registering configs ######################
2020-05-18 11:35:04,054 INFO [-] =========================================================
2020-05-18 11:35:05,366 WARNING [-] Failed to register configs: Failed to register config "/opt/stackstorm/configs/patching_roulette.yaml" for pack "patching_roulette": Failed validating attribute "assignments" in config for pack "patching_roulette" (/opt/stackstorm/configs/patching_roulette.yaml): '{{ st2kv.system.patching_roulette.assignments }}' is not of type u'array', 'null'

Failed validating u'type' in schema['properties'][u'assignments']:
    {u'description': u'List of patching assignments',
     u'items': {u'type': u'string'},
     u'type': [u'array', 'null']}

On instance[u'assignments']:
    '{{ st2kv.system.patching_roulette.assignments }}'
Traceback (most recent call last):
  File "/usr/bin/st2-register-content", line 22, in <module>
    sys.exit(content_loader.main(sys.argv[1:]))
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/content/bootstrap.py", line 407, in main
    register_content()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/content/bootstrap.py", line 390, in register_content
    register_configs()
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/content/bootstrap.py", line 345, in register_configs
    raise e
ValueError: Failed to register config "/opt/stackstorm/configs/patching_roulette.yaml" for pack "patching_roulette": Failed validating attribute "assignments" in config for pack "patching_roulette" (/opt/stackstorm/configs/patching_roulette.yaml): '{{ st2kv.system.patching_roulette.assignments }}' is not of type u'array', 'null'

Failed validating u'type' in schema['properties'][u'assignments']:
    {u'description': u'List of patching assignments',
     u'items': {u'type': u'string'},
     u'type': [u'array', 'null']}

On instance[u'assignments']:
    '{{ st2kv.system.patching_roulette.assignments }}'

When we change the config to not use the values from the Key Value store:

# cat /opt/stackstorm/configs/patching_roulette.yaml 
---
members: 
  - "test_user_1"
  - "test_user_2"
assignments: 
  - "test_assignment_1"
  - "test_assignment_2"

Everything works as expected:

# st2ctl reload --register-configs
Registering content...[flags = --config-file /etc/st2/st2.conf --register-configs]
2020-05-18 11:45:16,522 INFO [-] Connecting to database "st2" @ "127.0.0.1:27017" as user "stackstorm".
2020-05-18 11:45:16,531 INFO [-] Successfully connected to database "st2" @ "127.0.0.1:27017" as user "stackstorm".
2020-05-18 11:45:17,418 INFO [-] =========================================================
2020-05-18 11:45:17,418 INFO [-] ############## Registering configs ######################
2020-05-18 11:45:17,418 INFO [-] =========================================================
2020-05-18 11:45:19,064 INFO [-] Registered 8 configs.

bishopbm1 avatar May 18 '20 15:05 bishopbm1

Thanks for contributing to this issue. As it has been 90 days since the last activity, we are automatically marking is as stale. If this issue is not relevant or applicable anymore (problem has been fixed in a new version or similar), please close the issue or let us know so we can close it. On the contrary, if the issue is still relevant, there is nothing you need to do, but if you have any additional details or context which would help us when working on this issue, please include it as a comment to this issue.

stale[bot] avatar Aug 16 '20 17:08 stale[bot]

Still seeing this issue in st2 3.8.0, on Python 3.8.13

jschoewe avatar May 10 '23 14:05 jschoewe