Capsule synchronization is failing with the error "Could not lookup a publication_href for repo XXXX" for custom repositories.
Environment
- Red Hat Satellite 6.
- Red Hat Capsule 6.
Issue
-
Getting an error Could not lookup a publication_href for repo XXXX while syncing the capsule server for
the custom repository. -
Issues with the
Customrepository were observed while syncing the capsule server.2022-11-14T10:43:51 [I|app|964a3e94] Started POST "/katello/api/capsules/14/content/sync" for 1.6.3.5 at 2022-11-14 10:43:51 -0500 2022-11-14T10:43:51 [I|app|964a3e94] Processing by Katello::Api::V2::CapsuleContentController#sync as JSON 2022-11-14T10:43:51 [I|app|964a3e94] Parameters: {"api_version"=>"v2", "id"=>"14", "capsule_content"=>{}} 2022-11-14T11:15:30 [E|bac|964a3e94] 404, message='Not Found', url=URL('https://satellite.example.com/pulp/content/My_Org/Library/custom/EPEL/EPEL_7/Packages/l/liblxi-1.17-1.el7.src.rpm') (Katello::Errors::Pulp3Error) 2022-11-14T12:03:34 [E|bac|964a3e94] Could not lookup a publication_href for repo 3191 (RuntimeError) -
Satellite Capsule versions 6.11.2+ still getting the capsule sync error:
21: Actions::Pulp3::CapsuleContent::Sync (skipped) [ 360.55s / 7.24s ] Input: \--- repository_id: x smart_proxy_id: y \: 25: Actions::Pulp3::CapsuleContent::RefreshDistribution (skipped) [ 1.32s / 0.38s ] \: Error: RuntimeError Could not lookup a publication_href for repo x
Resolution
-
Upgrade to Red Hat Satellite 6.11.z or later as errata for the issue is released. See this Bugzilla and Errata for more details:
-
For Red Hat Satellite 6.11.2 or below, try the workaround:
-
Find out the affected packages from the repository:
-
Create a list of packages for the affected custom repository in a text file.
# hammer package list --repository-id X > /tmp/affected_repo -
Find out duplicate packages from the newly created file using the below command.
# cat /tmp/affected_repo | cut -d '|' -f2 | sort | uniq -c | sort -n -
Remove the duplicate packages which are listed from the above command from the Satellite WebUI.
- Click on
Satellite WebUI-> Go toContent->Products-> Find the repository → Click on the repository -> Click onPackagesunder theContent Typetabular section ->Filterthe duplicate packages. - Remove the duplicate packages by selecting the checkbox beside and clicking the
Remove Packagesoption.
- Click on
-
-
For Satellite Capsule version 6.11.2+ hitting error "Could not lookup a publication_href for repo x"
during capsule sync could be cause by failed custom repository sync not able to generate
the metadata therefore the capsule sync is not able to find the publication_href.
The solution is as detailed on the next steps.If the sync is hitting the postgresql violates foreign constraint:
"insert or update on table "core_repositorycontent" violates foreign key constraint "core_repositoryconte_version_added_id_d5113f18_fk_core_repo"
it is hitting the bug mentioned in KBase 6983687
-
Re-sync the affected custom repository again and then perform the capsule synchronization.
On Satellite GUI --> Content --> Sync Status --> Select affected Repos --> Synchronized NOW On Satellite GUI --> Navigate to Product --> Click on the Product --> Select affected Repos --> Select Action --> Click "Verify Content Checksum"- Then publish a new version in the Content-view and publish/promote to ENV
On Satellite GUI --> Content --> Content-views --> Select CV --> Publish a new version On Satellite GUI --> Content --> Content-views --> Select CV --> Promote to ENV-
Now initiate a new task for the capsule server "Capsule" to optimize synchronization.
Satellite GUI --> Infrastructure --> Capsule --> Select "Capsule" --> Content Sync --> Synchronize --> Optimized sync
-
For more KB articles/solutions related to Red Hat Satellite 6.x Capsule Sync Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Capsule Sync Issues
Root Cause
- This issue can occur due to duplicate packages present in the repository.
- For Satellite Capsule version 6.11.2+ sync still hitting this error, the error is expected if the custom
repository sync failed due to metadata not generated, causing the publication_href to be missing.
Diagnostic Steps
-
Below error is observed while syncing the capsule server in the
/var/log/foreman/production.logfile.404, message='Not Found',url=URL('https://satellite.example.com/pulp/content/ORG/Library/Linbit_RHEL_7_x86_64/custom/Linbit/drbd-8_4_RHEL_7_x86_64/Packages/k/kmod-drbd-8.4.6_3.10.0_229.1.2-1.el7.x86_64.rpm'), Could not lookup a publication_href for repo XXXX -
To get the repository ID from the logs, use the below command
$ egrep -i "Could not lookup a publication_href for repo" /var/log/foreman/production.log 2022-11-14T10:32:37 [E|bac|663c5e9b] Could not lookup a publication_href for repo 3191 (RuntimeError) 2022-11-14T12:03:34 [E|bac|964a3e94] Could not lookup a publication_href for repo 3191 (RuntimeError)
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.