Removing unwanted/stale packages from Red Hat Satellite's package list.

Solution Verified - Updated -

Environment

  • Red Hat Satellite 6.

Issue

  • A custom package which was removed from its corresponding repository is still listed through the hammer package search command although it does not show up on Satellite GUI:
[root@satellite ~]# hammer package list --search <custom-package>
------|-------------------------------------------------|---------------------------------------------
ID       | FILENAME                                                                 | SOURCE RPM                                  
------|-------------------------------------------------|---------------------------------------------
34783 | <custom-package-name>.arch.rpm              | <custom-package-name>.src.rpm
------|-------------------------------------------------|---------------------------------------------

Resolution

Please take a snapshot/backup of the Satellite server before performing any of the steps mentioned below:

  • Start by removing the stale entry of the custom package from the Foreman DB. Following command will list all repositories this custom package is a part of(notice the repo_id):
[root@satellite ~]# su - postgres -c "echo \" select repo.id as repo_id, rpm.id as rpm_package_id  from katello_repositories repo 
join katello_repository_rpms rr on rr.repository_id = repo.id 
join katello_rpms rpm on rpm.id = rr.rpm_id 
where rpm.nvra like '<package-name>%'  \" | psql foreman"
  • Verify if there are the same number of references(number of records) for the custom package to the repositories associated:
[root@satellite ~]# su - postgres -c "echo \" select * from katello_repository_rpms where rpm_id = <rpm-id>  \" | psql foreman"

Note: Replace the <rpm-id> as per the output of hammer package list --search <package-name> command.

  • Remove the package's association with the repositories:
[root@satellite ~]# su - postgres -c "echo \" delete from katello_repository_rpms where rpm_id = <rpm-id>  \" | psql foreman"
  • After the package-repository association is removed, delete the RPM record:
[root@satellite ~]# su - postgres -c "echo \" delete from katello_rpms where id = <rpm-id>  \" | psql foreman"

Root Cause

  • The package-repository association has stale entries in the Foreman DB.

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.

Comments