Bug 2159776

Summary: Unable to change download_policy to on_demand if the Red Hat Repository has any checksum_type set in Satellite
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: RepositoriesAssignee: Samir Jha <sajha>
Status: CLOSED ERRATA QA Contact: Cole Higgins <chiggins>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.11.4CC: ahumbe, pcreech, sajha
Target Milestone: 6.13.0Keywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-katello-4.7.0.5-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2184130 (view as bug list) Environment:
Last Closed: 2023-05-03 13:24:04 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 Sayan Das 2023-01-10 17:17:44 UTC
Description of problem:

Execution of "foreman-rake katello:change_download_policy DOWNLOAD_POLICY=on_demand" or UI action "Content > products > select "Product" > select "repository" > select "Download Policy" > choose on_demand" to change the download policy fails for Red Hat repos if they had "Yum Metadata Checksum" value set to sha1 or sha256 instead of Default.


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

Satellite 6.11 ( basically 6.10 and 6.13 as well )


How reproducible:

Always, when repository download policy is Immediate and checksum_type is set as sha1 or sha256 sum


Steps to Reproduce:
1. Install a Satellite 6.11 and enable a few Red Hat repos.
2. Change their download policy to Immediate and sync them.
3. Use any rake\DB hack to check checksum_type to sha1 or sha256 for any of those repos.
   e.g. it should look like 

# echo "select id,name,download_policy,checksum_type,pulp_scratchpad_checksum_type from katello_root_repositories;" | su - postgres -c "psql foreman"
. id  |                                                  name                                                  | download_policy | checksum_type | pulp_scratchpad_checksum_type
-----+--------------------------------------------------------------------------------------------------------+-----------------+---------------+-------------------------------
   4 | Red Hat Enterprise Linux 7 Server - RH Common RPMs x86_64 7Server                                      | immediate       | sha256        |
   6 | Red Hat Enterprise Linux 7 Server - Extras RPMs x86_64                                                 | immediate       | sha1          |
  26 | Red Hat Software Collections RPMs for Red Hat Enterprise Linux 7 Server x86_64 7Server                 | immediate       | sha1          |


4. Now either try executing "foreman-rake katello:change_download_policy DOWNLOAD_POLICY=on_demand" 

   Or, From Ui go to , Content > products > select "Product" > select "repository" > select "Download Policy" > choose on_demand" to change the download policy


Actual results:


2023-01-08T19:05:43 [I|bac|1cffb129] Task {label: , id: f99a7fa6-d705-4da6-8f94-8404f49df7f5, execution_plan_id: b1f66ded-3d58-405e-9326-9c62826b2302} state changed: pending 
2023-01-08T19:05:43 [I|bac|1cffb129] Task {label: Actions::Katello::Repository::Update, id: f99a7fa6-d705-4da6-8f94-8404f49df7f5, execution_plan_id: b1f66ded-3d58-405e-9326-9c62826b2302} state changed: planning 
2023-01-08T19:05:43 [E|bac|1cffb129] Validation failed: Checksum type Checksum type cannot be set for yum repositories with on demand download policy. (ActiveRecord::RecordInvalid)


And no way to change the "checksum_type" value from Satellite UI or hammer.


Expected results:

* We should be able to change the "checksum_type" in an acceptable way via UI or hammer.

* The "katello:change_download_policy" should be improved to handle the unsettling of checksum_type before changing the download_policy.


Additional info:

* This issue can be fixed for any custom repos as Satellite allows changing the checksum_type or "Yum Metadata Checksum" value to "Default" 

* For Red Hat repos, 

  ** From UI, we have no option to edit\set the "Yum Metadata Checksum"

  ** A command like "hammer repository update --id 79 --checksum-type 'sha1' --download-policy immediate" gets successfully executed but cannot set\unset the checksum ( here it's just an example to set sha1 as the value ).

Comment 3 Samir Jha 2023-01-16 14:56:57 UTC
Created redmine issue https://projects.theforeman.org/issues/35953 from this bug

Comment 11 errata-xmlrpc 2023-05-03 13:24:04 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