Repository navigation
feat(sandbox): reimplement the L2 golden tier in the Go daemon - #5824
Merged
Merged
Conversation
Author
|
Merge dependency: #5843 is stacked on this branch and adds the publish half — a node-level DaemonSet that fills the shared store. Neither PR is useful alone. This one restores from a store nothing fills (the tenant mount is read-only by design, so no sandbox boot can publish); #5843 fills a store nothing reads. Merge both or neither — merging only this one leaves prod with the volume mounted, the env var set, and a store that stays permanently empty, which is the exact state that let the tier sit broken and unnoticed for three months after #5575. #5843 also adds the org to the archive key, which changes the key shape. Worth landing together rather than reshaping keys after anything is published. |
pedrofrxncx
approved these changes
Aug 7, 2026
The cross-node golden tier was written in TypeScript (#5351, #5399) and deleted with that daemon in #5575, before it ever ran in a deployed config. Nothing replaced it: the Go daemon logged "GOLDEN_CACHE_REMOTE is set but this daemon implements the node-local golden tier only" and installed from scratch. Since then the bucket, the mountpoint PV/PVC and the env var were all provisioned (decocms/terraform-eks-cluster#88/#92, decocms/deco-apps-cd#203), so prod has the volume mounted at /golden-cache with nothing on either end of it. This ports restore, publish and prune to Go, keyed identically to L1 (same credential-stripped repo hash, same lockfile hash) so the two tiers can never disagree about what a key means. Orchestrator wiring: L1 reflink → L2 extract → install. An L2 hit leaves pendingGolden set, so the healthy-boot transition seeds THIS node's L1 from the extracted tree and the next pod here gets the reflink instead of another extract. That transition also runs the L2 publish, which no-ops on an existing key, so the two are safe together. Two deliberate departures from the TypeScript original: - The pipe is os.Pipe, not `bash -c` with pipefail. Both children get one real kernel fd pair, so a multi-GB tree never traverses this process — which matters because the health probe must keep answering (Studio tears the pod down on a single miss), and because a relayed copy is what truncated this transfer in the TS version. Using os/exec's StdoutPipe would reintroduce that relay. This also drops the bash dependency and the shell quoting it needed. - No shell means no `set -o pipefail`; both children's exit codes are checked explicitly instead, consumer first because its stderr is the line that explains a corrupt archive. Unchanged from the original, because they are load-bearing: an archive rather than a tree (per-operation metadata latency is fatal across ~100k files); extract into staging then rename, so an interrupted tar cannot leave a partial node_modules that later code reads as complete; write straight to the final key rather than temp+rename, because a blob store has no rename and does not need one; read the archive back before reporting success, because publish no-ops on an existing key so a corrupt one would be permanent. zstd is already in the sandbox image (packages/sandbox/image/Dockerfile) — it survived the TS deletion. main.go now warns when it is missing rather than warning that the tier is unimplemented. Testing: real files, real tar/zstd, no mocks. Publish on one root and restore on another (the point of the tier), an ~8 MB payload past any pipe buffer (the case that caught a truncating implementation in TS, where a 1 KB fixture passed), dormant-when-unconfigured as the discriminating counterpart, truncated and corrupt archives failing closed with no partial tree and no staging left behind, idempotent publish, and prune by TTL and per-repo cap. `go build ./...`, `go vet`, `gofmt` clean; full internal/setup suite passes. NOT validated on a real pod, and it cannot be yet: the tenant mount is read-only, so publish always fails there and the store stays empty. Restoring needs something to have published — a trusted seeder with the writable mount is the remaining piece, tracked separately. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
nicacioliveira
force-pushed
the
feat/sandbox-l2-golden-in-go-daemon
branch
from
August 7, 2026 21:36
ee30d0f to
2f539d6
Compare
decocms Bot
pushed a commit
that referenced
this pull request
Aug 10, 2026
PR: #5824 feat(sandbox): reimplement the L2 golden tier in the Go daemon Bump type: minor - @decocms/sandbox (packages/sandbox/package.json): 1.44.6 -> 1.45.0 - deploy/helm/sandbox-env (chart 0.12.11) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.45.0 Deploy-Scope: both
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cross-node golden tier has no implementation. This restores one.
What happened
The tier was written in TypeScript (#5351, #5399) and deleted with that daemon in #5575, before it ever ran in a deployed config. Nothing replaced it — the Go daemon logged
and installed from scratch. Meanwhile the infrastructure kept being built around it: the bucket (decocms/terraform-eks-cluster#88), the PV/PVC ownership refactor (#92, #5806) and the rollout (decocms/deco-apps-cd#203). So prod today has the volume mounted at
/golden-cachewith nothing on either end of it. TheRestoreL2metric constant indepmetrics.gosurvived too — only the code was gone.What this does
Ports restore, publish and prune to Go, keyed identically to L1 (same credential-stripped repo hash, same lockfile hash) so the two tiers can never disagree about what a key means. A test asserts credentials do not change the key and that two repos never collide — bun does not re-verify cache content, so per-repo isolation is the boundary both tiers rely on.
Orchestrator wiring: L1 reflink → L2 extract → install. An L2 hit leaves
pendingGoldenset, so the healthy-boot transition seeds this node's L1 from the extracted tree and the next pod here gets the reflink instead of another extract. That same transition runs the L2 publish, which no-ops on an existing key, so the two are safe together.Two deliberate departures from the original
The pipe is
os.Pipe, notbash -cwithpipefail. Both children get one real kernel fd pair, so a multi-GB tree never traverses this process. That matters twice: the health probe must keep answering (Studio tears the pod down on a single miss), and a relayed copy is exactly what truncated this transfer in the TS version — usingos/exec'sStdoutPipehere would reintroduce that relay. It also drops the bash dependency and the shell quoting it required.No shell means no
pipefail, so both exit codes are checked explicitly — consumer first, because its stderr is the line that explains a corrupt archive.tar exit 2alone is unactionable; it took a hand-run of the pipe to learn it meant "Unexpected EOF in archive".Kept, because they are load-bearing
node_modulesthat later code reads as complete — the boot skips install and fails somewhere unrelated.zstdis already in the sandbox image (packages/sandbox/image/Dockerfile:42) — it survived the TS deletion.main.gonow warns when it is missing instead of warning that the tier is unimplemented.Testing
Real files, real
tar/zstd, no mocks:node_modulesgets a complete tree, contents verified.viteexcludedgo build ./...,go vet,gofmtclean; the fullinternal/setupsuite passes. Tests skip rather than fail whenzstdis absent, so a contributor without it does not get a red suite that trains them to ignore it.Not covered: publish's read-back guard. Publish no-ops on an existing key so a corrupt object cannot be planted ahead of it, and making
zstdemit a bad archive on demand would mean faking the pipe — which defeats testing against real tools. Noted in the test file rather than papered over.Not validated on a real pod, and it cannot be yet
The tenant mount is read-only by design, so publish always fails there and the store stays empty. Restore needs something to have published first.
So this PR makes the tier possible, not live: with a seeded store, sandboxes will restore from it and
sandbox.deps.restore{source="l2"}starts reporting. The remaining piece is a trusted seeder holding the writable mount — deliberately not a sidecar in the sandbox pod, since a package manager installs cached content as-is and write access to a shared store would turn a node-local RCE surface into a fleet-wide one.Per the repo norm, "done" means a tailed pod showing an L2 hit. This is not that yet.
Summary by cubic
Reimplements the cross-node L2 golden cache in the Go daemon to restore, publish, and prune shared
tar+zstdarchives, cutting cold-node installs and wiring L2 before install in the orchestrator.New Features
sandbox.deps.restore{source="l2"}, marks install success; after healthy boot it runs L2 publish and prune..vite.os.Pipewith explicit exit checks; large streams never traverse the daemon process.GOLDEN_CACHE_REMOTEis set;main.gowarns whenzstdis missing.Migration
Written for commit 2f539d6. Summary will update on new commits.