Loading
docs(specs): add the S35 remote cache retention spec
Summary
- Problem: a remote repository caches every artifact pulled through it, and nothing ever removes a cached copy. The cache only grows, and GitLab pays for that storage.
- Impact: every remote repository on GitLab.com, Self-Managed and Dedicated. Users see a cache full of versions nobody uses, and the P0 GA item asks for cleanup with no setup (gitlab-org/gitlab#631533).
- Change: adds S35, remote cache retention. Every remote repository evicts cached copies not downloaded in the last 90 days, fixed, with no user setting. Eviction reuses the marker manual eviction writes, so the purger and GC reclaim storage as they do today. It runs on our own River jobs, with no external workflow engine: a leader-elected dispatch hands due repositories to one job each and caps live jobs across the fleet (
cache_cleanup.max_live_jobs), so autoscaling does not raise the database load. The UI says so on the remote repository pages. Operators get an on/off key and metrics, and a temporary feature flag turns it on during rollout, with a log line per evicted row while the flag exists. It also amends ADR-010's Cache Retention section to match, and drops a stale leak row from S28. - Downsides: one small table (per-repository run state) and five new indexes on the remote cache tables. Download stamps are best-effort, so a copy can be evicted early when its only stamp was dropped or arrived late; the next pull re-fetches it. Container layers of an evicted manifest stay until the whole image goes idle (tracked in the confidential
gitlab-org/ops/artifact-registry#1862). npm evicts versions only, not packages, until packuments stamp on every serve.
Checklist
- Gaps: npm package-level eviction waits for packument stamping on fills and revalidations. The container manifest refusal stays dormant until remote fills record index-to-child links. Layer reclaim per manifest is
gitlab-org/ops/artifact-registry#1862(confidential). Configurable windows are lifecycle policies, S29 (gitlab-org/gitlab#605721). The spec's Deferred section lists everything else left out, how we'd add it and what triggers it. None of it makes cleanup unsafe: each one only keeps something longer or costs one extra upstream fetch. - Least sure: accepting lossy download stamps, and a health gate that only knows reachability. A dropped or late stamp, or an upstream that answers probes but refuses fetches, can evict a copy someone then can't re-fetch until the upstream works again. I'd change my mind if production shows evictions of recently pulled copies or failed re-fetches; the spec names the fallback for each.
- Compatibility: nothing breaks for clients, and no API field changes. No existing data changes. Each repository waits one full 90-day window, plus a day, after cleanup first sees it, recorded on its run row, so no deployment evicts on download stamps that older code missed, however late it upgrades.
- Agreement: the S14, S15, S16 and S17 owners (stamps, fills, eviction), S20-A (the purger has to keep a zero window for the remote cache levels when GA trash lands; that amendment comes with the Trash spec), S22 (each batch emits its artifact count), S28 (GC), S27 (dispatch needs while-live uniqueness for a periodic schedule and a live-job count by kind, which an S27 amendment adds before S35 is built), and the monolith S05 and S07 owners (the UI text). This MR also amends ADR-010's Cache Retention section for the fixed 90-day window, which needs the Engineering Lead's approval. Not agreed yet: this MR is the ask.
- Simplicity: I kept only the state cleanup cannot work without: a run row per repository with its cutoff and cursor, so a large repository resumes instead of rescanning. I rejected a discovery job, a per-deployment stamp record, an API field, a bytes metric and an over-eviction alarm for now; the Deferred section says when each comes back. I also rejected a per-repository user setting, which is lifecycle policies.
Related to gitlab-org/gitlab#631533
Edited by João Pereira