Remove Content

Removing content from Pulp entirely is slightly complicated for a number of architectural reasons. First, repository-versions are immutable (so you can get back to any version and have all the content available). This means that it is not possible to remove content as long as there still exists a repo-version that “knows about it”. Second, Pulp deduplicates content. Artifacts can be shared across repositories - which means the repo being looked at, may not be the only one whose repo-versions still point to the content.

The way content gets removed “from Pulp” is via the orphan cleanup task, which will look for Artifacts that don’t belong to any repository-versions, and haven’t been touched in a while, and removes them.

Removing Content

Warning

Please, follow the script steps carefuly and only if you know what you are doing because you risk losing data.

Using pulp-cli commands:

#!/usr/bin/env bash

# Remove content from repository
echo "Removing content from ${REPO_NAME}"
pulp rpm repository version destroy --repository $REPO_NAME

echo "Removing orphan rpm contents"
pulp orphan cleanup --content-hrefs $(pulp rpm content list | jq -cr '.|map(.pulp_href)') --protection-time 0

echo "Checking rpm contents"
pulp rpm repository content list --repository $REPO_NAME

Using httpie to talk directly to the REST API:

#!/usr/bin/env bash

# Remove content from repository
echo "Removing content from ${REPO_NAME}"
export LATEST_VERSION=$(http "$BASE_ADDR/pulp/api/v3/repositories/rpm/rpm/?name=${REPO_NAME}"  | jq -r '.results[0].latest_version_href')
http DELETE "${BASE_ADDR}${LATEST_VERSION}"

echo "Removing orphan rpm contents"
http POST "$BASE_ADDR"/pulp/api/v3/orphans/cleanup/ orphan_protection_time=0

echo "Checking rpm contents"
export LATEST_VERSION_HREF=$(http "${BASE_ADDR}/pulp/api/v3/repositories/rpm/rpm/?name=${REPO_NAME}" | jq -r .results[0].latest_version_href)
http "${BASE_ADDR}/pulp/api/v3/content/rpm/packages/?repository_version=${LATEST_VERSION_HREF}"