Remove specific RPM package from pulp repository

Problem:
Hi,
I want to know how to remove specific content/RPM package from pulp repository/content.
FYI :
[pulp@pulpcore ~]$ pulp rpm repository list
{
“pulp_href”: “/pulp/api/v3/repositories/rpm/rpm/018c4405-f505-7b1a-b5b6-ade858be107c/”,
“pulp_created”: “2023-12-07T11:24:50.310805Z”,
“versions_href”: “/pulp/api/v3/repositories/rpm/rpm/018c4405-f505-7b1a-b5b6-ade858be107c/versions/”,
“pulp_labels”: {},
“latest_version_href”: “/pulp/api/v3/repositories/rpm/rpm/018c4405-f505-7b1a-b5b6-ade858be107c/versions/6/”,
“name”: “boomi-rhel8”,
“description”: null,
“retain_repo_versions”: null,
“remote”: null,
“autopublish”: false,
“metadata_signing_service”: null,
“retain_package_versions”: 0,
“metadata_checksum_type”: null,
“package_checksum_type”: null,
“gpgcheck”: 0,
“repo_gpgcheck”: 0,
“sqlite_metadata”: false
}
Expected Outcome
for example: I should be able to remove this specific package
[pulp@pulpcore ~]$ pulp rpm content list --name mysql-community-server
[
{
“pulp_href”: “/pulp/api/v3/content/rpm/packages/018c4481-9ce1-713a-8876-7a16e1a36c1a/”,
“pulp_created”: “2023-12-07T13:40:34.441742Z”,
“md5”: null,
“sha1”: null,
“sha224”: “dc00f8bc300f90ca23047c0def6f55fc6dfd857a4715d1c73b7df4e3”,
“sha256”: “8f8a4eac8e9d085ab639ba6f65779a0a658163da9c0e3dc7cf9e7673d8c577c7”,
“sha384”: “08f764c1fb34fd038904a1094014de6d5358daec3b4c1a89dba283cdedd8cfd29a64742a2794097c8414edfc4ede2886”,
“sha512”: “703604e9e09b38ad3143fb2db1a4a6cc5a2a0ca05947cd919593e5c6de81620311e9574f6f52a4b6ebc35ce6da29178611abb893db56dba053cfcf0522a0e345”,
“artifact”: “/pulp/api/v3/artifacts/018c4481-c709-7068-8b1c-0327c85d4772/”,
“name”: “mysql-community-server”,
“epoch”: “0”,
“version”: “8.0.35”,
“release”: “1.el8”,
“arch”: “x86_64”,
“pkgId”: “8f8a4eac8e9d085ab639ba6f65779a0a658163da9c0e3dc7cf9e7673d8c577c7”,
“checksum_type”: “sha256”,
“summary”: “A very fast and reliable SQL database server”,
“description”: “The MySQL™ software delivers a very fast, multi-threaded, multi-user,\nand robust SQL (Structured Query Language) database server. MySQL Server\nis intended for mission-critical, heavy-load production systems as well\nas for embedding into mass-deployed software. MySQL is a trademark of\nOracle and/or its affiliates\n\nThe MySQL software has Dual Licensing, which means you can use the MySQL\nsoftware free of charge under the GNU General Public License\n(Licenses - GNU Project - Free Software Foundation). You can also purchase commercial MySQL\nlicenses from Oracle and/or its affiliates if you do not wish to be bound by theterms of\nthe GPL. See the chapter “Licensing and Support” in the manual for\nfurther info.\n\nThe MySQL web site (http://www.mysql.com/) provides the latest news and\ninformation about the MySQL software. Also please see the documentation\nand the manual for more information.\n\nThis package includes the MySQL server binary as well as related utilities\nto run and administer a MySQL server.”,
“url”: “http://www.mysql.com/”,

Pulpcore version:
pulpcore==3.31.0
Pulp plugins installed and their versions:
pulp-rpm==3.22.3
pulp-certguard==1.6.5
pulp-certguard-client==1.6.5
pulp-cli==0.21.2
Operating system - distribution and version:
RHEL 8.8

Please let me know if you need any other information.
Thank You!

My hint: Proceed from pulp rpm repository content remove --help

1 Like

Hi, Thank you for the response!
Can you please tell what is --package-href I have to use, I tried using “pulp_href” or “artifact” from output mentioned in the topic.

this is the error I am getting

[pulp@pulpcore ~]$ pulp rpm repository content remove --repository boomi-rhel8 --package-href /pulp/api/v3/artifacts/018c4481-c709-7068-8b1c-0327c85d4772/
Error: {"remove_content_units":["Could not find the following content units: ['/pulp/api/v3/artifacts/018c4481-c709-7068-8b1c-0327c85d4772/']"]}
[pulp@pulpcore ~]$ pulp rpm repository content remove --repository boomi-rhel8 --package-href /pulp/api/v3/repositories/rpm/rpm/018c4405-f505-7b1a-b5b6-ade858be107c/
Error: {"remove_content_units":["Could not find the following content units: ['/pulp/api/v3/repositories/rpm/rpm/018c4405-f505-7b1a-b5b6-ade858be107c/']"]}

Another question : Can I also remove specific pulp rpm repository version ? For example here the version is 6. Is there anyway I can remove preceding versions?

/pulp/api/v3/repositories/rpm/rpm/018c4405-f505-7b1a-b5b6-ade858be107c/versions/6/

In general any option named -href wants a pulp_href of the relevant type of entity. So yes, in your case, from the output you posted above the “href” for the “mysql-community-server” package you listed is /pulp/api/v3/content/rpm/packages/018c4481-9ce1-713a-8876-7a16e1a36c1a/, which is not the hrefs you used in the examples where you are getting the error. I am not sure what happens if you try to remove a package from a repository that is not in the latest version of that repository in the first place.

You can also remove repository versions:

$ pulp rpm repository version destroy --help
Usage: pulp rpm repository version destroy [OPTIONS]

  Destroy a repository version.

Options:
  --repository-href TEXT  HREF of the repository
  --repository TEXT       A resource to look for identified by <name> or by
                          <href>.
  --version INTEGER       Repository version number
  --help                  Show this message and exit.

So you should be able to use something like:

pulp rpm repository version destroy --repository <repository_name_or_href> --version 5

Version 5 would then be deleted. If there is a version 6 in the repo, this does not change the content within version 6, so in effect the version being deleted will be merged into the next higher version. So content that was previously added in version 5 would now show up as “added in version 6”. (Somebody correct me if I am wrong).

If you only want a certain number of versions to be retained per repository, then you may want to look into the retain_repo_versions setting, which can be set on a repository.

1 Like

So looking at this again, you tried using the artifact href, and the repostiroy href. You need to use the pulp_href of the package (or more generally the content) you want to remove from the repo. In your example the correct href to use is:

/pulp/api/v3/content/rpm/packages/018c4481-9ce1-713a-8876-7a16e1a36c1a/

You can find it in the output you posted above!

1 Like

Hi,
Sorry it was my bad I may have mistakenly entered wrong href.

I corrected my mistake and entered correct href. But I can still see the package listed when I run pulp rpm content list --name mysql-community-server

Please check these below outputs

[pulp@pulpcore ~]$ pulp rpm repository content remove --repository boomi-rhel8 --package-href /pulp/api/v3/content/rpm/packages/018c4481-9ce1-713a-8876-7a16e1a36c1a/
Started background task /pulp/api/v3/tasks/018c59f2-21e3-7eab-af16-42990890f686/
…Done.
[pulp@pulpcore ~]$ pulp rpm content list --name mysql-community-server
[
{
“pulp_href”: “/pulp/api/v3/content/rpm/packages/018c4481-9ce1-713a-8876-7a16e1a36c1a/”,
“pulp_created”: “2023-12-07T13:40:34.441742Z”,
“md5”: null,
“sha1”: null,
“sha224”: “dc00f8bc300f90ca23047c0def6f55fc6dfd857a4715d1c73b7df4e3”,
“sha256”: “8f8a4eac8e9d085ab639ba6f65779a0a658163da9c0e3dc7cf9e7673d8c577c7”,
“sha384”: “08f764c1fb34fd038904a1094014de6d5358daec3b4c1a89dba283cdedd8cfd29a64742a2794097c8414edfc4ede2886”,
“sha512”: “703604e9e09b38ad3143fb2db1a4a6cc5a2a0ca05947cd919593e5c6de81620311e9574f6f52a4b6ebc35ce6da29178611abb893db56dba053cfcf0522a0e345”,
“artifact”: “/pulp/api/v3/artifacts/018c4481-c709-7068-8b1c-0327c85d4772/”,
“name”: “mysql-community-server”,
“epoch”: “0”,
“version”: “8.0.35”,
“release”: “1.el8”,
“arch”: “x86_64”,
“pkgId”: “8f8a4eac8e9d085ab639ba6f65779a0a658163da9c0e3dc7cf9e7673d8c577c7”,
“checksum_type”: “sha256”,
“summary”: “A very fast and reliable SQL database server”,
“description”: “The MySQL™ software delivers a very fast, multi-threaded, multi-user,\nand robust SQL (Structured Query Language) database server. MySQL Server\nis intended for mission-critical, heavy-load production systems as well\nas for embedding into mass-deployed software. MySQL is a trademark of\nOracle and/or its affiliates\n\nThe MySQL software has Dual Licensing, which means you can use the MySQL\nsoftware free of charge under the GNU General Public License\n(Licenses - GNU Project - Free Software Foundation). You can also purchase commercial MySQL\nlicenses from Oracle and/or its affiliates if you do not wish to be bound by theterms of\nthe GPL. See the chapter “Licensing and Support” in the manual for\nfurther info.\n\nThe MySQL web site (http://www.mysql.com/) provides the latest news and\ninformation about the MySQL software. Also please see the documentation\nand the manual for more information.\n\nThis package includes the MySQL server binary as well as related utilities\nto run and administer a MySQL server.”,
“url”: “http://www.mysql.com/”,

@tushar This is expected.

The command rpm content list will list all RPM content that exists within Pulp. You have only removed the package from one repository (version), you have not removed it from Pulp.

Let me explain in a bit more detail what the command pulp rpm repository content remove --repository boomi-rhel8 --package-href /pulp/api/v3/content/rpm/packages/018c4481-9ce1-713a-8876-7a16e1a36c1a/ does:

First, we assume that before you ran the command you had a repository named “boomi-rhel8” with the latest repository version 6. (See "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/018c4405-f505-7b1a-b5b6-ade858be107c/versions/6/" from your example output above). Let’s also assume that this repository version 6 had the package “mysql-community-server” in it. (Note that I can’t actually be certain this is true from the example output you posted).

If you now run:

pulp rpm repository content remove --repository boomi-rhel8 --package-href /pulp/api/v3/content/rpm/packages/018c4481-9ce1-713a-8876-7a16e1a36c1a/

Then Pulp will remove the package with the given href (which has the name “mysql-community-server”) from the repository named “boomi-rhel8”. This means that Pulp will create a new repository version 7, that does not have the package in it. However repository version 6 (with the package in it) will continue to exist, and the package will continue to exist in Pulp, and rpm content list will continue to list it.

If you now go and delete every repository version that has the package “mysql-community-server” in it, and then run a Pulp orphan cleanup, and the Package is outside the orphan protection window, then the orphan cleanup would remove the package from Pulp completely.

3 Likes

Hi @quba42 That worked for me. Thank you for the explanation!