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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For paused metadata task clearing:
Alternate of the 4th step mentioned above: