images filtering with Glance image services and PostgreSQL

Bug #943259 reported by Roman Bogorodskiy on 2012-02-29
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
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 -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": []}


curl -i -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": "", "rel": "self"}, {"href": "", "rel": "bookmark"}, {"href": "", "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "tty"}, {"id": "26d6b279-be00-4f1b-b5aa-04019f0cf187", "links": [{"href": "", "rel": "self"}, {"href": "", "rel": "bookmark"}, {"href": "", "type": "application/vnd.openstack.image", "rel": "alternate"}], "name": "tty-ramdisk"}, {"id": "e685e213-50ce-4055-8ad4-084f9df44d58", "links": [{"href": "", "rel": "self"}, {"href": "", "rel": "bookmark"}, {"href": "", "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
root@host:~# glance -A nova index status=active|wc -l

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)

And Glance expects statuses to be lowercase:

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.

Roman Bogorodskiy (novel) wrote :
Brian Waldon (bcwaldon) on 2012-03-01
Changed in nova:
assignee: nobody → Brian Waldon (bcwaldon)
importance: Undecided → Medium
status: New → In Progress
Brian Waldon (bcwaldon) on 2012-03-01
Changed in nova:
milestone: none → essex-rc1

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) on 2012-03-20
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in nova:
milestone: essex-rc1 → 2012.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers