Bug 2154512

Summary: Katello API activation_key/:id/product_content does not expose per_page
Product: Red Hat Satellite Reporter: Beat Rubischon <beat>
Component: APIAssignee: Evgeni Golov <egolov>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.12.0CC: ahumbe, akapse, egolov, pcreech
Target Milestone: 6.13.0Keywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: rubygem-katello-4.7.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2158575 (view as bug list) Environment:
Last Closed: 2023-05-03 13:23:43 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:
Embargoed:

Description Beat Rubischon 2022-12-17 10:51:38 UTC
Description of problem:

Katello's API documentation doesn't expose paging in /katello/api/activation_keys/:id/product_content [1]. This limits the theforeman.foreman.activation_key Ansible module [2] to a maximum of 20 products - in case you have more, the module doesn't know about all products and is no longer idempotent. The same is true for hammer, it shows about additional pages, but doesn't accept to page or increase the page size. This becomes painful when creating keys for Library, Organization View on a Red Hat Satellite with Simple Content Access enabled.

[1] https://theforeman.org/plugins/katello/3.17/api/apidoc/v2/activation_keys/product_content.html
[2] https://docs.ansible.com/ansible/latest/collections/theforeman/foreman/activation_key_module.html

From my understanding it's sufficient to announce the per_page and page parameters in the API documentation to make apypie aware of the parameters. I'm not sure if hammer needs special treating.

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

Red Hat Satellite >= 6.12

How reproducible:

always

Steps to Reproduce:
1. Make sure the Satellite has more then 20 active Red Hat repositories
2. Create an ActivationKey following the example in https://docs.ansible.com/ansible/latest/collections/theforeman/foreman/activation_key_module.html
3. Rerun the Ansible play

Actual results:

The module isn't idempotent since it is not capable of fetching more then 20 product entries from the existing ActivationKey

Expected results:

The module fetches all product entries and is idempotent

Additional info:

The same issue exists in hammer:

# hammer -d activation-key product-content --id=1 --organization=Default --content-access-mode-all true --content-access-mode-env false

-----|-----------------------------------------------------------------------|------------------------------------------|------------------|----------
ID   | NAME                                                                  | LABEL                                    | DEFAULT ENABLED? | OVERRIDE 
-----|-----------------------------------------------------------------------|------------------------------------------|------------------|----------
4822 | Red Hat Enterprise Linux 7 Server (Kickstart)                         | rhel-7-server-kickstart                  | no               |          
4848 | Red Hat Enterprise Linux 7 Server (RPMs)                              | rhel-7-server-rpms                       | yes              | enabled:0
3015 | Red Hat Enterprise Linux 8 for x86_64 - AppStream (Kickstart)         | rhel-8-for-x86_64-appstream-kickstart    | no               |          
-----|-----------------------------------------------------------------------|------------------------------------------|------------------|----------
Page 1 of 2 (use --page and --per-page for navigation).

Comment 2 Lukáš Hellebrandt 2023-02-02 16:20:30 UTC
1) Tried listing product content in AK using API and Hammer. In both cases, a full list was returned with proper pagination.
2) APIdoc correctly contains information about per_page: and page: attributes.
3) The playbook is de-facto idempotent since it only creates the AK once, and with proper overrides. However, the task is still marked as "changed" when run repeatedly.

=> VERIFYING this BZ since it's about API and docs, point 3) should be fixed in snap 8.0 and is tracked in bug 2134605.

Comment 5 errata-xmlrpc 2023-05-03 13:23:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.13 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2097