Bug 2244616

Summary: hammer subscription content-override applies the change to all repository sets
Product: Red Hat Satellite Reporter: Pavel Moravec <pmoravec>
Component: Subscription ManagementAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED MIGRATED QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: low Docs Contact:
Priority: medium    
Version: 6.13.0CC: ahumbe, ajambhul, jlenz, ofedoren
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, Triaged, WorkAround
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-06 16:30:57 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 Pavel Moravec 2023-10-17 10:54:30 UTC
Description of problem:
An attempt to change (via hammer) one Repository Set enabled on a Host does alter the setting for all Repository Sets.

Example:

hammer> host subscription product-content --content-access-mode-all 1 --host-id 2
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
ID   | NAME                                                        | LABEL                                             | DEFAULT ENABLED? | OVERRIDE 
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
6401 | Red Hat Ansible Engine 2 for RHEL 8 x86_64 (RPMs)           | ansible-2-for-rhel-8-x86_64-rpms                  | no               | 
371  | Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)    | rhel-8-for-x86_64-appstream-rpms                  | yes              | 
440  | Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)       | rhel-8-for-x86_64-baseos-rpms                     | yes              | 
364  | Red Hat Satellite Client 6 for RHEL 8 x86_64 (RPMs)         | satellite-client-6-for-rhel-8-x86_64-rpms         | no               | 
hammer>

being changed via:

hammer> host subscription content-override --content-label satellite-client-6-for-rhel-8-x86_64-rpms --enabled true --value 1 --host-id 2
Updated content override.

applies the change to *everything* :

hammer> host subscription product-content --content-access-mode-all 1 --host-id 2
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
ID   | NAME                                                        | LABEL                                             | DEFAULT ENABLED? | OVERRIDE 
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
6401 | Red Hat Ansible Engine 2 for RHEL 8 x86_64 (RPMs)           | ansible-2-for-rhel-8-x86_64-rpms                  | no               | enabled:1
371  | Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)    | rhel-8-for-x86_64-appstream-rpms                  | yes              | enabled:1
440  | Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)       | rhel-8-for-x86_64-baseos-rpms                     | yes              | enabled:1
364  | Red Hat Satellite Client 6 for RHEL 8 x86_64 (RPMs)         | satellite-client-6-for-rhel-8-x86_64-rpms         | no               | enabled:1
hammer>


The reason is hidden in parameters hammer used:

2023-10-17T12:45:14 [I|app|eb7ad4a2] Started PUT "/api/hosts/2/subscriptions/content_override" for 1.2.3.4 at 2023-10-17 12:45:14 +0200
2023-10-17T12:45:14 [I|app|eb7ad4a2] Processing by Katello::Api::V2::HostSubscriptionsController#content_override as JSON
2023-10-17T12:45:14 [I|app|eb7ad4a2]   Parameters: {"content_overrides_search"=>{"enabled"=>true}, "content_overrides"=>[{"content_label"=>"satellite-client-6-for-rhel-8-x86_64-rpms", "value"=>"[FILTERED]", "name"=>"enabled"}], "api_version"=>"v2", "host_id"=>"2", "host_subscription"=>{"content_overrides_search"=>{"enabled"=>true}, "content_overrides"=>[{"content_label"=>"satellite-client-6-for-rhel-8-x86_64-rpms", "value"=>"[FILTERED]", "name"=>"enabled"}]}}

So any repository set matching the filter in content_overrides_search will be changed.

OK, maybe this is just a hammer UX bug and hammer assumes --search option to be *extra* used? (already an UX bug I would say since --content-label is mandatory option so why to provide the same info "I wanna scope the change to .." also somewhere else?). So let reset everything and retry:

hammer> host subscription product-content --content-access-mode-all 1 --host-id 2
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
ID   | NAME                                                        | LABEL                                             | DEFAULT ENABLED? | OVERRIDE 
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
6401 | Red Hat Ansible Engine 2 for RHEL 8 x86_64 (RPMs)           | ansible-2-for-rhel-8-x86_64-rpms                  | no               | 
371  | Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)    | rhel-8-for-x86_64-appstream-rpms                  | yes              | 
440  | Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)       | rhel-8-for-x86_64-baseos-rpms                     | yes              | 
364  | Red Hat Satellite Client 6 for RHEL 8 x86_64 (RPMs)         | satellite-client-6-for-rhel-8-x86_64-rpms         | no               | 
hammer>
hammer> host subscription content-override --content-label satellite-client-6-for-rhel-8-x86_64-rpms --enabled true --value 1 --host-id 2 --search "label = satellite-client-6-for-rhel-8-x86_64-rpms"
Updated content override.
hammer> 
hammer> host subscription product-content --content-access-mode-all 1 --host-id 2
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
ID   | NAME                                                        | LABEL                                             | DEFAULT ENABLED? | OVERRIDE 
-----|-------------------------------------------------------------|---------------------------------------------------|------------------|----------
6401 | Red Hat Ansible Engine 2 for RHEL 8 x86_64 (RPMs)           | ansible-2-for-rhel-8-x86_64-rpms                  | no               | 
371  | Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)    | rhel-8-for-x86_64-appstream-rpms                  | yes              | 
440  | Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)       | rhel-8-for-x86_64-baseos-rpms                     | yes              | 
364  | Red Hat Satellite Client 6 for RHEL 8 x86_64 (RPMs)         | satellite-client-6-for-rhel-8-x86_64-rpms         | no               | enabled:1
hammer>

with parameters used:

2023-10-17T12:48:48 [I|app|1059352e] Started PUT "/api/hosts/2/subscriptions/content_override" for 1.2.3.4 at 2023-10-17 12:48:48 +0200
2023-10-17T12:48:48 [I|app|1059352e] Processing by Katello::Api::V2::HostSubscriptionsController#content_override as JSON
2023-10-17T12:48:48 [I|app|1059352e]   Parameters: {"content_overrides_search"=>{"search"=>"label = satellite-client-6-for-rhel-8-x86_64-rpms", "enabled"=>true}, "content_overrides"=>[{"content_label"=>"satellite-client-6-for-rhel-8-x86_64-rpms", "value"=>"[FILTERED]", "name"=>"enabled"}], "api_version"=>"v2", "host_id"=>"2", "host_subscription"=>{"content_overrides_search"=>{"search"=>"label = satellite-client-6-for-rhel-8-x86_64-rpms", "enabled"=>true}, "content_overrides"=>[{"content_label"=>"satellite-client-6-for-rhel-8-x86_64-rpms", "value"=>"[FILTERED]", "name"=>"enabled"}]}}


Please make the --content-label optional (to lead users to use --search instead to limit the scope of the change), and/or apply the --content-label value into the search itself.


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


How reproducible:
100%


Steps to Reproduce:
1. See above reproducer steps


Actual results:
host subscription content-override --content-label <LABEL>   applies the change unsocped, to any repo set


Expected results:
host subscription content-override --content-label <LABEL>    should apply the change just to the label
and/or
host subscription content-override --search ..                is allowed (--content-label is not mandatory)


Additional info:

Comment 1 Oleh Fedorenko 2023-10-17 13:16:13 UTC
Not sure if Subscription Management is right component. Moving is based on the first subcommand.

Comment 8 Eric Helms 2024-06-06 16:30:57 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.