Project

General

Profile

Bug #18470

Hammer does not list over 20 item per page for some resources

Added by Tomáš Strachota over 2 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1420503

Description of problem:
Hammer does not list more than 20 items when trying to query all records for some resources.

Version-Release number of selected component (if applicable):
katello 3.3
hammer_cli_foreman 0.9.0

How reproducible:
everytime

Steps to Reproduce:
1.Create 21 lifecycle environments
2.list all LCE with hammer
3.--page and --per-page options don't work

Actual results:

// 21 lifecycles in the environment
[root@sat62 ~]# hammer -p redhat lifecycle-environment list --organization-id=1 
---|---------|--------
ID | NAME    | PRIOR  
---|---------|--------
1  | Library |        
22 | lfc_21  | Library
21 | lfc_20  | Library
20 | lfc_19  | Library
19 | lfc_18  | Library
18 | lfc_17  | Library
17 | lfc_16  | Library
16 | lfc_15  | Library
15 | lfc_14  | Library
14 | lfc_13  | Library
13 | lfc_12  | Library
12 | lfc_11  | Library
11 | lfc_10  | Library
10 | lfc_09  | Library
9  | lfc_08  | Library
8  | lfc_07  | Library
7  | lfc_06  | Library
6  | lfc_05  | Library
5  | lfc_04  | Library
4  | lfc_03  | Library
---|---------|--------
Page 1 of 2 (use --page and --per-page for navigation)
[root@sat62 ~]#

// It's not possible to see the flags --per-page or --page
[root@sat62 ~]# hammer -p redhat lifecycle-environment list --organization-id=1 --help
Usage:
    hammer lifecycle-environment list [OPTIONS]

Options:
 --library LIBRARY                       set true if you want to see only library environments
                                         Possible value(s): 'true', 'false'
 --name NAME                             filter only environments containing this name
 --organization ORGANIZATION_NAME        Organization name to search by
 --organization-id ORGANIZATION_ID       organization ID
 --organization-label ORGANIZATION_LABEL Organization label to search by
 -h, --help                              print help
[root@sat62 ~]#

// Trying to use --page flag
[root@sat62 ~]# hammer -p redhat lifecycle-environment list --organization-id=1 --page
Error: Unrecognised option '--page'

See: 'hammer lifecycle-environment list --help'
[root@sat62 ~]#

// Trying to use --per-page flag
[root@sat62 ~]# hammer -p redhat lifecycle-environment list --organization-id=1 --per-page
Error: Unrecognised option '--per-page'

See: 'hammer lifecycle-environment list --help'
[root@sat62 ~]#

Expected results:
--page --per-page options should work

Associated revisions

Revision d3e60743 (diff)
Added by Ashish Humbe over 2 years ago

Fixes #18470 - Pagination issue fix

History

#1 Updated by Tomáš Strachota over 2 years ago

  • Subject changed from Hammer does not list over 20 environments per page, ignores config file to Hammer does not list over 20 environments per page, ignores config file
  • Category set to Lifecycle Environments
  • Assignee set to Tomáš Strachota

#2 Updated by Tomáš Strachota over 2 years ago

  • Description updated (diff)

#3 Updated by Tomáš Strachota over 2 years ago

  • Subject changed from Hammer does not list over 20 environments per page, ignores config file to Hammer does not list over 20 item per page for some resources
  • Description updated (diff)
  • Category changed from Lifecycle Environments to API
  • Assignee deleted (Tomáš Strachota)

#4 Updated by Tomáš Strachota over 2 years ago

The problem is in missing api parameters for pagination (page and per_page) in some index actions. Hammer checks whether the options are present and tries to iterate over the pages to get all records. The issue with lifecycle environment controller is that it lacks the params but returns the results paged. That's why only first 20 records is shown.

This should be fixed by adding

param_group :search, Api::V2::ApiController

to index action apidoc.

I looked into the api controllers and there seems to be more resources affected. Fixing this deserves larger audit across whole Katello's API.

#5 Updated by Eric Helms over 2 years ago

  • Legacy Backlogs Release (now unused) set to 219

#6 Updated by The Foreman Bot over 2 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/6633 added

#7 Updated by Eric Helms over 2 years ago

  • Legacy Backlogs Release (now unused) changed from 219 to 211

#8 Updated by The Foreman Bot over 2 years ago

  • Pull request https://github.com/Katello/katello/pull/6668 added

#9 Updated by Ashish Humbe over 2 years ago

  • Pull request deleted (https://github.com/Katello/katello/pull/6633)

#10 Updated by Ashish Humbe over 2 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF