Skip to content

fix(sandbox): remove package caches an organization stopped using - #4547

Merged
yannickmonney merged 1 commit into
mainfrom
fix/sandbox-package-cache-retention
Oct 9, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/sandbox-package-cache-retention

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Per-organization pip/npm/bun cache volumes only ever grew: none of these tools evicts, and the volumes went only when the organization was deleted.

Changes

fix(sandbox): remove package caches an organization stopped using

Every Docker session without Docker inside mounts its organization's pip,
npm and bun cache volumes. None of these tools evicts on its own, and the
volumes were removed only when the organization was deleted, so a cache
only grew: one CUDA wheel set alone is 2-3 GB, kept for organizations that
stopped using their sandboxes months ago, and invisible to disk relief.

Each create now records its organization's last cache use under the
session root (.package-caches/.used). The hourly look in the
host sweep removes an organization's three volumes once no session
container of the organization exists (any state, any spawner on the
daemon) and that use is older than SANDBOX_PACKAGE_CACHE_RETENTION:
14 days by default, as for the stopped build caches; off keeps them.
Caches without a recorded use (hosts upgraded from an earlier release)
get one at first sight, so nothing goes before a full retention.

A create holds its organization's caches from before it ensures them
until its container exists; no removal starts while one is held, a create
that arrives during a removal waits for it, and the removal judges the
organization again under its claim. Docker refusing to remove a mounted
volume stays the second safety net. The organization's next session after
a removal starts with empty caches.

Verification

  • services/sandbox: package-cache-retention.test.ts, docker-session-cache-volumes.test.ts, config.test.ts, volume.test.ts, docker-session-backend.test.ts (128 pass); @tale/sandbox typecheck and lint clean; lint:manual ok.
  • EN/DE/FR environment reference, .env.example and the sandbox README document SANDBOX_PACKAGE_CACHE_RETENTION.

Part of the sandbox footprint and robustness pass (#4533, #4538 and siblings).

@yannickmonney
yannickmonney force-pushed the fix/sandbox-package-cache-retention branch from 10a6e7e to c17ec21 Compare October 8, 2026 15:28
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 9, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 9, 2026
@yannickmonney
yannickmonney force-pushed the fix/sandbox-package-cache-retention branch 2 times, most recently from 7eaa129 to 720b1d0 Compare October 9, 2026 02:40
@yannickmonney
yannickmonney force-pushed the fix/sandbox-package-cache-retention branch from 720b1d0 to b8ac7a4 Compare October 9, 2026 02:55
Every Docker session without Docker inside mounts its organization's pip,
npm and bun cache volumes. None of these tools evicts on its own, and the
volumes were removed only when the organization was deleted, so a cache
only grew: one CUDA wheel set alone is 2-3 GB, kept for organizations that
stopped using their sandboxes months ago, and invisible to disk relief.

Each create now records its organization's last cache use under the
session root (.package-caches/<organization>.used). The hourly look in the
host sweep removes an organization's three volumes once no session
container of the organization exists (any state, any spawner on the
daemon) and that use is older than SANDBOX_PACKAGE_CACHE_RETENTION:
14 days by default, as for the stopped build caches; off keeps them.
Caches without a recorded use (hosts upgraded from an earlier release)
get one at first sight, so nothing goes before a full retention.

A create holds its organization's caches from before it ensures them
until its container exists; no removal starts while one is held, a create
that arrives during a removal waits for it, and the removal judges the
organization again under its claim. Docker refusing to remove a mounted
volume stays the second safety net. The organization's next session after
a removal starts with empty caches.
@yannickmonney
yannickmonney force-pushed the fix/sandbox-package-cache-retention branch from b8ac7a4 to c719a31 Compare October 9, 2026 03:02
@yannickmonney
yannickmonney merged commit f1bf7de into main Oct 9, 2026
@yannickmonney
yannickmonney deleted the fix/sandbox-package-cache-retention branch October 9, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant