Bug 2055951

Summary: Index content is creating duplicated errata in "katello_erratum" table after upgrading to Satellite 6.10
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Lai <ltran>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.10.0CC: aperotti, ehelms, ileppala, jsherril, karnsing, sadas, saydas, yann.lopez
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.3.0.15-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2070994 (view as bug list) Environment:
Last Closed: 2022-07-05 14:33:38 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 Hao Chang Yu 2022-02-18 02:30:17 UTC
Description of problem:
Index content is creating duplicated errata in "katello_erratum" table after upgrading to Satellite 6.10. This is because the existing errata has pulp2 id in pulp_id column. The newly created errata will have the errata_id in the pulp_id column. Katello considers them as different errata.

It appears that Satellite doesn't switch the entries in katello_erratum during the content switchover. Is this the expected behaviour? If not, should we remove them and how can we safely remove the old errata (with pulp2 id) which are still associated to the old versions of content view repositories?


foreman-rake console
> pp Katello::Erratum.where(errata_id: "RHBA-2019:1293").first.pulp_id
"78f852c6-44bc-411c-9d43-615b1ea6ccfe"  <==== pulp2 id
> pp Katello::Erratum.where(errata_id: "RHBA-2019:1293").second.pulp_id
"RHBA-2019:1293  <=== errata_id
exit


# select errata_id, count(errata_id) count from katello_errata group by errata_id order by count desc;
   errata_id    | count 
----------------+-------
 RHEA-2021:1949 |     2
 RHEA-2018:0867 |     2
 RHSA-2021:0289 |     2
 RHBA-2020:5049 |     2
 RHBA-2018:3024 |     2
 RHBA-2019:2025 |     2
 RHSA-2015:1666 |     2
 RHBA-2020:4452 |     2
 RHSA-2021:0989 |     2
 RHBA-2021:0243 |     2
<snip>


The duplicated errata have 0 module streams which break the content view filtering. If you have a filter to "include/exclude all module streams without errata" then unexpected module streams and errata will be included/excluded.


> pp Katello::Erratum.where(errata_id: "RHBA-2019:1293").first.module_streams.size
1  <====
> pp Katello::Erratum.where(errata_id: "RHBA-2019:1293").second.module_streams.size
0  <====


The empty module streams for the duplicated/second erratum can be fixed by applying the following change:

--- a/app/services/katello/pulp3/erratum.rb     2021-12-18 03:12:39.000000000 +1000
+++ b/app/services/katello/pulp3/erratum.rb     2022-02-18 12:06:05.668000000 +1000
@@ -102,7 +102,7 @@
             module_stream_id_column = "#{ModuleStreamErratumPackage.table_name}.module_stream_id"
             existing = ErratumPackage.joins(:module_streams).
                                       where(module_stream_id_column => module_stream.id,
-                                            :nvrea => nvreas).pluck(:nvrea)
+                                            :nvrea => nvreas, :erratum_id => model.id).pluck(:nvrea)

             (nvreas - existing).each do |nvrea|
               package = model.packages.find_by(:nvrea => nvrea)



Katello upstream seems to have included this fix already after refactoring the content indexing codes.

https://github.com/Katello/katello/blob/master/app/services/katello/pulp3/erratum.rb#L106



Steps to Reproduce:
1. Upgrade Satellite from 6.9 to 6.10
2. After upgrading the Satellite, trigger complete sync against one or more repositories (particularly those with module streams) and wait until they are finished.

Actual results:
Duplicated errata created in katello_erratum table. Duplicated modular errata have 0 module streams.

Expected results:
No duplicate errata

Comment 4 Samir Jha 2022-03-02 19:16:13 UTC
Created redmine issue https://projects.theforeman.org/issues/34549 from this bug

Comment 5 ileppala 2022-03-04 08:02:24 UTC
We also upgraded to satellite 6.10, (6.10.2 to be exact) and we are also affected by the same bug.

Comment 6 Bryan Kearney 2022-03-07 20:05:34 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34549 has been resolved.

Comment 12 errata-xmlrpc 2022-07-05 14:33:38 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 (Moderate: Satellite 6.11 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-2022:5498