-
-
Notifications
You must be signed in to change notification settings - Fork 782
#4828 - fix tag filter when querying actions #4874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#4828 - fix tag filter when querying actions #4874
Conversation
|
I saw that there are no tests for the tag filter. I will have another look on the tests in the next few days and add them. Will provide the tests in a separate PR if this is merged earlier than that. |
|
@cognifloyd Would be nice to have a second pair of 👀 on verifying this API PR bugfix end2end considering full story in #4828 and more background in #4219. |
|
Here are 4 curls to show the effect of the fix.
Without the fix a curl to the API with While a curl with the tag provided tag matching the name of the action did return the action: So, with the fix being applied the query with |
nmaludy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are my reproduction steps:
Create a new action:
$ cat << EOF > /opt/stackstorm/packs/default/actions/test_tags.yaml
---
description: Action that executes an arbitrary Linux command on the localhost.
enabled: true
entry_point: ''
name: test_tags
tags:
- name: foo
value: bar
- name: blah
value: junk
parameters:
cmd:
description: Arbitrary Linux command to be executed on the local host.
required: true
type: string
sudo:
immutable: true
runner_type: "local-shell-cmd"
EOF
$ st2 action create /opt/stackstorm/packs/default/actions/test_tags.yaml
Auth and test the API:
$ export ST2_AUTH_TOKEN=$(st2 auth st2admin -p Ch@ngeMe -t)
$ curl -H "X-Auth-Token: $ST2_AUTH_TOKEN" -k https://localhost/api/v1/actions?tags=foo
[]
Apply your fix and test again:
$ sed -i "s/'tags': 'name'/'tags': 'tags.name'/g" /opt/stackstorm/st2/lib/python3.6/site-packages/st2api/controllers/v1/actions.py
$ systemctl restart st2api
$ curl -H "X-Auth-Token: $ST2_AUTH_TOKEN" -k https://localhost/api/v1/actions?tags=foo
[
{
"tags": [
{
"name": "foo",
"value": "bar"
},
{
"name": "blah",
"value": "junk"
}
],
"uid": "action:default:test_tags",
"metadata_file": "",
"name": "test_tags",
"ref": "default.test_tags",
"description": "Action that executes an arbitrary Linux command on the localhost.",
"enabled": true,
"entry_point": "",
"pack": "default",
"runner_type": "local-shell-cmd",
"parameters": {
"cmd": {
"description": "Arbitrary Linux command to be executed on the local host.",
"required": true,
"type": "string"
},
"sudo": {
"immutable": true
}
},
"output_schema": {},
"notify": {},
"id": "5e8d20a45dfe26b0514e0646"
}
]
Closes #4828
This PR contains a small fix and does the lookup on the correct key.
Previous implementation returned actions with the name of the provided tag name (value) and not those actions with the specified tag.