sort_key does not work for 'name' param on v2 snapshot API GET

Bug #1659504 reported by Ghanshyam Mann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
wangxiyuan

Bug Description

v2 snapshots POST/GET/PUT all works with 'name' in request as well as in response. But only sort things does not work on 'name' it expect only 'display_name'.

Seems like DB layer have only 'display_name' no 'name').

It is little bit odd where 'name' is being published everywhere on API and user does not know what 'display_name' is in v2 APIs but user is being force to sort with 'display_name' only and 'name' sort_key does not work. This seems odd APIs behavior.

All other APIs and filter etc translation logic to convert 'name' to 'display_name' is there- https://github.com/openstack/cinder/blob/master/cinder/api/v2/snapshots.py#L92

For sort also same should be done at least.

Ref- https://review.openstack.org/#/c/421251/

Revision history for this message
Eric Harney (eharney) wrote :
Download full text (4.0 KiB)

This seems to be working as expected to me. What commands give an unexpected output?

$ OS_VOLUME_API_VERSION=2 cinder snapshot-list
+--------------------------------------+--------------------------------------+-----------+------+------+
| ID | Volume ID | Status | Name | Size |
+--------------------------------------+--------------------------------------+-----------+------+------+
| 65b6128d-2107-4028-86ec-7b887ba50a44 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | c | 1 |
| 85db0ec0-1a8c-46e2-8000-4e1fb1fad81a | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | a | 1 |
| ccc396a7-a94f-4bd5-8ac7-7c77054ca117 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | b | 1 |
+--------------------------------------+--------------------------------------+-----------+------+------+

$ OS_VOLUME_API_VERSION=2 cinder snapshot-list --sort name:asc
+--------------------------------------+--------------------------------------+-----------+------+------+
| ID | Volume ID | Status | Name | Size |
+--------------------------------------+--------------------------------------+-----------+------+------+
| 85db0ec0-1a8c-46e2-8000-4e1fb1fad81a | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | a | 1 |
| ccc396a7-a94f-4bd5-8ac7-7c77054ca117 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | b | 1 |
| 65b6128d-2107-4028-86ec-7b887ba50a44 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | c | 1 |
+--------------------------------------+--------------------------------------+-----------+------+------+

$ OS_VOLUME_API_VERSION=2 cinder snapshot-list --sort name:desc
+--------------------------------------+--------------------------------------+-----------+------+------+
| ID | Volume ID | Status | Name | Size |
+--------------------------------------+--------------------------------------+-----------+------+------+
| 65b6128d-2107-4028-86ec-7b887ba50a44 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | c | 1 |
| ccc396a7-a94f-4bd5-8ac7-7c77054ca117 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | b | 1 |
| 85db0ec0-1a8c-46e2-8000-4e1fb1fad81a | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | a | 1 |
+--------------------------------------+--------------------------------------+-----------+------+------+

$ OS_VOLUME_API_VERSION=3.20 cinder snapshot-list --sort name:asc
+--------------------------------------+--------------------------------------+-----------+------+------+
| ID | Volume ID | Status | Name | Size |
+--------------------------------------+--------------------------------------+-----------+------+------+
| 85db0ec0-1a8c-46e2-8000-4e1fb1fad81a | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | a | 1 |
| ccc396a7-a94f-4bd5-8ac7-7c77054ca117 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | b | 1 |
| 65b6128d-2107-4028-86ec-7b887ba50a44 | c225f384-d02b-449d-bf7f-c1b3918d0660 | available | c | 1 |
+--...

Read more...

Revision history for this message
Ghanshyam Mann (ghanshyammann) wrote :

Thanks Eric. Yea it works well from client side as mapping is being done there - https://github.com/openstack/python-cinderclient/blob/master/cinderclient/base.py#L234

API side still have issue.

Revision history for this message
wangxiyuan (wangxiyuan) wrote :

http://ip:8776/v3/{project_id}/snapshots?sort_key=name doesn't work.

wangxiyuan (wangxiyuan)
Changed in cinder:
assignee: nobody → wangxiyuan (wangxiyuan)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

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

Changed in cinder:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/431488
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=8b5264f559e60a8947f9d879070ff67960ae86f3
Submitter: Jenkins
Branch: master

commit 8b5264f559e60a8947f9d879070ff67960ae86f3
Author: wangxiyuan <email address hidden>
Date: Thu Feb 9 20:00:10 2017 +0800

    Support sort snapshots with name

    Cinder now doesn't support sort snapshots with "name".
    This patch adds the support to keep the same with volume
    does.

    Change-Id: I79d160292bc190c643bbe11668cc49ba11a23bcb
    Closes-bug: #1659504

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 11.0.0.0b2

This issue was fixed in the openstack/cinder 11.0.0.0b2 development milestone.

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.