filter not work with deleted status

Bug #1790114 reported by jichenjc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Expired
Undecided
Unassigned

Bug Description

During review https://review.openstack.org/#/c/597443/
seems this

 174 if search_opts.get("vm_state") == ['deleted']:
 175 if context.is_admin:
 176 search_opts['deleted'] = True
 177 else:
 178 msg = _("Only administrators may list deleted instances")
 179 raise exc.HTTPForbidden(explanation=msg)

has some issue so that the check won't work at all

Revision history for this message
jichenjc (jichenjc) wrote :

Type "help", "copyright", "credits" or "license" for more information.
>>> search_opts.get("vm_state") == ['deleted']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'search_opts' is not defined
>>> search_opts = {'vm_state': 'deleted'}
>>> search_opts.get("vm_state") == ['deleted']
False
>>>

Changed in nova:
assignee: nobody → jichenjc (jichenjc)
Revision history for this message
jichenjc (jichenjc) wrote :

seems we both allow vm_state from REST API layer and internally we might transfer it to a dict
so it's a little bit weird ,need dig more

Revision history for this message
jichenjc (jichenjc) wrote :

jichen@kolla:~$ env | grep OS_
OS_REGION_NAME=RegionOne
OS_AUTH_PLUGIN=password
OS_USER_DOMAIN_NAME=Default
OS_PROJECT_NAME=demo
OS_IDENTITY_API_VERSION=3
OS_PASSWORD=demo2
OS_USERNAME=demo2
OS_TENANT_NAME=demo

jichen@kolla:~$ openstack token issue
+------------+----------------------------------+
| Field | Value |
+------------+----------------------------------+
| expires | 2018-09-04T04:44:35+0000 |
| id | 8efb8c4dd97a4360b7bf102899082450 |
| project_id | 31b899dfac9241708d58c746852af793 |
| user_id | 181c100ac05e4bcfa3a4d5bca79a6120 |
+------------+----------------------------------+

jichen@kolla:~$ curl -g -i -X GET http://9.115.112.77:8774/v2.1/31b899dfac9241708d58c746852af793/servers/detail?vm_state=DELETED -H "Accept: application/json" -H "OpenStack-API-Version: compute 2.60" -H "User-Agent: python-novaclient" -H "X-Auth-Token: 8efb8c4dd97a4360b7bf102899082450" -H "X-OpenStack-Nova-API-Version: 2.60"
HTTP/1.1 200 OK
Content-Length: 15
Content-Type: application/json
Openstack-Api-Version: compute 2.60
X-Openstack-Nova-Api-Version: 2.60
Vary: OpenStack-API-Version
Vary: X-OpenStack-Nova-API-Version
X-Openstack-Request-Id: req-0688e4bb-e1d2-422a-acbf-89614cc6dadf
X-Compute-Request-Id: req-0688e4bb-e1d2-422a-acbf-89614cc6dadf
Date: Tue, 04 Sep 2018 03:47:28 GMT

{"servers": []}

expect to see a 403 due to
https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/servers.py#L178

but got a 200

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

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

Change abandoned by Stephen Finucane (<email address hidden>) on branch: master
Review: https://review.opendev.org/599492

Eric Fried (efried)
Changed in nova:
status: In Progress → New
assignee: jichenjc (jichenjc) → nobody
Revision history for this message
Artom Lifshitz (notartom) wrote :

Looks like you found a potentially issue and are digging into it (thanks!), but for this to be a valid bug report, it would be very helpful to follow the template of "I did X, I expected Y, instead I got Z", with details of the steps you did, what was the expected behaviour, and what you actually saw for X, Y and Z.

Changed in nova:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for OpenStack Compute (nova) because there has been no activity for 60 days.]

Changed in nova:
status: Incomplete → Expired
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.