Bug 2034461

Summary: Capsule failed to sync empty repositories
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: PulpAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.10.0CC: aeladawy, dalley, dkliban, ehelms, ggainey, rchan, sadas, saydas, vsedmik
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pulp-rpm-3.17.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:31:12 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-21 02:13:58 UTC
Description of problem:
Capsule failed to sync an empty repository with the following error while refreshing the distribution.

12: Actions::Pulp3::CapsuleContent::RefreshDistribution (skipped) [ 2.47s / 2.05s ]
Queue: default

Started at: 2021-12-16 08:42:24 UTC
Ended at: 2021-12-16 08:42:26 UTC
Real time: 2.47s
Execution time (excluding suspended state): 2.05s

Input:
---
repository_id: 78
smart_proxy_id: 2
options:
  contents_changed: true
<snip>
Output:

--- {}
Error:

NoMethodError

Error:
NoMethodError
undefined method `pulp_href' for nil:NilClass
---
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository_mirror.rb:78:in
  `publication_href'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository_mirror.rb:164:in
  `refresh_distributions'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/lib/actions/pulp3/capsule_content/refresh_distribution.rb:17:in
  `invoke_external_task'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/action/polling.rb:84:in
  `initiate_external_action'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/action/polling.rb:19:in
  `run'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/action/cancellable.rb:14:in
  `run'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/lib/actions/pulp3/abstract_async_task.rb:10:in
  `run'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/action.rb:572:in
  `block (3 levels) in execute_run'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware/stack.rb:27:in
<snip>


I think it is because mirror repository won't create a publication for empty repository.

# Capsule pulpcore database
pulpcore=# select pulp_id, name, next_version, pulp_type from core_repository where pulp_id = '7effd787-066f-4359-ac28-abd5f1bb91eb';
               pulp_id                |                            name                             | next_version | pulp_type 
--------------------------------------+-------------------------------------------------------------+--------------+-----------
 7effd787-066f-4359-ac28-abd5f1bb91eb | 1-empty-cv-development-909fee88-367c-4310-851d-9a9ebf66087c |            1 | rpm.rpm
(1 row)

pulpcore=# select * from core_repositoryversion where repository_id = '7effd787-066f-4359-ac28-abd5f1bb91eb';
               pulp_id                |         pulp_created          |       pulp_last_updated       | number | complete | base_version_id |            repository_id             
--------------------------------------+-------------------------------+-------------------------------+--------+----------+-----------------+--------------------------------------
 2689f18b-a003-4bca-8185-54d896cdedee | 2021-12-16 18:39:08.434498+10 | 2021-12-16 18:39:08.434517+10 |      0 | t        |                 | 7effd787-066f-4359-ac28-abd5f1bb91eb
(1 row)

pulpcore=# select * from core_publication where repository_version_id = '2689f18b-a003-4bca-8185-54d896cdedee';
 pulp_id | pulp_created | pulp_last_updated | pulp_type | complete | pass_through | repository_version_id 
---------+--------------+-------------------+-----------+----------+--------------+-----------------------
(0 rows)  <======== No publication created


Steps to Reproduce:
1. Create or enable a repository, don't sync it or add any content.
2. Create a content view and add the new repo to it
3. Create a new LCE, such as 'dev' and ensure it is added to the Capsule.
4. Publish and promote the new content view which should trigger a capsule sync.
5. If not just trigger a complete capsule sync.

Actual results:
undefined method `pulp_href' for nil:NilClass

Expected results:
No error

Comment 1 Brad Buckingham 2022-01-05 14:52:15 UTC
Is this a regression from prior releases?

Comment 2 Hao Chang Yu 2022-01-06 01:00:02 UTC
(In reply to Brad Buckingham from comment #1)
> Is this a regression from prior releases?

No. It is the regression of current release

Comment 8 Vladimír Sedmík 2022-04-27 14:15:55 UTC
Verified on 6.11.0 snap 17 at rhel7 and rhel8 (with tfm-pulpcore-python3-pulp-rpm-3.17.3-2.el7pc.noarch and python38-pulp-rpm-3.17.3-2.el8pc.noarch):
Following the steps from comment 0 using empty custom or unsynced RH repo I was not able to reproduce the error - all capsule syncs succeeded without errors, regardless the download or mirroring policy or the sync type.

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