Bug 2089580

Summary: After syncing a repository, it doesn't sync to the capsule automatically.
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: RepositoriesAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Cole Higgins <chiggins>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.10.5CC: aganbat, ahumbe, ajambhul, akjha, bbuckingham, chiggins, osousa, risantam, wclark, wpinheir
Target Milestone: 6.10.7Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.1.1.60-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2103094 2103096 (view as bug list) Environment:
Last Closed: 2022-07-06 12:07:13 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:
Bug Depends On: 2044314    
Bug Blocks:    
Attachments:
Description Flags
Hotfix RPM for Satellite 6.10.6
none
Updated Hotfix RPM for Satellite 6.10.6 none

Description Hao Chang Yu 2022-05-24 04:26:04 UTC
Description of problem:
After syncing a repository and some contents have changed, Satellite will trigger an empty Capsule sync task which doesn't sync any repositores.

It appears to be the contents_changed flag not parsing into an action incorrectly. See the code below:

In file "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/lib/actions/katello/repository/sync.rb"
----------------------------------
...
              plan_self(:id => repo.id, :sync_result => output, :skip_metadata_check => skip_metadata_check, :validate_contents => validate_contents,
                        :contents_changed => contents_changed)  <========= This will always be "nil" as it is not getting from the output.
...
...
        def contents_changed
          input['contents_changed'] <=========
        end
-----------------------------------


Checking the upstream code, it appears that this issue has been fixed together with other issue[1] in the pull request below:

https://github.com/Katello/katello/pull/9931/files#diff-558aee5ae708f4471204806fef76de73707e6b4745ab4d348e8075953420d6ccR58


[1] https://projects.theforeman.org/issues/34414

Comment 1 Hao Chang Yu 2022-05-26 09:13:16 UTC
This is fixed in bug #2044314

Comment 6 wclark 2022-06-02 15:10:02 UTC
Created attachment 1886127 [details]
Hotfix RPM for Satellite 6.10.6

HOTFIX RPM is available for Satellite 6.10.3

INSTALL INSTRUCTIONS:

1. Take a complete backup or snapshot of Satellite 6.10.3 server

2. Download the hotfix RPM attached to this BZ and copy it to Satellite server

3. # yum install ./tfm-rubygem-katello-4.1.1.57-2.HOTFIXRHBZ2089580.el7sat.noarch.rpm --disableplugin=foreman-protector

4. # satellite-maintain service restart

Comment 7 wclark 2022-06-02 15:53:17 UTC
CORRECTION: the above comment has inconsistent Satellite versions due to copy & paste error on my part. To clarify, this hotfix is applicable to Satellite 6.10.6 only.

Comment 12 wclark 2022-06-28 21:09:44 UTC
Created attachment 1893266 [details]
Updated Hotfix RPM for Satellite 6.10.6

A new Hotfix RPM is available, which fixes both the Capsule Sync issue described here as well as the Errata Mail issue described in https://bugzilla.redhat.com/show_bug.cgi?id=2044314

INSTALL INSTRUCTIONS:

1. Take a complete backup or snapshot of Satellite 6.10.6 server

2. Download the hotfix RPM attached to this BZ and copy it to Satellite server

3. # yum install ./tfm-rubygem-katello-4.1.1.57-3.HOTFIXRHBZ2089580.el7sat.noarch.rpm --disableplugin=foreman-protector

4. # satellite-maintain service restart

Comment 13 wclark 2022-06-29 14:18:46 UTC
An important note about this bug and hotfix: This bug affects only repositories in the Library environment + Default Organization View. Capsule syncs following CV publish/promote should not be affected by this issue. The intended behavior of 'Optimized' Capsule syncs, for the Library environment + Default Organization View, is that repositories are only synced on Capsules when some change is detected in the repo, as compared to the last time it was synced on Satellite. This Hotfix restores that intended behavior. Some repository syncs on Satellite may however find no changes since the last sync (even though the Capsules are still behind Satellite) and therefore still not trigger the automatic syncs on Capsules even with the Hotfix installed.

To ensure all repositories in the Library + Default Org View are up to date on all Capsules, regardless of whether the most recent syncs on Satellite detect any changes in the repository, use this approach:

1. Install the Hotfix using the steps in the above comment. ( https://bugzilla.redhat.com/show_bug.cgi?id=2089580#c12 ). This will ensure that when repository syncs on Satellite do detect changes, those changes are propagated out to any Capsules with the Library environment assigned.

2. Clear smart proxy sync histories for all root repositories on Satellite with this command:

  # echo "Katello::RootRepository.all.map(&:id).each { |repo_id| Katello::Repository.find(repo_id).clear_smart_proxy_sync_histories }" |foreman-rake console

3. Run 'Optimized' syncs of each Capsule.

Comment 14 Waldirio M Pinheiro 2022-06-29 17:35:17 UTC
*** Bug 2098271 has been marked as a duplicate of this bug. ***

Comment 15 wclark 2022-06-30 19:48:30 UTC
Correction to the above script in comment #13 above. Step 2. (clear smart proxy sync histories) should use this command instead:

  # echo "Katello::Repository.where(content_view_version_id: 1).each(&:clear_smart_proxy_sync_histories)" |foreman-rake console

This will better target all repositories in the "Default Organization View"

Comment 24 errata-xmlrpc 2022-07-06 12:07:13 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 (Satellite 6.10.7 Async Bug Fix 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/RHBA-2022:5516

Comment 25 Amar Ganbat 2022-07-06 17:29:46 UTC
*** Bug 2098275 has been marked as a duplicate of this bug. ***