Can't filter/list resources that have no key=value metadata/extra-specs

Bug #1782847 reported by Goutham Pacha Ravi on 2018-07-20
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Manila
Wishlist
Unassigned
python-manilaclient
Wishlist
Unassigned

Bug Description

This bug was created out of the review on https://review.openstack.org/#/c/571366/

Looks like there's no way to get access rules with no metadata by using the metadata filter like this:

 $ manila --debug access-list test2 --metadata ''

Because this resolves to:
 GET /v2/cadd7139bc3148b8973df097c0911016/share-access-rules?share_id=ee8a6aa7-d685-4905-a9a2-c6c6899fe568&metadata=%7B%27%27%3A+None%7D

The URL params for metadata decoded are: {'':None}

The problem exists with other commands as well:
 $ manila list --metadata ''
 GET /v2/cadd7139bc3148b8973df097c0911016/shares/detail?metadata=%7B%27%27%3A+None%7D HTTP/1.1
 $ manila --debug type-list --extra-specs ''
 GET /v2/cadd7139bc3148b8973df097c0911016/types?extra_specs=%7B%27%27%3A+None%7D
 $ manila --debug list --extra-specs ''
  GET /v2/cadd7139bc3148b8973df097c0911016/shares/detail?extra_specs=%7B%27%27%3A+None%7D HTTP/1.1

The correct URL encoding shouldn't be {"": None}, it should be {} or %7B%7D; but even with that the server seems to misbehave with any of these keys.

-------------------------------------------------------------------------------

For example, I had a few shares, one of them has metadata, rest don't:

$ manila list --column id,metadata
+--------------------------------------+-----------------------------------------+
| Id | Metadata |
+--------------------------------------+-----------------------------------------+
| 3c2ddf21-c845-414e-ab8c-36c4ef56abe6 | {u'test': u'key', u'passing': u'value'} |
| d89d27de-b066-4ebb-919b-c6741bed0cce | {} |
| ee8a6aa7-d685-4905-a9a2-c6c6899fe568 | {} |
| ef3bca6d-ee62-4dbe-8563-a01887401fb8 | {} |
| f8075cf5-16f1-4c7c-b727-2ef1c2e3351c | {} |
+--------------------------------------+-----------------------------------------+

I wanted to retrieve only shares with no metadata

$ curl -i -X GET http://10.10.10.5:8786/v2/cadd7139bc3148b8973df097c0911016/shares?metadata=%7B%7D -H "X-Openstack-Manila-Api-Version: 2.45" -H "X-Auth-Token: gAAAAABbUlNPWkOdm5gqBZ3UX97jKLdujpbiGfAX6Sght9iLwEFOa-yslnzFOdBIJbba-MrNBdJ6D-ON6XoW6Nb7-UPGzishVzg0LvkhI7Yj5A345LkV3iGDhrvHSs5Cehmq9lxP4MvVtolltCcIVdRQmmzqAA_sA6SH9wgYjU0xhhe_brIU6cw" -H "Accept: application/json"
HTTP/1.1 200 OK
Date: Fri, 20 Jul 2018 21:28:35 GMT
Server: Apache/2.4.18 (Ubuntu)
x-compute-request-id: req-179d508c-f6ab-45d2-8c57-de2e0aa23160
X-OpenStack-Manila-API-Version: 2.45
Vary: X-OpenStack-Manila-API-Version
Content-Length: 1701
Connection: close
Content-Type: application/json

{"shares": [{"id": "3c2ddf21-c845-414e-ab8c-36c4ef56abe6", "links": [{"href": "http://10.10.10.5:8786/v2/cadd7139bc3148b8973df097c0911016/shares/3c2ddf21-c845-414e-ab8c-36c4ef56abe6", "rel": "self"}, {"href": "http://10.10.10.5:8786/cadd7139bc3148b8973df097c0911016/shares/3c2ddf21-c845-414e-ab8c-36c4ef56abe6", "rel": "bookmark"}], "name": null}, {"id": "d89d27de-b066-4ebb-919b-c6741bed0cce", "links": [{"href": "http://10.10.10.5:8786/v2/cadd7139bc3148b8973df097c0911016/shares/d89d27de-b066-4ebb-919b-c6741bed0cce", "rel": "self"}, {"href": "http://10.10.10.5:8786/cadd7139bc3148b8973df097c0911016/shares/d89d27de-b066-4ebb-919b-c6741bed0cce", "rel": "bookmark"}], "name": "zzaa"}, {"id": "f8075cf5-16f1-4c7c-b727-2ef1c2e3351c", "links": [{"href": "http://10.10.10.5:8786/v2/cadd7139bc3148b8973df097c0911016/shares/f8075cf5-16f1-4c7c-b727-2ef1c2e3351c", "rel": "self"}, {"href": "http://10.10.10.5:8786/cadd7139bc3148b8973df097c0911016/shares/f8075cf5-16f1-4c7c-b727-2ef1c2e3351c", "rel": "bookmark"}], "name": "zzzb"}, {"id": "ef3bca6d-ee62-4dbe-8563-a01887401fb8", "links": [{"href": "http://10.10.10.5:8786/v2/cadd7139bc3148b8973df097c0911016/shares/ef3bca6d-ee62-4dbe-8563-a01887401fb8", "rel": "self"}, {"href": "http://10.10.10.5:8786/cadd7139bc3148b8973df097c0911016/shares/ef3bca6d-ee62-4dbe-8563-a01887401fb8", "rel": "bookmark"}], "name": "zzza"}, {"id": "ee8a6aa7-d685-4905-a9a2-c6c6899fe568", "links": [{"href": "http://10.10.10.5:8786/v2/cadd7139bc3148b8973df097c0911016/shares/ee8a6aa7-d685-4905-a9a2-c6c6899fe568", "rel": "self"}, {"href": "http://10.10.10.5:8786/cadd7139bc3148b8973df097c0911016/shares/ee8a6aa7-d685-4905-a9a2-c6c6899fe568", "rel": "bookmark"}], "name": "test2"}]}

So the result wasn't filtered by "{}"

Jason Grosso (jgrosso) wrote :

Goutham is this your defect are you currently working on this? is it a wishlist item?

Goutham Pacha Ravi (gouthamr) wrote :

Thanks for asking Jason. I've added this bug to the Denver/Project Technical Gathering Agenda: https://etherpad.openstack.org/p/manila-denver-train-ptg-planning

This is an improvement to the filtering logic we have in all the APIs, we can take a look at it holistically in my opinion. I'll revert here with the proceedings of that discussion.

Tom Barron (tpb) on 2019-05-03
Changed in manila:
importance: Undecided → Wishlist
Changed in python-manilaclient:
importance: Undecided → Wishlist
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers