images filtering with Glance image services and PostgreSQL

Bug #943259 reported by Roman Bogorodskiy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Brian Waldon

Bug Description

I have a Nova installation that's configured to use Glance as image service. Glance is configured to use PostgreSQL as a database.

Image listing in Nova doesn't return any images if I filter by status in upper case. Example:

curl -i http://172.18.67.136:8774/v1.1/1/images?status=ACTIVE -X GET -H "X-Auth-Project-Id: admin" -H "User-Agent: python-novaclient" -H "X-Auth-Token: nova"
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 14
Date: Wed, 29 Feb 2012 13:26:21 GMT

{"images": []}

However,

curl -i http://172.18.67.137:8774/v1.1/1/images?status=active -X GET -H "X-Auth-Project-Id: admin" -H "User-Agent: python-novaclient" -H "X-Auth-Token: nova"
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1320
Date: Wed, 29 Feb 2012 13:27:30 GMT

{"images": [{"id": "23e2fb2d-6c1d-40a3-bcf2-825b44a064c4", "links": [{"href": "http://172.18.67.137:8774/v1.1/1/images/23e2fb2d-6c1d-40a3-bcf2-825b44a064c4", "rel": "self"}, {"href": "http://172.18.67.137:8774/1/images/23e2fb2d-6c1d-40a3-bcf2-825b44a064c4", "rel": "bookmark"}, {"href": "http://172.18.67.137:9292/1/images/23e2fb2d-6c1d-40a3-bcf2-825b44a064c4", "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "tty"}, {"id": "26d6b279-be00-4f1b-b5aa-04019f0cf187", "links": [{"href": "http://172.18.67.137:8774/v1.1/1/images/26d6b279-be00-4f1b-b5aa-04019f0cf187", "rel": "self"}, {"href": "http://172.18.67.137:8774/1/images/26d6b279-be00-4f1b-b5aa-04019f0cf187", "rel": "bookmark"}, {"href": "http://172.18.67.137:9292/1/images/26d6b279-be00-4f1b-b5aa-04019f0cf187", "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "tty-ramdisk"}, {"id": "e685e213-50ce-4055-8ad4-084f9df44d58", "links": [{"href": "http://172.18.67.137:8774/v1.1/1/images/e685e213-50ce-4055-8ad4-084f9df44d58", "rel": "self"}, {"href": "http://172.18.67.137:8774/1/images/e685e213-50ce-4055-8ad4-084f9df44d58", "rel": "bookmark"}, {"href": "http://172.18.67.137:9292/1/images/e685e213-50ce-4055-8ad4-084f9df44d58", "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "tty-kernel"}]}

The reason is that PostgreSQL is case sensitive. Glance stores images' statuses in lower case, so filtering by status in upper case doesn't show any result. And nova passes filters as is, the request above doesn't show relevant results. This is not quite right as some API consumers doesn't care much about case of the status.

The problem could be easily reproduced by glance only:

root@host:~# glance -A nova index status=ACTIVE|wc -l
0
root@host:~# glance -A nova index status=active|wc -l
5
root@host:~#

According to the documentation, nova uses uppercase statuses in filters: "In-flight images will have the status attribute set to SAVING and the conditional progress element (0-100% completion) will also be returned. Other possible values for the status attribute include: UNKNOWN, ACTIVE, SAVING, ERROR, and DELETED. " (c) http://docs.openstack.org/api/openstack-compute/2/content/List_Images-d1e4435.html

And Glance expects statuses to be lowercase: http://glance.openstack.org/statuses.html

So appears that the right think would be to convert statuses to lowercase before passing them to Glance.

Attached a patch which fixes the problem for me.

Revision history for this message
Roman Bogorodskiy (novel) wrote :
Brian Waldon (bcwaldon)
Changed in nova:
assignee: nobody → Brian Waldon (bcwaldon)
importance: Undecided → Medium
status: New → In Progress
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/4775

Brian Waldon (bcwaldon)
Changed in nova:
milestone: none → essex-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/4775
Committed: http://github.com/openstack/nova/commit/ff716dee035dd51257b240fad842ecfd70d9d90d
Submitter: Jenkins
Branch: master

commit ff716dee035dd51257b240fad842ecfd70d9d90d
Author: Brian Waldon <email address hidden>
Date: Thu Mar 1 14:51:03 2012 -0800

    Ensure image status filter matches glance format

    * Fixes bug 943259

    Change-Id: Id5172aa40be2f5a337b3e192b4bee8139c16c4d3

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: essex-rc1 → 2012.1
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.