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.
Criteria
Section titled “Criteria”| 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 |
Create, preview, apply
Section titled “Create, preview, apply”E=https://entrepot.example.comapi() { 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"resource "entrepot_cleanup_policy" "prune_snapshots" { name = "prune-snapshots" format = "npm" criteria = { prerelease_only = true published_older_than_days = 30 keep_latest = 5 }}
resource "entrepot_repository" "npm_internal" { name = "npm-internal" format = "npm" kind = "hosted" blob_store = "default" cleanup_policies = [entrepot_cleanup_policy.prune_snapshots.name]}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}How runs work
Section titled “How runs work”- Schedule. Policies run every
cleanup.interval(default24h;0disables 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, Helmindex.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 (
409lists the repositories).
Recipes
Section titled “Recipes”| 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} |