Skip to content

Cleanup policies

A cleanup policy deletes components that match all of its set criteria. Repositories opt in by listing policies in cleanup.policies; a policy can be shared by many repositories and optionally restricted to one format.

Criterion Meaning
publishedOlderThanDays the component was published (or first cached) more than N days ago
lastDownloadedOlderThanDays the component has not been downloaded for N days. Never-downloaded components count from their publish date
nameRegex / versionRegex regular expressions over the name / version
prereleaseOnly only pre-releases. npm, Helm and Docker use SemVer pre-release; PyPI uses PEP 440 a, b, rc and dev; Apt and Yum use a ~ or alpha/beta/rc markers
keepLatest always keep the N newest versions of each name. Versions are ordered when every version parses in the format’s scheme, otherwise by publish date
untaggedOlderThanDays Docker: delete untagged manifests older than N days, plus layer links no remaining manifest references
Terminal window
E=https://entrepot.example.com
api() { curl -fsS -H "Authorization: Bearer $ADMIN" -H 'Content-Type: application/json' "$@"; }
api -X POST $E/api/v1/cleanup-policies -d '{
"name": "prune-snapshots", "format": "npm",
"description": "Pre-releases older than 30 days, keeping the 5 newest",
"criteria": {"prereleaseOnly": true, "publishedOlderThanDays": 30, "keepLatest": 5}
}'
# What would it delete in npm-internal?
api -X POST "$E/api/v1/cleanup-policies/prune-snapshots/preview?repository=npm-internal"
# Attach it: add "cleanup": {"policies": ["prune-snapshots"]} to the repository (PUT)
# Run a repository's policies now (dryRun=true for a preview, policy=… for just one)
api -X POST "$E/api/v1/repositories/npm-internal/cleanup?dryRun=false"

The preview and the run return the same shape:

{"dryRun": true, "repositories": ["npm-internal"],
"components": [{"name": "@acme/widgets", "version": "1.3.0-rc.1", "…": "…"}],
"assets": 12, "bytes": 4823112}
  • Schedule. Policies run every cleanup.interval (default 24h; 0 disables the schedule). A cluster-wide lock ensures only one replica runs them, and each run is audited (cleanup.run).
  • What gets deleted. Component assets are deleted, then format metadata is regenerated (npm packuments, PyPI indexes, Apt Packages/Release, Yum repodata, Helm index.yaml). Freed blobs are garbage-collected afterwards.
  • Proxies. Cleanup only evicts cached components; anything still needed is fetched again on demand.
  • Groups are skipped — attach policies to their members.
  • In-use policies can’t be deleted (409 lists the repositories).
Goal Criteria
Evict proxy content nobody used for 90 days {"lastDownloadedOlderThanDays": 90} on the proxies
Keep only the 10 newest versions of each package {"keepLatest": 10, "publishedOlderThanDays": 1}
Drop CI snapshot images {"versionRegex": "^[0-9a-f]{8}$", "publishedOlderThanDays": 14} on docker-internal
Remove untagged manifests left by moving tags {"untaggedOlderThanDays": 7} on Docker hosted repositories
Prune PyPI dev builds {"prereleaseOnly": true, "versionRegex": "\\.dev", "publishedOlderThanDays": 7}