Unable to delete content uploaded via pulp file content create – no destroy command available

I’m using the pulp file plugin and uploading content into a file repository using the below command:

pulp file content create --relative-path k8s-ds-amdgpu-dp.yaml --file-url https://raw.githubusercontent.com/ROCm/k8s-device-plugin/r1.16/k8s-ds-amdgpu-dp.yaml --repository manifest-repo

However, I noticed there is no ‘destroy’ or ‘delete’ option under pulp file content --help to remove content that was uploaded this way.

How can I delete specific content that was added via pulp file content create?

Due to how Pulp shares and deduplicates content in the background, the way to remove content (specifically, get the binary deleted from storage) is to make it an orphan, that’s it, make sure it does not belong to any repository version. Orphaned content is cleanup by orphan cleanup internal task.

There are some docs about it for RPM, but the same applies for File.

1 Like

Hi, I would like to add a few notes to what was already mentioned.

If you want to only remove content from the repository, you can run the following command:
pulp file repository content remove --repository manifest-repo --relative-path k8s-ds-amdgpu-dp.yaml --sha256 "ff16754a81b0f130a03e23f688e60be60a7bf5111831b2faef0fa138eeb1f3bc"

If you want to completely remove content from pulp, you can follow these steps (however, I cannot say if this is the recommended approach):

Suppose you want to remove content with the href "/pulp/api/v3/content/file/files/0197fa0b-6618-765a-adf0-9381b7cc62f9/":

HREF="/pulp/api/v3/content/file/files/0197fa0b-6618-765a-adf0-9381b7cc62f9/"

# Identify which repository versions include the content
# (this assumes that the content is only in manifest-repo)
pulp file repository version list --repository manifest-repo --content "[\"$HREF\"]" | jq -r ".[].number"
1

# Remove these versions
# (content must not be included in any repository versions)
pulp file repository version destroy --repository manifest-repo --version 1

# Run the cleanup for the specific content 
pulp orphan cleanup --protection-time 0 --content-hrefs "[\"$HREF\"]"

# Verify that the content was completely removed from pulp
pulp file content list
[]

Hope this helps!

3 Likes