Last active
December 6, 2023 06:02
-
-
Save sayan3296/5aaac9ec1e7ba6a2bb6a135bd4e40c10 to your computer and use it in GitHub Desktop.
Script to recreate the issue from KB https://access.redhat.com/solutions/6809431 and https://access.redhat.com/solutions/6826971
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Assuming that, this is a fresh satellite 6.10 with a subscription manifest imported ( having a valid RHEL sub ) and no repos are enabled at present | |
## Also assuming that the organization name is RedHat or else replace "--organization RedHat" with "--organization-id 1" | |
## Setup the repo and CV in satellite | |
hammer repository-set enable --name "Red Hat Satellite Tools 6.9 (for RHEL 7 Server) (RPMs)" --product "Red Hat Enterprise Linux Server" --basearch x86_64 --releasever 7Server --organization RedHat | |
hammer repository-set enable --name "Red Hat Ansible Engine 2.9 RPMs for Red Hat Enterprise Linux 7 Server" --product "Red Hat Ansible Engine" --basearch x86_64 --organization RedHat | |
hammer repository update --name "Red Hat Ansible Engine 2.9 RPMs for Red Hat Enterprise Linux 7 Server x86_64" --product "Red Hat Ansible Engine" --organization RedHat --download-policy immediate | |
hammer repository synchronize --name "Red Hat Ansible Engine 2.9 RPMs for Red Hat Enterprise Linux 7 Server x86_64" --product "Red Hat Ansible Engine" --organization RedHat | |
hammer repository synchronize --name "Red Hat Satellite Tools 6.9 for RHEL 7 Server RPMs x86_64" --product "Red Hat Enterprise Linux Server" --organization RedHat | |
REPO_IDS=$(hammer --no-headers repository list --organization RedHat --fields Id | xargs | tr " " ",") | |
hammer lifecycle-environment create --name QA --prior Library --organization RedHat | |
hammer content-view create --name TestCV --organization RedHat --repository-ids $REPO_IDS | |
hammer content-view publish --name TestCV --organization RedHat | |
hammer content-view version promote --from-lifecycle-environment Library --to-lifecycle-environment QA --content-view TestCV --organization RedHat | |
hammer content-view publish --name TestCV --organization RedHat | |
hammer content-view version promote --from-lifecycle-environment Library --to-lifecycle-environment QA --content-view TestCV --organization RedHat | |
## Start breaking the pulp | |
su - postgres -c "psql -x foreman -c \"select main.id,main.root_id,root.name,main.pulp_id,root.http_proxy_id,main.library_instance_id,root.url,main.relative_path,main.remote_href,main.publication_href,main.version_href from katello_root_repositories root left JOIN katello_repositories main on main.root_id=root.id where main.library_instance_id is null;\"" &> /tmp/library_repos.txt | |
su - postgres -c "psql -x foreman -c \"select main.id,main.root_id,root.name,main.pulp_id,root.http_proxy_id,main.library_instance_id,root.url,main.relative_path,main.remote_href,main.publication_href,main.version_href from katello_root_repositories root left JOIN katello_repositories main on main.root_id=root.id where main.library_instance_id is not null;\"" &> /tmp/non_library_repos.txt | |
for repo in `cat /tmp/library_repos.txt | egrep "^pub" | awk -F'|' '{print $NF}' | sort -u`; do echo -e "\nDeleting $repo :\n"; curl -X DELETE -H "Content-Type: application/json" --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://`hostname -f`$repo ; echo -e "\n" ; done | |
for repo in `cat /tmp/non_library_repos.txt | egrep "^version" | awk -F'|' '{print $NF}' | sort -u`; | |
do | |
URL1=$repo | |
URL2=$( echo $repo | sed 's/..$/0\//') | |
echo -e "\nDeleting $URL1 :\n"; | |
curl -X DELETE -H "Content-Type: application/json" --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://`hostname -f`$URL1 ; | |
echo -e "\n" ; | |
echo -e "\nDeleting $URL2 :\n"; | |
curl -X DELETE -H "Content-Type: application/json" --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://`hostname -f`$URL2 ; | |
echo -e "\n" ; | |
done | |
for repo in `cat /tmp/non_library_repos.txt | egrep "^version" | awk -F'|' '{print $NF}' | sort -u`; | |
do | |
URL=$( echo $repo | sed 's/...........$//') | |
echo -e "\nDeleting $URL :\n"; | |
curl -X DELETE -H "Content-Type: application/json" --cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key https://`hostname -f`$URL ; | |
echo -e "\n" ; | |
done | |
## Delete the temp files | |
rm -f /tmp/non_library_repos.txt /tmp/library_repos.txt | |
## Try publishing a new version of CV | |
hammer content-view publish --name TestCV --organization RedHat | |
## Try another repo sync with --async | |
hammer repository synchronize --name "Red Hat Satellite Tools 6.9 for RHEL 7 Server RPMs x86_64" --product "Red Hat Enterprise Linux Server" --organization RedHat --async | |
## Wait for 6 minutes and then Try a manifest refresh with --async | |
sleep 360 | |
hammer subscription refresh-manifest --organization RedHat --async | |
echo "Done" |
Solution:
-
Clear the paused or pending tasks related to repo\cv\manifest.
-
Re-create the missing repos in Pulp: [ The command has to finish successfully ]
# foreman-rake katello:correct_repositories COMMIT=true --trace
-
Check in satellite UI and hopefully, the missing repos have been recreated but the related metadata regenerate tasks would be in paused state. So clear them again.
-
Re-create the publication and the metadata forcefully by following https://access.redhat.com/solutions/6826971.
-
Now, the repos should be able to sync and CVs can be republished and the manifest can be refreshed.
For paused metadata task clearing:
# foreman-rake foreman_tasks:cleanup TASK_SEARCH='label = Actions::Katello::Repository::MetadataGenerate' STATES='paused' VERBOSE=true
Alternate of the 4th step mentioned above:
# echo -e '
::User.current = ::User.anonymous_admin
missing = 0
tasks = []
Katello::Repository.all.where(library_instance: nil).select(&:yum?).each do |repo|
service = repo.backend_service(SmartProxy.pulp_primary)
p "Checking repository id #{repo.id} (#{repo.relative_path})"
begin
service.api.publications_api.read(repo.publication_href)
rescue PulpRpmClient::ApiError => e
if e.code == 404
missing += 1
p " - Publication '#{repo.publication_href}' is missing in Pulp. Fixing it now..."
if
tasks << ForemanTasks.async_task(Actions::Katello::Repository::MetadataGenerate, repo, force_publication: true)
end
else
p "Unexpected error: HTTP status: #{e.code}, #{e.message}"
end
end
end
' | foreman-rake console
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Errors:
Attempt to publish a new content view version fails with the following error:
Attempt to sync a repo fails with this error:
Attempt to refresh manifest fails with a similar error.