How to check on Satellite or Capsule where a package is served from?
Environment
Red Hat Satellite or Capsule 6
Issue
- Fetching a package from Satellite or Capsule hits some issues.
- We need to understand where the package is served from - from a disk if already downloaded, or from some remote source (and which one)?
Resolution
Create explain_where_to_fetch_package.py file with this content:
from pulpcore.content import Handler
from pulpcore.content.handler import PathNotResolved
import os
if 'URI' not in os.environ.keys():
print("no URI path provided, please re-run with OS variable URI set")
quit()
path = os.environ['URI'] # example: 'RedHat/Library/content/dist/rhel9/9/x86_64/baseos/os/Packages/s/sos-4.8.2-2.el9_5.noarch.rpm'
h = Handler()
try:
distro = h._match_distribution(path)
except PathNotResolved:
print(f"path {path} is not known, ensure you provide a valid URI without the server name")
quit()
rel_path = path.lstrip("/")
rel_path = rel_path[len(distro.base_path) :]
rel_path = rel_path.lstrip("/")
ca = distro.publication.published_artifact.select_related(
"content_artifact",
"content_artifact__artifact",
"content_artifact__artifact__pulp_domain",
).get(relative_path=rel_path).content_artifact
if ca.artifact:
print(f"package is downloaded locally at /var/lib/pulp/media/{ca.artifact.file}, expected size: {ca.artifact.size} sha1sum: {ca.artifact.sha1} sha256sum: {ca.artifact.sha256}")
else:
remote_artifacts = ca.remoteartifact_set.select_related(
"remote"
).order_by_acs()
print(f"package is not local, can be downloaded from {len(remote_artifacts)} locations, printing first up to 3:")
for ra in remote_artifacts[:2]:
if ra.url.startswith(ra.remote.url):
warn = ""
else:
warn = f" DIFFERENT FROM Remote object url {ra.remote.url}!"
print(f" {ra.url}{warn}")
Execute it with proper URI value:
cat explain_where_to_fetch_package.py | sudo -u pulp URI='MyOrg/DEV_LE/MY_CV/content/dist/rhel9/9/x86_64/baseos/os/Packages/s/sos-4.8.1-1.el9_5.noarch.rpm' PULP_SETTINGS='/etc/pulp/settings.py' DJANGO_SETTINGS_MODULE='pulpcore.app.settings' pulpcore-manager shell
Example output:
package is downloaded locally at /var/lib/pulp/media/artifact/04/2d43e4f70945ffc72ecba4739cf382dafb559bb5060b10ec9073f23a5bfed8, expected size: 1223606 sha256sum: 042d43e4f70945ffc72ecba4739cf382dafb559bb5060b10ec9073f23a5bfed8
or:
package is not local, can be downloaded from 1 locations, printing first up to 3:
https://cdn.redhat.com/content/dist/rhel9/9/x86_64/baseos/os/Packages/s/sos-4.8.1-1.el9_5.noarch.rpm
Warning: For Satellite/Capsule 6.14 or older, run rather
grep -v content_artifact__artifact__pulp_domain explain_where_to_fetch_package.py | ..
For more KB articles/solutions related to Red Hat Satellite 6.x Pulp 3.0 Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Pulp 3.0-related Issues.
SBR
Product(s)
Components
Category
Tags
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.