cannot filter the list servers to show only those that does not have config drive

Bug #1871409 reported by Balazs Gibizer
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
Medium
Balazs Gibizer

Bug Description

The server's config_drive field is "True" if there is a config drive attached to the server and an empty string if there is no config drive attached. Nova API allow filtering the list of servers returned by GET /servers/details by config_drive, but the API does not allow specifying an empty string in the filter. So there is no way to filter for servers without config drive.

stack@aio:~$ curl -g -i -X GET 'http://192.168.121.129/compute/v2.1/servers/detail?config_drive=&' -H "Accept: application/json" -H "OpenStack-API-Version: compute 2.83" -H "User-Agent: python-novaclient" -H "X-Auth-Token: $TOKEN" -H "X-OpenStack-Nova-API-Version: 2.83"
HTTP/1.1 400 Bad Request
Date: Tue, 07 Apr 2020 14:35:24 GMT
Server: Apache/2.4.29 (Ubuntu)
OpenStack-API-Version: compute 2.83
X-OpenStack-Nova-API-Version: 2.83
Vary: OpenStack-API-Version,X-OpenStack-Nova-API-Version
Content-Type: application/json; charset=UTF-8
Content-Length: 121
x-openstack-request-id: req-7d10c44b-9c9b-463e-8cbc-99f5bd68390a
x-compute-request-id: req-7d10c44b-9c9b-463e-8cbc-99f5bd68390a
Connection: close

{"badRequest": {"code": 400, "message": "Invalid input for query parameters config_drive. Value: . '' is not a 'regex'"}}

stack@aio:~$

Tags: api
tags: added: api
Changed in nova:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Balazs Gibizer (balazs-gibizer)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/718140

Changed in nova:
status: Triaged → In Progress
Revision history for this message
Balazs Gibizer (balazs-gibizer) wrote :

Long discussion on IRC[1]. Bottom line:
* config_drive field in db allows for String(255)
* sean-k-mooney remembers that there is some downstream rackspace dependency that use this to store a uuid of a volume
* the Nova API GET /server/details response defines config_drive as either "True" or "" (empty string) with the meaning of False
* the query filter GET/server/details?config_drive= is rejected today by the schema and directly fixing it would spread the empty string crazyness. Using True and False instead would make a confusion with the GET rsp and might break rackspace
=> API + DB cleanup is needed. Item added to https://etherpad.openstack.org/p/nova-api-cleanup L86

[1] http://eavesdrop.openstack.org/irclogs/%23openstack-nova/%23openstack-nova.2020-04-07.log.html#t2020-04-07T14:37:00

Revision history for this message
Balazs Gibizer (balazs-gibizer) wrote :

the reason we have a String(255) field in the db is historical, see https://bugs.launchpad.net/python-novaclient/+bug/1314395

Revision history for this message
Brin Zhang (zhangbailin) wrote :

I think we can enable config_drive to True/False, only a boolean type, that in:

* Create Server ``POST /servers`` API, request config_drive is boolean type [1], it's parameter type is boolean
* List Servers Detailed ``GET /servers/detail`` API, return "config_drive": "" [2], it's parameter type is string
* Show Server Details ``GET /servers/{server_id}`` API, return "config_drive": "" [2], it's parameter type is string

We have already done boolean verification when the request was created, IMO the response can be consistent.
This way we need to change the nova api, that need to add a micorversion to support, => https://etherpad.openstack.org/p/nova-api-cleanup L86.

[1]https://opendev.org/openstack/nova/src/branch/master/api-ref/source/parameters.yaml#L2079-L2089
[2]https://opendev.org/openstack/nova/src/branch/master/api-ref/source/parameters.yaml#L2097-L2104

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.