Skip to content

Instantly share code, notes, and snippets.

@mccun934
Last active June 4, 2021 21:43
Show Gist options
  • Save mccun934/4d031b5ac2d81a599c4ce7e574130400 to your computer and use it in GitHub Desktop.
Save mccun934/4d031b5ac2d81a599c4ce7e574130400 to your computer and use it in GitHub Desktop.

1) On your MongoDB server:

Substitute in the name of the package you are looking for in the name param, in this example we use satellite-clone

# mongo pulp_database
> db.units_rpm.find( {name: "satellite-clone"}, { id: 1})
{ "_id" : "33e8dfe8-87d3-43a9-849e-c65092f22f68" }
{ "_id" : "3e7b87e6-b67d-4655-87c6-2754e3dcfb21" }
{ "_id" : "203df79d-d71f-4d83-aa5b-be384de708e9" }
{ "_id" : "33b6b6ad-382f-4bb5-82c4-8b3a9a7dafd1" }
{ "_id" : "5f76658a-e4b4-411a-b797-1c7edca8b5d3" }
{ "_id" : "53c58b9e-73b4-42e3-adc5-ca5549a98874" }
{ "_id" : "23147490-7067-4730-be5f-32ecfa70c308" }
{ "_id" : "680ebd29-6950-4e9e-867e-311cf0166651" }
{ "_id" : "c60f455f-5d6b-46d5-8809-85dfb2c51d64" }
{ "_id" : "3153278b-94d8-4f17-8714-394a082a4702" }

Now you have the IDs listed for the RPMs that exist with the name 'satellite-clone'. Looks like there are 10 of them, so pick the 1st one on the list and go to step 2

2) Now find the row in the join table in Mongo that links the unit to the Repos, so you can find the repo_id, paste in the uni_id in the query below:

> db.repo_content_units.find( {unit_id: "33e8dfe8-87d3-43a9-849e-c65092f22f68"}, { repo_id: 1} )
{ "_id" : ObjectId("5f85dbdc59c52b84c8792ba7"), "repo_id" : "6fe6d45a-56d1-45e0-b953-cb9086bd1c1a" }

3) Now you have the repo_id that has satellite-clone in it:

> db.repos.find( { repo_id: "6fe6d45a-56d1-45e0-b953-cb9086bd1c1a" }, {display_name: 1} )
{ "_id" : ObjectId("5f85dbc24c6bf00c2e47bce9"), "display_name" : "Red Hat Satellite Maintenance 6 for RHEL 7 Server RPMs x86_64" }

4) Now you have the name of the repo referencing the RPM you want gone. Delete said repo and re-run orphan cleanup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment