cinder v2 volume list API does not create "next" link correctly for pagination

Bug #1350558 reported by Mingyan Bao
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Vincent Hou

Bug Description

According to the pagination documentation at http://docs.openstack.org/api/openstack-compute/2/content/Paginated_Collections-d1e664.html, The "next" link should only be provided if there are more items after the current page.

However the "next" link is provided if the returned number of items is exactly the page size, i.e if there are 3 volumes, the following query will list all 3 volumes, but also give a "next" link for more volumes, which if used, retrieves 0 items.

This makes it hard to try and do pagination for clients like Horizon.

Example query:
http://192.168.48.130:8776/v2/d005c0dcb1ea426b82da6160ab03ae22/volumes?limit=3

Response:
{
    "volumes_links": [{
        "href": "http://192.168.48.130:8776/v2/d005c0dcb1ea426b82da6160ab03ae22/volumes?limit=3&marker=c08b1929-e206-41f8-93d1-5cd5eb77394f",
        "rel": "next"
    }],
    "volumes": [{
        "id": "2d9e16f9-a758-4075-bb8f-78d4a3321a4f",
        "links": [{
            "href": "http://192.168.48.130:8776/v2/d005c0dcb1ea426b82da6160ab03ae22/volumes/2d9e16f9-a758-4075-bb8f-78d4a3321a4f",
            "rel": "self"
        }, {
            "href": "http://192.168.48.130:8776/d005c0dcb1ea426b82da6160ab03ae22/volumes/2d9e16f9-a758-4075-bb8f-78d4a3321a4f",
            "rel": "bookmark"
        }],
        "name": "vol10"
    }, {
        "id": "ead262df-f2b4-423d-9652-29fa2b5aa78f",
        "links": [{
            "href": "http://192.168.48.130:8776/v2/d005c0dcb1ea426b82da6160ab03ae22/volumes/ead262df-f2b4-423d-9652-29fa2b5aa78f",
            "rel": "self"
        }, {
            "href": "http://192.168.48.130:8776/d005c0dcb1ea426b82da6160ab03ae22/volumes/ead262df-f2b4-423d-9652-29fa2b5aa78f",
            "rel": "bookmark"
        }],
        "name": "vol9"
    }, {
        "id": "c08b1929-e206-41f8-93d1-5cd5eb77394f",
        "links": [{
            "href": "http://192.168.48.130:8776/v2/d005c0dcb1ea426b82da6160ab03ae22/volumes/c08b1929-e206-41f8-93d1-5cd5eb77394f",
            "rel": "self"
        }, {
            "href": "http://192.168.48.130:8776/d005c0dcb1ea426b82da6160ab03ae22/volumes/c08b1929-e206-41f8-93d1-5cd5eb77394f",
            "rel": "bookmark"
        }],
        "name": "vol8"
    }]
}

summary: - cinder volume list API does not create "next" link correctly for
+ cinder v2 volume list API does not create "next" link correctly for
pagination
Vincent Hou (houshengbo)
Changed in cinder:
assignee: nobody → Vincent Hou (houshengbo)
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/131915

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

Reviewed: https://review.openstack.org/131915
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=5d8cf41bc2122d271af4ba7988fc3fd39f02e987
Submitter: Jenkins
Branch: master

commit 5d8cf41bc2122d271af4ba7988fc3fd39f02e987
Author: Vincent Hou <email address hidden>
Date: Wed Oct 29 01:40:31 2014 -0700

    Remove the useless next link for volumes, transfers and backups

    Two cases this patch will resolve:
    1) Currently if the number of items equals the osapi_max_limit or
    the last page of items equals the osapi_max_limit without the
    parameter limit set in the user request, a next link is generated
    in the response, though this next link will return empty volume
    list. In fact it is unnecessary to generate the next link in
    this case.

    2) If the number of items equals the osapi_max_limit and limit is
    greater than osapi_max_limit, a next link is generated. Actually,
    the next link does not need to be generated, because it is certain
    that there is no more volumes left in the database.

    The method _get_collection_links has been called in volumes,
    volume_transfers and backups. The patch can only affect the next
    link generation for three of them. However, other lists like
    consistency groups, qos specs, cgsnapshots have not implemented the
    generation for the next link. Potentially this can be a wishlist
    item for them.

    Change-Id: I0f1f449c73d51675281497a095d869c1e72c889f
    closes-bug: #1350558

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
milestone: none → kilo-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: kilo-3 → 2015.1.0
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.