Bug 1038273

Summary: List Pools API Paging Broken
Product: [Community] Candlepin Reporter: Jonathon Turel <jturel>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.9CC: bkearney
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-22 14:40:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jonathon Turel 2013-12-04 19:03:08 UTC
Description of problem:

When calling /owners/<key>/pools with paging the expected results are not returned beyond the first page. Instead, we get an empty page.

The following output was generated by API calls in RHSM Web:

all available,matching pools for a consumer (no paging)
Fetching pools: /owners/5394945/pools?consumer=0cb583db-d949-4316-a37f-adbab3ff2132&listall=false&
Got pools: 19

Using paging: first page, ten per:
Fetching pools: /owners/5394945/pools?consumer=0cb583db-d949-4316-a37f-adbab3ff2132&listall=false&page=1&per_page=10&
Got pools: 10


The above is well and fine. Then we look at the link headers we get back:
Server: Apache-Coyote/1.1
X-Candlepin-Version: 0.8.28.1-1
Link: <https://subscription.rhn.qa.redhat.com/subscription/consumers//owners/5394945/pools?per_page=10&listall=false&consumer=0cb583db-d949-4316-a37f-adbab3ff2132&page=1>; rel="first", <https://subscription.rhn.qa.redhat.com/subscription/consumers//owners/5394945/pools?per_page=10&listall=false&consumer=0cb583db-d949-4316-a37f-adbab3ff2132&page=1>; rel="last"
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 03 Dec 2013 21:19:43 GMT

Notice

1) It says the last page is page 1. There are 9 results not returned on the first page as queried. They should be on page 2 which would also be the last page

2) The URL given back is not correct: /consumers//owners
It'd be nice if we were given a [correct] URL which began at /owners and did not include the whole hostname since we do not talk to subscription.rhn.redhat.com within rhsm-web.

3) Querying directly for page 2, one would expect to get the remaining 9 pools back, but it is an empty page.


Version-Release number of selected component (if applicable): 0.8.28


How reproducible: Always


Steps to Reproduce:
1. Configure a consumer to have some available pools
2. Call candlpin /owners/<key>/pools API with paging such that per_page is < the total available bools

Actual results:
Beyond the first page the data is not returned correctly -> the pages are empty. The link headers are also incorrect.

Expected results:
pages > 1 should have the correct (non-empty) data if it exists. Link headers should be accurate.


Additional info: We plan to enable paging for pools, entitlements, and consumers in RHSM web. Please review these other APIS to ensure they do not have these same issues.

Comment 1 Carter Kozak 2013-12-18 21:03:11 UTC
commit 7542d379d7f1972bdb9c249fe704bc56a0990a15
Author: ckozak <ckozak>
Date:   Tue Dec 17 15:04:43 2013 -0500

    1038273: correctly paginate when listing pools by consumer
    
    It looks like we forgot to take advantage of the postFilter
    method in AbstractHibernateCurator.
    
    OwnerResource does postfiltering when a consumer is supplied,
    otherwise we don't filter based on the rules.

Comment 3 Mike McCune 2016-03-28 22:20:08 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 4 Barnaby Court 2016-07-22 14:40:11 UTC
Moving to closed per the updated candlepin process for bugs that have been merged or have been taken care of.