Bug 2032098

Summary: Incremental publish content view doesn't copy any contents
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: high    
Version: 6.10.0CC: ahumbe, ajambhul, ben.formosa, casl, jbhatia, jkrajice, jobuckle, ltran, msunil, pcreech, pmendezh, risantam, saydas
Target Milestone: 6.11.0Keywords: Patch, 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:
: 2043719 (view as bug list) Environment:
Last Closed: 2022-07-05 14:31:01 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 2021-12-14 03:04:41 UTC
Description of problem:
After publishing an incremental content view, the content count remain the same as previous version. The specified errata are not copy to the latest published version.

This is because Katello database is still storing to the errata with old href which have been deleted by Pulp (delete orphan). When Katello instructs Pulp to copy those errata, nothing will be copy because they are no longer exist in Pulp.

Like any other content in Pulp 3, advisories are immutable. So when there is some change to it, a new one is created, it is then associated to a repository as a part of a new repository version and the old one is unassociated and becomes orphaned.

They are some errata/advisory's fields that Katello doesn't store in its database but Pulp does, such as version, pushcount, fromstr, rights etc. When one of those field changed after syncing the repo, Katello can't notice the change and "index_content" will not update the hrefs.


For example:
# The version of the RHSA-2020:3220 has bumped up to version '2' but other fields, such as updated_date remain unchanged.

pulpcore=# select content_ptr_id,  id, updated_date, issued_date, title, status, fromstr, version, severity, release,rights, pushcount, reboot_suggested from rpm_updaterecord where content_ptr_id in ('10dd841a-c411-41e1-9e3e-9b3021877daa', 'c9404462-9edb-4cef-9632-b59268e673fa');
            content_ptr_id            |       id       |    updated_date     |     issued_date     |                     title                     | status |            fromstr             | version | severity  
| release |           rights           | pushcount | reboot_suggested 
--------------------------------------+----------------+---------------------+---------------------+-----------------------------------------------+--------+--------------------------------+---------+-----------
+---------+----------------------------+-----------+------------------
 10dd841a-c411-41e1-9e3e-9b3021877daa | RHSA-2020:3220 | 2020-07-29 17:19:23 | 2020-07-29 17:19:38 | Important: kernel security and bug fix update | final  | release-engineering | 1       | Important 
| 0       | Copyright 2020 Red Hat Inc | 7         | t
 c9404462-9edb-4cef-9632-b59268e673fa | RHSA-2020:3220 | 2020-07-29 17:19:23 | 2020-07-29 17:19:38 | Important: kernel security and bug fix update | final  | release-engineering | 2       | Important 
| 0       | Copyright 2020 Red Hat Inc | 7         | t
(2 rows)


# However, we can see that Katello is still referring the old href.

irb(main):128:0> pp Katello::RepositoryErratum.find(2888951)
#<Katello::RepositoryErratum:0x000000000da40e40
 id: 2888951,
 erratum_id: 50031,
 repository_id: 1,
 created_at: Wed, 24 Nov 2021 01:48:03 UTC +00:00,
 updated_at: Wed, 24 Nov 2021 01:48:03 UTC +00:00,
 erratum_pulp3_href:
  "/pulp/api/v3/content/rpm/advisories/10dd841a-c411-41e1-9e3e-9b3021877daa/">  <======== The new one should be "c9404462-9edb-4cef-9632-b59268e673fa"


# The repository is a library instance

irb(main):131:0> pp Katello::RepositoryErratum.find(2888951).repository
#<Katello::Repository:0x000000000984d740
 id: 1,
 pulp_id:
  "Default_Organization-Red_Hat_Enterprise_Linux_Server-Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7Server",
 library_instance_id: nil,
 content_view_version_id: 1,
 relative_path:
  "Default_Organization/Library/content/dist/rhel/server/7/7Server/x86_64/os",
 environment_id: 1,
 saved_checksum_type: "sha1",
 distribution_version: nil,
 distribution_arch: nil,
 distribution_bootable: nil,
 distribution_family: nil,
 distribution_variant: nil,
 container_repository_name: nil,
 root_id: 1,
 remote_href:
  "/pulp/api/v3/remotes/rpm/rpm/8c9ff859-90a4-4885-ba3f-238fd878eb6a/",
 publication_href:
  "/pulp/api/v3/publications/rpm/rpm/2e694e90-5e43-42c7-9f8f-3f61314115c4/",
 version_href:
  "/pulp/api/v3/repositories/rpm/rpm/4aeedada-9a72-4570-8498-8ffaf1bcbf78/versions/4/",


# As we can see below "/pulp/api/v3/repositories/rpm/rpm/4aeedada-9a72-4570-8498-8ffaf1bcbf78/versions/4/" is associated to RHSA-2020:3220 version '2'.

pulpcore=# select rc.repository_id, rc.content_id, v.pulp_id as version_pulp_id, v.number, v.complete from core_repositorycontent rc left join core_repositoryversion v on v.pulp_id = rc.version_added_id where content_id = 'c9404462-9edb-4cef-9632-b59268e673fa' and rc.repository_id = '4aeedada-9a72-4570-8498-8ffaf1bcbf78';
            repository_id             |              content_id              |           version_pulp_id            | number | complete 
--------------------------------------+--------------------------------------+--------------------------------------+--------+----------
 4aeedada-9a72-4570-8498-8ffaf1bcbf78 | c9404462-9edb-4cef-9632-b59268e673fa | 83c626e6-b5d1-4f2c-be8e-b8f5e0a3acd9 |      4 | t
(1 row)


Index content method should check if the href of a unit has been changed and update it accordingly.


This issue is also affecting other functionality that need to copy content from source to destination repos, such as publishing content view with filter. The task will fail with the following error.

PulpRpmClient::ApiError
...
Response body: ["Could not find the following content units: ['/pulp/api/v3/content/rpm/advisories/297c4432-cc7b-4998-b75b-1a8f85d00dc8/', '/pulp/api/v3/content/rpm/advisories/513e7889-12f3-4598-ada7-4236e0f95d87/', '/pulp/api/v3/content/rpm/advisories/4f525eb5-9659-4a8a-a42f-d6fb00787da7/', '/pulp/api/v3/content/rpm/advisories/ba40ef74-bf92-49bb-aa3f-0ae07d343d9b/']"]

Comment 3 Bryan Kearney 2022-01-11 20:05:01 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34145 has been resolved.

Comment 4 Lai 2022-04-21 20:47:39 UTC
Steps to retest:

1. sync a few repos with erratas
2. Create a cv and add repos from step 1
3. create a filter that exclude a package
4. publish cv
5. incrementally update the cv with an errata

Expected:
cv should be published with a new version and have the content counts should be updated

Actual:
cv is published with new version and the content counts are updated


Verified on 6.11_17 on rhel7 and rhel8

Comment 8 errata-xmlrpc 2022-07-05 14:31:01 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