This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
Bug 2012910 - Server list by tags not working
Summary: Server list by tags not working
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: python-openstackclient
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: Upstream M1
: ---
Assignee: Stephen Finucane
QA Contact: nlevinki
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-11 15:08 UTC by Matthew Booth
Modified: 2024-01-10 20:42 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-01-10 20:27:31 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Launchpad 1946816 0 None None None 2021-10-13 03:33:03 UTC
OpenStack gerrit 813789 0 None MERGED compute: Fix filtering servers by tags 2021-10-13 16:29:34 UTC
Red Hat Issue Tracker   OSP-10318 0 None None None 2024-01-10 20:27:30 UTC
Red Hat Issue Tracker OSP-31121 0 None None None 2024-01-10 20:42:33 UTC

Description Matthew Booth 2021-10-11 15:08:23 UTC
Description of problem:
I have a number of servers tagged with 'capo-e2e'. I want to list them by tag. I cannot do this. I added a second tag 'capo_e2e', and I can't select by that, either.

$ openstack --os-compute-api-version 2.26 server show 64232f5b-01e8-4139-be54-59c0399c40a8
+-----------------------------+----------------------------------------------------------+
| Field                       | Value                                                    |
+-----------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig           | MANUAL                                                   |
| OS-EXT-AZ:availability_zone | nova                                                     |
| OS-EXT-STS:power_state      | Running                                                  |
| OS-EXT-STS:task_state       | None                                                     |
| OS-EXT-STS:vm_state         | active                                                   |
| OS-SRV-USG:launched_at      | 2021-10-11T12:27:27.000000                               |
| OS-SRV-USG:terminated_at    | None                                                     |
| accessIPv4                  |                                                          |
| accessIPv6                  |                                                          |
| addresses                   | capo-e2e-network=10.0.2.16                               |
| config_drive                |                                                          |
| created                     | 2021-10-11T12:27:16Z                                     |
| description                 | capo-e2e-worker                                          |
| flavor                      | m1.xlarge (86d33ae4-b13d-4381-84a8-a0c307115bf9)         |
| hostId                      | 6ad047fd6e10b28977a60c38bde9c73b24130c0b24012a42fcdda227 |
| id                          | 64232f5b-01e8-4139-be54-59c0399c40a8                     |
| image                       | ubuntu-2004-lts (cbabe19a-de0d-4297-bb5e-65ae7db4946a)   |
| key_name                    | None                                                     |
| locked                      | False                                                    |
| name                        | capo-e2e-worker                                          |
| progress                    | 0                                                        |
| project_id                  | 25c8689dad974accbed26d0c67aadb4f                         |
| properties                  |                                                          |
| security_groups             | name='capo-e2e-secgroup'                                 |
| status                      | ACTIVE                                                   |
| tags                        | capo-e2e, capo_e2e                                       |
| updated                     | 2021-10-11T12:27:28Z                                     |
| user_id                     | bc844776c9a143b087ae4b811778ec2e                         |
| volumes_attached            |                                                          |
+-----------------------------+----------------------------------------------------------+

$ openstack --os-compute-api-version 2.26 server list --tags capo-e2e
Invalid input for query parameters tags. Value: ['capo-e2e']. "['capo-e2e']" is not a 'regex' (HTTP 400) (Request-ID: req-91a4d02a-8e4a-44c7-aa04-99808648a847)

(Incidentally, there may be good technical reasons for 👆 but it's a very bad api experience)

The following all list no servers:

$ openstack --os-compute-api-version 2.26 server list --tags capo\\-e2e
$ openstack --os-compute-api-version 2.26 server list --tags capo_e2e
$ openstack --os-compute-api-version 2.26 server list --tags e
$ openstack --os-compute-api-version 2.26 server list --tags '.*e.*'
$ openstack --os-compute-api-version 2.26 server list --tags '/.*e.*/'

(I'm basically just guessing random syntax)

Version-Release number of selected component (if applicable):
openstack-nova-api-20.6.2-2.20210607104828.el8ost.4.noarch

How reproducible:
Always

Comment 1 melanie witt 2021-10-12 21:52:30 UTC
(In reply to Matthew Booth from comment #0)
> $ openstack --os-compute-api-version 2.26 server list --tags capo-e2e
> Invalid input for query parameters tags. Value: ['capo-e2e']. "['capo-e2e']"
> is not a 'regex' (HTTP 400) (Request-ID:
> req-91a4d02a-8e4a-44c7-aa04-99808648a847)

Looking at this error message ^ again, I think I see what the bug is in nova. The value of the query parameter is a list and the schema validation is expecting a 'regex' [1], not a list of regexes (which I think it should be).

Based on another example in the same file, I think we might be able to fix this by adding the "multi_params" helper [2] around the 'regex' schema format. For example:

query_params_v226 = copy.deepcopy(query_params_v21)
query_params_v226['properties'].update({
    'tags': multi_params(parameter_types.common_query_regex_param),
    'tags-any': multi_params(parameter_types.common_query_regex_param),
    'not-tags': multi_params(parameter_types.common_query_regex_param),
    'not-tags-any': multi_params(parameter_types.common_query_regex_param),
})

[1] https://github.com/openstack/nova/blob/fdfdba265833d237e22676f9a223ab8ca0fe1e03/nova/api/openstack/compute/schemas/servers.py#L650-L653
[2] https://github.com/openstack/nova/blob/fdfdba265833d237e22676f9a223ab8ca0fe1e03/nova/api/validation/parameter_types.py#L57

Comment 2 melanie witt 2021-10-13 00:19:13 UTC
(In reply to melanie witt from comment #1)
> Based on another example in the same file, I think we might be able to fix
> this by adding the "multi_params" helper [2] around the 'regex' schema
> format. For example:
> 
> query_params_v226 = copy.deepcopy(query_params_v21)
> query_params_v226['properties'].update({
>     'tags': multi_params(parameter_types.common_query_regex_param),
>     'tags-any': multi_params(parameter_types.common_query_regex_param),
>     'not-tags': multi_params(parameter_types.common_query_regex_param),
>     'not-tags-any': multi_params(parameter_types.common_query_regex_param),
> })

Nevermind, I'm wrong, multi_params is already part of parameter_types.common_query_regex_param [3]. So, there is something else going wrong here.

[3] https://github.com/openstack/nova/blob/fdfdba265833d237e22676f9a223ab8ca0fe1e03/nova/api/validation/parameter_types.py#L70

> [1]
> https://github.com/openstack/nova/blob/
> fdfdba265833d237e22676f9a223ab8ca0fe1e03/nova/api/openstack/compute/schemas/
> servers.py#L650-L653
> [2]
> https://github.com/openstack/nova/blob/
> fdfdba265833d237e22676f9a223ab8ca0fe1e03/nova/api/validation/parameter_types.
> py#L57


Note You need to log in before you can comment on or make changes to this bug.