supplying multiple list --filters does not work correctly

Bug #1696780 reported by Eric Harney
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-cinderclient
New
Undecided
Rajat Dhasmana

Bug Description

Specifying multiple "--filters" arguments for "cinder list" does not produce the expected results. I would expect this to apply all filters with an AND. It seems that some filters are just ignored.

$ cinder list
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 105f960b-462b-4a51-8652-30122af2d4b7 | available | Σ | 1 | lvmdriver-1 | false | |
| 8747b5d5-dc12-403c-813a-854cda67eb1f | available | test2 | 1 | lvmdriver-1 | false | |
| 8fa11f2b-a847-422e-8ba0-9d61e8bad043 | available | - | 1 | lvmdriver-1 | false | |
| bb809d11-6489-4998-89d2-9584cea2de42 | available | test1 | 1 | lvmdriver-1 | false | |
| ea6d46cb-8839-4b2e-9609-f9ecc442f2d5 | available | test2 | 1 | lvmdriver-1 | false | |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+

$ cinder list --filters name=test2
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| 8747b5d5-dc12-403c-813a-854cda67eb1f | available | test2 | 1 | lvmdriver-1 | false | |
| ea6d46cb-8839-4b2e-9609-f9ecc442f2d5 | available | test2 | 1 | lvmdriver-1 | false | |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+

- This looks right

$ cinder list --filters name=test2 --filters name=test1
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| bb809d11-6489-4998-89d2-9584cea2de42 | available | test1 | 1 | lvmdriver-1 | false | |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+

- This does not look right because name=test2 is ignored.

$ cinder list --filters size=2 --filters name=test1
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| bb809d11-6489-4998-89d2-9584cea2de42 | available | test1 | 1 | lvmdriver-1 | false | |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+

- This does not look right because size=2 is ignored.

$ cinder --debug list --filters size=2 --filters name=test1
<snip>
DEBUG:keystoneauth:GET call to volumev3 for http://10.16.149.222:8776/v3/1d75311965b5407dbf9ff2c78ce09c74/volumes/detail?name=test1 used request id req-ab159e47-1e66-4d93-9e8e-e368bcf91e62
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+
| bb809d11-6489-4998-89d2-9584cea2de42 | available | test1 | 1 | lvmdriver-1 | false | |
+--------------------------------------+-----------+-------+------+-------------+----------+-------------+

- This shows that the size filter is not sent to the API.

TommyLike (hu-husheng)
Changed in python-cinderclient:
assignee: nobody → TommyLike (hu-husheng)
Revision history for this message
Eric Harney (eharney) wrote :

$ cinder --debug list --filters size=2 name=test1

Will send the request w/ both filters specified, but the above versions should also work IMO. (Or give some kind of warning if they don't work.)

Revision history for this message
TommyLike (hu-husheng) wrote :

Hey, Eric, do we already have any command options that can accept multi values with the input of --key value1 --key value2?

Revision history for this message
Gorka Eguileor (gorka) wrote :

The argument parser we are using only restricts to 1 instance on positional arguments, and all optional arguments can be duplicated and the result will not be the expected one, but this is not limited to just this command but to *ALL* our commands.

If you do `cinder list --fields name --fields size` you will only get the ID and size fields and not the name field.

I believe we should prevent this from happening, in this command and all other commands that are not ready to accept multiple times the optional argument, instead of adding support for it.

If I remember correctly we are using argparse below all the abstraction layers, so we could do something like this: https://stackoverflow.com/questions/23032514/argparse-disable-same-argument-occurences

Revision history for this message
Sean McGinnis (sean-mcginnis) wrote : Bug Assignee Expired

Unassigning due to no activity for > 6 months.

Changed in python-cinderclient:
assignee: TommyLike (hu-husheng) → nobody
Changed in python-cinderclient:
assignee: nobody → Rajat Dhasmana (whoami-rajat)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-cinderclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/587610

Changed in python-cinderclient:
status: New → In Progress
Eric Harney (eharney)
Changed in python-cinderclient:
status: In Progress → New
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-cinderclient (master)

Change abandoned by Rajat Dhasmana (<email address hidden>) on branch: master
Review: https://review.opendev.org/587610
Reason: New implementation
https://review.opendev.org/#/c/678523/

Revision history for this message
이예림 (yaeeee) wrote :

$ cinder --debug --os-volume-api-version 3.70 list --filters name=test1 --filters size=1

I have confirmed that the command works normally on the following versions of cinder.

cinder version : 9.3.0

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.