The created_at and updated_at filters don't work with a postgresql db
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance |
New
|
Undecided
|
Unassigned | ||
Bug Description
When listing images, several optional parameters can be used to filter the list of images retrieved by the API, these parameters can be found in the API documentation (http://
These created_at and updated_at parameters can be used in the following two ways:
- Without specifying an operator (which defaults to an eq operator)
e.g. /v2/images?
Note: This is currently not working, see bug https:/
- With an operator (using one of these: eq, new, lt, lte, gt, gte)
e.g. /v2/images?
This works as documented when run in an OpenStack environment that has the default backend DataBase of Mysql, but if the environment has a Postgresql database the created_at and updated_at filters always return empty lists even when the filter criteria matches existing images.
Steps to reproduce:
1) Install a devstack environment with the default db backend (mysql).
2) Try listing the images using the created_at or updated_at parameters, using an operator and using the DateTime stamp of an existing image. Like this: /v2/images?
Expected Results: Glance API should return a list with 1 or more images that match the filter criteria.
3) Install a devstack environment with the postgresql DB backend (https:/
4) Try listing the images again using the same API call used in step 2 against the new environment.
Expected Results: Glance API should work the same as with the mysql DB returning a list of 1 or more images that match the filter criteria.
Actual Results: An empty list is always returned, even when the filter matches existing images.
Extra note: You can also reproduce this bug using the parameters without using an operator but you would need to use the patch https:/
Now that bug 1584415 (https:/ /bugs.launchpad .net/glance/ +bug/1584415) has been closed, looks like it only got fixed for MySQL DB backend.
So as an update for this bug, trying to filter images by using the created_at and updated_at parameters fail when the DB backend is Postgresql regardless of if the date includes an operation or not:
1) Using only date without an operator: created_ at=2016- 04-18T21: 38:55Z
/v2/images?
Results in a 400 Bad Request error: Bad "created_at" query filter format. Use ISO 8601 DateTime notation.
2) Using date plus operator: created_ at=lte: 2016-04- 18T21:38: 55Z
/v2/images?
Looks like depending on the operator we get different results:
+ using eq: Doesn't work. Results in an empty list even when there are images that match the criteria.
+ using lt: Seems to be working fine. Lists the images that match only the "less than" condition.
+ using lte: Doesn't work. It only lists the images that match the "less than" condition and ignores the "equal" condition.
+ using gt: Doesn't work. It lists the images that match the "greater than" condition but also the "equal".
+ using gte: Seems to be working fine. It lists the images that match the "greater than" condition and the "equal" condition.