No 'next' link provided when GET'ing the maximum number of items

Bug #1250804 reported by Lucas Alvares Gomes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
High
Ruby Loo

Bug Description

When GET'ing items from a collection with no limit parameter specified the API should get limit value from the configuration file (default is 1000). But when we reach this number the API is not returning a 'next' link to retrieve the next subset of items (in case there's more >= 1000 items registered)

To reproduce:

1- Create 1000 nodes (or chassis or ports)
2 - GET /v1/nodes

Output:

stack@stack-virtual-machine:~/devstack$ curl -X GET http://0.0.0.0:6385/v1/nodes | python -mjson.tool | grep next
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 370k 100 370k 0 0 1224k 0 --:--:-- --:--:-- --:--:-- 1230k
stack@stack-virtual-machine:~/devstack$

Changed in ironic:
assignee: nobody → Lucas Alvares Gomes (lucasagomes)
summary: - No 'next' provided when GET'ing the maximum number of items in the API
+ No 'next' link provided when GET'ing the maximum number of items
Changed in ironic:
assignee: Lucas Alvares Gomes (lucasagomes) → nobody
Ruby Loo (rloo)
Changed in ironic:
assignee: nobody → Ruby Loo (rloo)
Ruby Loo (rloo)
Changed in ironic:
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

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

Changed in ironic:
status: Confirmed → In Progress
aeva black (tenbrae)
Changed in ironic:
importance: Undecided → High
Revision history for this message
aeva black (tenbrae) wrote :

This issue also appears if the requested limit=N value is greater than the API max_limit setting, but it does not appear if the requested limit equals the max_api value! To test this, I set max_limit = 10, then registered more than 10 nodes, and issued several requests...

$ curl -s 'http://192.0.2.2:6385/v1/nodes?limit=5' |json_pp > x && echo "Num nodes: $(grep -c power_state x)" && echo "Has next link? $(grep -c next x)"
Num nodes: 5
Has next link? 1

$ curl -s 'http://192.0.2.2:6385/v1/nodes?limit=10' |json_pp > x && echo "Num nodes: $(grep -c power_state x)" && echo "Has next link? $(grep -c next x)"
Num nodes: 10
Has next link? 1

$ curl -s 'http://192.0.2.2:6385/v1/nodes' |json_pp > x && echo "Num nodes: $(grep -c power_state x)" && echo "Has next link? $(grep -c next x)"
Num nodes: 10
Has next link? 0

$ curl -s 'http://192.0.2.2:6385/v1/nodes?limit=20' |json_pp > x && echo "Num nodes: $(grep -c power_state x)" && echo "Has next link? $(grep -c next x)"
Num nodes: 10
Has next link? 0

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (master)

Reviewed: https://review.openstack.org/62743
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=e8fa75647c9dc5dd10fc5590b214140859534ecc
Submitter: Jenkins
Branch: master

commit e8fa75647c9dc5dd10fc5590b214140859534ecc
Author: Ruby Loo <email address hidden>
Date: Tue Dec 17 19:13:24 2013 +0000

    Add 'next' link when GET maximum number of items

    When GET'ing items from a collection with no limit parameter specified
    in the request, the API gets the limit value from the configuration file
    (default is max_limit=1000). However, in the case where there are more
    than max_limit items, the API was not returning a 'next' link to retrieve
    the next subset of items.

    It turns out that the max_limit value wasn't being passed to the
    *Collection.convert_with_links method. This fixes that issue by moving
    the collection call into the same method that determines the limit value.

    Change-Id: I81e734a951e4025f64a5d572656d627e4126b353
    Closes-Bug: #1250804

Changed in ironic:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ironic:
milestone: none → icehouse-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ironic:
milestone: icehouse-2 → 2014.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.