Delete Artifact with pulp-cli

Problem: * How can I delete an artifact with ‘pulp-cli’?

I tried with httpie this method:

[admin@pulp-vso-pr pulp3]$  http --form DELETE http://mypulp/pulp/api/v3/content/rpm/packages/568d2155-a032-4a2b-807f-783c9d0e10f6/  

Authorization:“Basic xxxxxxxxxxxxxxxxxx”
HTTP/1.1 405 Method Not Allowed
access-control-expose-headers: Correlation-ID
content-length: 43
content-type: application/json
correlation-id: 042d19ea1f464543acdacaafb97c9ad6
date: Wed, 10 Aug 2022 15:53:59 GMT
referrer-policy: same-origin
server: gunicorn
vary: Accept, Cookie
x-content-type-options: nosniff
x-frame-options: DENY

“detail”: “Method “DELETE” not allowed.”

Pulpcore version:

  "component": "core",
  "version": "3.20.0",
  "package": "pulpcore"

Pulp plugins installed and their versions:
“component”: “rpm”,
“version”: “3.17.7”,
“package”: “pulp-rpm”
“component”: “file”,
“version”: “1.10.3”,
“package”: “pulp-file”
“component”: “container”,
“version”: “2.13.0”,
“package”: “pulp-container”
“component”: “ansible”,
“version”: “0.14.0”,
“package”: “pulp-ansible”

Operating system - distribution and version: alma 8.6

Content in Pulp should be immutable, so Content endpoints don’t have a DELETE method. The main method for removing Content from Pulp is orphan cleanup, which removes any Content and their Artifacts which are not present in any current Repository. Check out pulp orphan cleanup --help.

ok so first i remove the package from my repository:

pulp rpm repository content remove --package-href “$PACKAGE_HREF” --repository ${REPO_NAME}

my package is considered orphaned

(venv-pulp3) [admin@pulp pulp3]$ pulp orphan cleanup --content-hrefs $(pulp rpm content list --name mypackage | jq -cr ‘.|map(.pulp_href)’) --protection-time 0
Started background task /pulp/api/v3/tasks/5274c6e0-c9d0-43e8-afed-e6df19180a42/
“pulp_href”: “/pulp/api/v3/tasks/5274c6e0-c9d0-43e8-afed-e6df19180a42/”,
“pulp_created”: “2022-08-10T21:46:15.772950Z”,
“state”: “completed”,
“name”: “”,
“logging_cid”: “e749216f04a6457a83b67d5cbfc06aa6”,
“started_at”: “2022-08-10T21:46:15.816214Z”,
“finished_at”: “2022-08-10T21:46:15.848534Z”,
“error”: null,
“worker”: “/pulp/api/v3/workers/bcccb229-28e8-4f21-898f-e72e3aadddbd/”,
“parent_task”: null,
“child_tasks”: [],
“task_group”: null,
“progress_reports”: [
“message”: “Clean up orphan Content”,
“code”: “clean-up.content”,
“state”: “completed”,
“total”: 0,
“done”: 0,
“suffix”: null
“message”: “Clean up orphan Artifacts”,
“code”: “clean-up.content”,
“state”: “completed”,
“total”: 0,
“done”: 0,
“suffix”: null
“created_resources”: [],
“reserved_resources_record”: []
the artifact is still not deleted

I should have clarified since orphaned behavior is kind of confusing. A Content unit becomes an orphan when it is not present in any repository and their previous versions. So when you run pulp rpm repository content remove that creates a new repository version without the Content, but the previous version still has it so the Content is not orphaned. To truly remove the Content you must delete all previous repository versions that contain the Content before running orphan cleanup. If you don’t care about the repository history you can also set the repository’s --retain-repo-versions to 1 to remove all previous versions.

How many repo versions does you repo have? If you have previous versions that contain that package you need to DELETE them.

currently i have 3 versions, the problem is how to identify the version to delete when there are several?

As @gerrod pointed out - if you do not care/use previous repo versions you can just set on the repo to retain always 1 version and you will be good to go.
Otherwise, execute this call to find what versions contain the content unit in question GET http :/pulp/api/v3/repositories/rpm/rpm/:UUID/versions/?content=<content_href>

i set the repository "–retain-repo-versions " to 1, that does the job :wink:

1 Like

Also repository versions follow the natural numbers. You probably want to keep the one with the greatest version number.