Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2150120 - Upgrade to Satellite 6.12 may fail to apply RemoveDrpmFromIgnorableContent migration if erratum is also a ignorable content type for any repo
Summary: Upgrade to Satellite 6.12 may fail to apply RemoveDrpmFromIgnorableContent mi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Repositories
Version: 6.12.0
Hardware: All
OS: All
high
high
Target Milestone: 6.12.1
Assignee: Samir Jha
QA Contact: Vladimír Sedmík
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-12-01 21:12 UTC by Odilon Sousa
Modified: 2023-01-18 14:53 UTC (History)
3 users (show)

Fixed In Version: rubygem-katello-4.5.0.22-1.el8sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2145240
Environment:
Last Closed: 2023-01-18 14:53:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 35864 0 High Closed Upgrade to 4.5 may fail to apply RemoveDrpmFromIgnorableContent migration if erratum is also a ignorable content type fo... 2023-01-03 10:06:50 UTC
Red Hat Issue Tracker SAT-14070 0 None None None 2022-12-01 21:12:14 UTC
Red Hat Issue Tracker SAT-14177 0 None None None 2022-12-01 21:24:38 UTC
Red Hat Knowledge Base (Solution) 6987408 0 None None None 2022-12-01 21:12:14 UTC
Red Hat Knowledge Base (Solution) 6988713 0 None None None 2022-12-01 21:12:14 UTC
Red Hat Product Errata RHSA-2023:0261 0 None None None 2023-01-18 14:53:28 UTC

Description Odilon Sousa 2022-12-01 21:12:01 UTC
+++ This bug was initially created as a clone of Bug #2145240 +++

Description of problem:

Despite https://bugzilla.redhat.com/show_bug.cgi?id=2055391 was fixed in Satellite 6.12, we only, assumed that we have to deal with "drpm" ignorable content but in some odd cases, "erratum" could also be found mentioned as Ignorable content type for some repos in which case the migration fail to perform root.save! from https://github.com/Katello/katello/pull/9986/files  


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

Satellite 6.12
katello-4.5.0.20

How reproducible:

100% 

Steps to Reproduce:

1. Install satellite 6.11

2. Create a repo by name SLE_12_SP5 under product SLES https://download.opensuse.org/repositories/home:/czanik:/syslog-ng336/SLE_12_SP5/ and enable the "Ignore SRPMs" option for the repo.

3. Now perform the following steps i.e. edit app/lib/actions/katello/repository/update.rb and app/models/katello/root_repository.rb to allow adding drpms and erratum as ignorable content types.

# cd /usr/share/gems/gems/katello-4.3.0.50

# git init .;git add .;git commit -m 'original state'

# vi app/models/katello/root_repository.rb

# vi app/lib/actions/katello/repository/update.rb

# git diff
diff --git a/app/lib/actions/katello/repository/update.rb b/app/lib/actions/katello/repository/update.rb
+++ b/app/lib/actions/katello/repository/update.rb
@@ -10,7 +10,7 @@ module Actions
 
           repo_params[:url] = nil if repo_params[:url] == ''
           update_cv_cert_protected = repo_params.key?(:unprotected) && (repo_params[:unprotected] != repository.unprotected)
-
+          repo_params[:ignorable_content] = ['srpm', 'drpm']
           root.update!(repo_params)
 
           if update_content?(repository)
diff --git a/app/models/katello/root_repository.rb b/app/models/katello/root_repository.rb
index 80c57ba..392b9f1 100644
--- a/app/models/katello/root_repository.rb
+++ b/app/models/katello/root_repository.rb
@@ -17,7 +17,7 @@ module Katello
     DOWNLOAD_ON_DEMAND = 'on_demand'.freeze
     DOWNLOAD_POLICIES = [DOWNLOAD_IMMEDIATE, DOWNLOAD_ON_DEMAND].freeze
 
-    IGNORABLE_CONTENT_UNIT_TYPES = %w(srpm).freeze
+    IGNORABLE_CONTENT_UNIT_TYPES = %w(srpm drpm erratum).freeze
     CHECKSUM_TYPES = %w(sha1 sha256).freeze
 
     SUBSCRIBABLE_TYPES = [Repository::YUM_TYPE, Repository::OSTREE_TYPE, Repository::DEB_TYPE].freeze


4. Now, Add the drpm and erratum as the ignorable content types for the SLE_12_SP5 repo


# cat << EOF |foreman-rake console
Katello::RootRepository.select { |r| r&.ignorable_content&.include? "srpm" }.each do |root|
 root.ignorable_content = root.ignorable_content + ["drpm", "erratum"]
 root.save!
end
EOF

# echo "select id,name,product_id,content_type,ignorable_content from katello_root_repositories;" | su - postgres -c "psql foreman"


5. Revert back the changes done in the katello code

# cd /usr/share/gems/gems/katello-4.3.0.50

# git reset --hard


6. Upgrade to Satellite 6.12 and observe the results. 



Actual Results:

Upgrade will fail on the db:migrate step , to perform the RemoveDrpmFromIgnorableContent migration as the current code https://github.com/Katello/katello/pull/9986/files only assumes that drpm would the only additional ignorable content and hence it tries to just remove it and the save the repo but sinc erratum is present as well and it is not a supported content type, The root.save! fails. 

~~~
2022-11-23 20:26:27 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns:
2022-11-23 20:26:27 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: == 20220228173251 RemoveDrpmFromIgnorableContent: migrating ===================
2022-11-23 20:26:27 [ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-11-23 20:26:27 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]

~~~


Expected Results: 

No such errors.


Additional info:

At this stage, To fix the issue, 

# cd /usr/share/gems/gems/katello-4.5.0.20

--> Create this file :

# cat migration_fix.patch
diff --git a/db/migrate/20220228173251_remove_drpm_from_ignorable_content.rb b/db/migrate/20220228173251_remove_drpm_from_ignorable_content.rb
index a690c9e..39c0bca 100644
--- a/db/migrate/20220228173251_remove_drpm_from_ignorable_content.rb
+++ b/db/migrate/20220228173251_remove_drpm_from_ignorable_content.rb
@@ -1,8 +1,15 @@
 class RemoveDrpmFromIgnorableContent < ActiveRecord::Migration[6.0]
   def up
-    Katello::RootRepository.select { |r| r&.ignorable_content&.include? "drpm" }.each do |root|
-      root.ignorable_content = root.ignorable_content - ["drpm"]
-      root.save!
+    Katello::RootRepository.select { |r| r&.ignorable_content&.include?("drpm") || r&.ignorable_content&.include?("erratum") }.each do |root|
+       ignorable_content_to_remove = []
+       if(root&.ignorable_content&.include? "drpm")
+            ignorable_content_to_remove << "drpm"
+       end
+       if(root&.ignorable_content&.include? "erratum")
+            ignorable_content_to_remove << "erratum"
+       end
+       root.ignorable_content = root.ignorable_content - ignorable_content_to_remove
+       root.save!
     end
   end
 
--> Apply the patch

# patch -p1 < migration_fix.patch 
patching file db/migrate/20220228173251_remove_drpm_from_ignorable_content.rb


--> Run db:migrate manually 

# cd ~

# foreman-rake db:migrate --trace

--> And confirm that, Now only srpms are showing up as the IGNORABLE CONTENT for the same repo

# echo "select id,name,product_id,content_type,ignorable_content from katello_root_repositories;" | su - postgres -c "psql foreman"


--> Re-run the upgrade and it should be completed successfully

Comment 2 Bryan Kearney 2022-12-22 20:03:35 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/35864 has been resolved.

Comment 13 errata-xmlrpc 2023-01-18 14:53:14 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 (Critical: Satellite 6.12.1 Async Security Update), 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:0261


Note You need to log in before you can comment on or make changes to this bug.