Snapshot list cannot be sorted by 'name'

Bug #1779732 reported by Goutham Pacha Ravi on 2018-07-02
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Manila
Low
Unassigned

Bug Description

How to reproduce:

1) Create a share that supports snapshots
2) Create 2 or more snapshots with different names (the sort_key doesn't have to be "name", it can be any attr)
3) On the manila client CLI, execute:

 manila snapshot-list --sort-key name --sort-dir asc

4) You can use the '--debug' opt to verify the right API is being executed:

manila --debug snapshot-list --sort-key name --sort-dir asc
<SNIP>
http://10.10.10.5:8786 "GET /v2/cadd7139bc3148b8973df097c0911016/snapshots/detail?sort_dir=asc&sort_key=name HTTP/1.1" 500 128
RESP: [500] {'Content-Length': '128', 'x-compute-request-id': 'req-a246e66d-ad0b-4547-896e-820a161c76f3', 'Vary': 'X-OpenStack-Manila-API-Version', 'Connection': 'close', 'Server': 'Apache/2.4.18 (Ubuntu)', 'X-OpenStack-Manila-API-Version': '2.43', 'Date': 'Mon, 02 Jul 2018 18:13:06 GMT', 'Content-Type': 'application/json'}
RESP BODY: {"computeFault": {"message": "The server has either erred or is incapable of performing the requested operation.", "code": 500}}

Error in the API logs:

[00;32mDEBUG manila.share.api [[01;36mreq-2df90312-6c27-41a8-b8b9-90dccd0821c2 [00;36m61aef4895b0b41619e67ae83fba6defe cadd7139bc3148b8973df097c0911016[00;32m] [01;35m[00;32mSearching for snapshots by: {}[00m [00;33mfrom (pid=19204) get_all_snapshots /opt/stack/manila/manila/share/api.py:1552[00m
[01;31mERROR manila.api.middleware.fault [[01;36mreq-2df90312-6c27-41a8-b8b9-90dccd0821c2 [00;36m61aef4895b0b41619e67ae83fba6defe cadd7139bc3148b8973df097c0911016[01;31m] [01;35m[01;31mCaught error: 'property' object has no attribute 'asc'[00m: AttributeError: 'property' object has no attribute 'asc'
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00mTraceback (most recent call last):
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/api/middleware/fault.py", line 77, in __call__
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return req.get_response(self.application)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1327, in send
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m application, catch_exc_info=False)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1291, in call_application Top
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m app_iter = application(self.environ, start_response)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 145, in __call__
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return resp(environ, start_response)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 145, in __call__
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return resp(environ, start_response)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/routes/middleware.py", line 141, in __call__
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m response = self.app(environ, start_response)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 145, in __call__
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return resp(environ, start_response)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 131, in __call__
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m resp = self.call_func(req, *args, **self.kwargs)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 196, in call_func
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return self.func(req, *args, **kwargs)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/api/openstack/wsgi.py", line 763, in __call__
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m content_type, body, accept)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/api/openstack/wsgi.py", line 821, in _process_stack
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m action_result = self.dispatch(meth, request, action_args)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/api/openstack/wsgi.py", line 916, in dispatch
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return method(req=request, **action_args)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/api/openstack/wsgi.py", line 1058, in version_select
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return func.func(self, *args, **kwargs)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/api/v2/share_snapshots.py", line 311, in detail
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return self._get_snapshots(req, is_detail=True)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/api/v1/share_snapshots.py", line 123, in _get_snapshots
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m sort_dir=sort_dir,
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/share/api.py", line 1572, in get_all_snapshots
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m sort_key=sort_key, sort_dir=sort_dir)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/db/api.py", line 558, in share_snapshot_get_all_by_project
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m sort_dir=sort_dir,
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/db/sqlalchemy/api.py", line 168, in wrapper
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m return f(*args, **kwargs)
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/db/sqlalchemy/api.py", line 2532, in share_snapshot_get_all_by_project
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m filters=filters, sort_key=sort_key, sort_dir=sort_dir,
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m File "/opt/stack/manila/manila/db/sqlalchemy/api.py", line 2507, in _share_snapshot_get_all_with_filters
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m query = query.order_by(attr.asc())
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00mAttributeError: 'property' object has no attribute 'asc'
[01;31m2018-07-02 18:04:48.689 TRACE manila.api.middleware.fault [01;35m[00m
-07-02 18:04:48.690 [00;36mINFO manila.api.middleware.fault [[01;36mreq-2df90312-6c27-41a8-b8b9-90dccd0821c2 [00;36m61aef4895b0b41619e67ae83fba6defe cadd7139bc3148b8973df097c0911016[00;36m] [01;35m[00;36mhttp://10.10.10.5:8786/v2/cadd7139bc3148b8973df097c0911016/snapshots/detail?sort_dir=asc&sort_key=name returned with HTTP 500[00m

The problem here seems to be that the user really wants to sort by the "display_name" rather than the sqlalchemy property "name" on the ShareSnapshot model.

summary: - Snapshot list cannot be sorted with sort keys 'asc' or 'desc'
+ Snapshot list cannot be sorted with 'name'
summary: - Snapshot list cannot be sorted with 'name'
+ Snapshot list cannot be sorted by 'name'
Goutham Pacha Ravi (gouthamr) wrote :

As expected the sort by display_name seems to work fine, but that's really a server-side name for this field

$ manila snapshot-list --sort-key display_name --sort-dir asc
+--------------------------------------+--------------------------------------+-----------+--------+------------+
| ID | Share ID | Status | Name | Share Size |
+--------------------------------------+--------------------------------------+-----------+--------+------------+
| 200eabb1-9775-44c9-a34b-e9a79624f6f8 | ef3bca6d-ee62-4dbe-8563-a01887401fb8 | available | zzza.1 | 1 |
| 36d12275-909b-445b-9503-6aa5e313b50b | ef3bca6d-ee62-4dbe-8563-a01887401fb8 | available | zzza.2 | 1 |
| a0567ac3-1652-424e-b2f5-fc2b99e2a1ce | ef3bca6d-ee62-4dbe-8563-a01887401fb8 | available | zzzb.1 | 1 |
| c370a31d-9f2d-4d44-8de7-75c960c76c65 | f8075cf5-16f1-4c7c-b727-2ef1c2e3351c | available | zzzb.1 | 1 |
+--------------------------------------+--------------------------------------+-----------+--------+------------+

Changed in manila:
assignee: nobody → Deepak Mourya (mourya007)
Changed in manila:
status: New → In Progress
importance: Undecided → Low
Changed in manila:
assignee: Deepak Mourya (mourya007) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers