test_list_servers_filter_by_zero_limit fails with DB2

Bug #1296929 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Matt Riedemann

Bug Description

Tempest test test_list_servers_filter_by_zero_limit does a server list query with limit=0 which is OK with MySQL and PostgreSQL but not with DB2 since DB2's fetch-first clause doesn't support values < 1:

http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0059212.html?resultof=%22%46%45%54%43%48%22%20%22%66%65%74%63%68%22%20%22%66%69%72%73%74%22%20

From the DB2 doc:

"The fetch-first-clause lets the database manager know that the application does not want to retrieve more than integer rows, regardless of how many rows there might be in the result table when this clause is not specified. An attempt to fetch beyond integer rows is handled the same way as normal end of data (SQLSTATE 02000). The value of integer must be a positive integer (not zero)."

Looking at the Nova API paginate collections docs:

http://docs.openstack.org/api/openstack-compute/2/content/Paginated_Collections-d1e664.html

It doesn't say anything about lower bounds validation, only that over limit is a 413 HTTP error response. Otherwise the examples use limit=1.

There isn't really any point of allowing the query to get down into the DB API layer just to perform a query and then remove the results, so we should just detect limit == 0 in the nova API layer and just return an empty response.

Tags: api db2
Revision history for this message
Matt Riedemann (mriedem) wrote :

Here is where nova API checks for request limit < 0:

https://github.com/openstack/nova/blob/2014.1.b3/nova/api/openstack/common.py#L210

and get_limit_and_marker is used by the servers API:

https://github.com/openstack/nova/blob/2014.1.b3/nova/api/openstack/common.py#L222

https://github.com/openstack/nova/blob/2014.1.b3/nova/api/openstack/compute/servers.py#L595

So it would be easy enough to just detect limit == 0 in the servers API (v2 and v3) and handle it there by returning instance_list = [].

Matt Riedemann (mriedem)
Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)
status: New → Triaged
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/82697

Changed in nova:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/82697
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=d63a7012d221753de71dd2c3fd8c1dcde15a33c3
Submitter: Jenkins
Branch: master

commit d63a7012d221753de71dd2c3fd8c1dcde15a33c3
Author: Matt Riedemann <email address hidden>
Date: Mon Mar 24 14:43:23 2014 -0700

    Bypass the database if limit=0 for server-list requests

    Not all database engines handle fetching 0 rows the same and there isn't
    really a point in going to the database to return nothing, so bypass the
    DB query if limit=0.

    The Nova API is explicitly checking if limit >= 0 so we can't make any
    changes there since they would be backwards incompatible, i.e. to start
    enforcing limit > 0.

    Closes-Bug: #1296929

    Change-Id: Ib3d0318bec972af5f1f25202101e76066f930f34

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-1 → 2014.2
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.