Repository navigation
feat(sandbox-sidecar): add boxd as a sandbox runner - #2774
Open
MichielMAnalytics wants to merge 1 commit into
Open
MichielMAnalytics wants to merge 1 commit into
MichielMAnalytics wants to merge 1 commit into
Conversation
SANDBOX_RUNNER=boxd runs each Remote Runs job in a fresh, isolated boxd machine. The runner installs the requested Terraform or OpenTofu version unless the machine already has it (BOXD_SNAPSHOT), streams init, plan and apply output, returns the plan JSON or the new state, and deletes the machine when the job ends. Each job has one deadline (BOXD_JOB_TIMEOUT_SECONDS, default 25 minutes, below statesman's poll timeout). Each machine also gets a delete-after timer of that limit plus 10 minutes, so it goes away even if the sidecar stops mid-job. The plan summary moves to runners/planSummary.ts so both runners share it. Adds unit tests (npm test) and a live smoke test (npm run smoke:boxd).
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This branch has not been deployed
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.
I work on boxd. This adds boxd as a second sandbox runner for OpenTaco Remote Runs, next to E2B. With
SANDBOX_RUNNER=boxdthe sidecar runs each plan or apply in a fresh boxd machine (a full Ubuntu VM) and deletes it when the job ends.Summary
sandbox-sidecar/src/runners/boxdRunner.ts: aSandboxRunnerthat mirrorse2bRunner.ts. Same job flow: install the requested Terraform/OpenTofu version, write the config archive and state, runinitandplanorapply/destroy, stream the output to the job log, return the plan JSON or the new state.SANDBOX_RUNNERacceptse2b(still the default) orboxd. An unknown value or a missingBOXD_API_KEYfails at startup with a clear message.e2bRunner.tstorunners/planSummary.ts, unchanged, so both runners count changes the same way.OPENTACO_SANDBOX_PROVIDER=e2bandOPENTACO_E2B_SIDECAR_URL, since it only talks HTTP to the sidecar.SANDBOX_RUNNERmoved from the composeenvironment:block intosidecar.env(the example setse2b), so it can be switched there. An env file without it still getse2b, the sidecar's default.Turn it on:
Options:
BOXD_ORG,BOXD_REGION,BOXD_SNAPSHOT(start from a snapshot with Terraform or OpenTofu installed, like the E2B templates),BOXD_VCPU/BOXD_MEMORY,BOXD_LABELS,BOXD_NAME_PREFIX,BOXD_JOB_TIMEOUT_SECONDS(default 1500, below statesman's 30 minute poll timeout).How it maps onto the runner
Sandbox.create(template)machines.create({ isolated: true, config: { autoSuspendTimeout: 0 } })+waitUntilReadyBOXD_SNAPSHOT) already has that versionfiles.writefiles.upload, byte count checkedcommands.runwith output callbacksstreamExec, stopped when the job runs out of timefiles.readfiles.downloadsandbox.kill()infinallymachines.delete(id)infinally, retried once, plus a delete-after timer set at createDifferences from the E2B runner
isolated, since they run user Terraform. They have outbound internet (providers, registries) but can't reach other machines.x.y.z[-suffix]before it goes into the install script, and aworking_directorythat leaves the workspace is refused before a machine is created. A leading/is relative to the workspace, as with E2B.BOXD_JOB_TIMEOUT_SECONDS, defaulting to 25 minutes so a job ends before statesman stops polling (OPENTACO_E2B_POLL_TIMEOUT, 30 minutes). Keep a few minutes between them.managed-by=opentaco-sidecarandopentaco-job=<job id>.BOXD_SNAPSHOT) holds oneterraformand onetofuonPATH. Other versions are installed at runtime. The docs say to build it on a fresh isolated machine, since every job runs user Terraform on a copy of it.Test plan
npm test: 39 new unit tests (the sidecar had none) against a fake boxd client. They cover config parsing, runner selection, the plan summary, create options, streaming, plan/apply/destroy, state round trip, install skip, the job deadline, and that the machine is deleted on every failure path. Passes on Node 24 and onnode:20-alpine(the sidecar image's base).npm run build: clean.docker build -f Dockerfile_sidecar: builds.BOXD_E2E=1 npm run smoke:boxd: Terraform 1.5.7 plan, apply, re-plan with state (no changes), destroy plan, destroy; OpenTofu 1.10.0 plan; a broken config that failsinit. 7 jobs, 7 machines created and deleted, each job about 3 s end to end.SANDBOX_RUNNER=boxd, driven by statesman's own Go client (taco/internal/sandbox): plan and apply with Terraform 1.8.5 in a/infraworking directory, and a failing OpenTofu plan.time_sleep) streamed to the end. WithBOXD_JOB_TIMEOUT_SECONDS=25a 90 s apply was stopped and the machine deleted. A live machine had its delete-after timer, labels and idle settings as set.mint broken-linksindocs/: the same 19 broken links as ondevelop, none new.🧠 Ai UsageDetails (if applicable):
This PR was written primarily by Claude Code (code, tests and docs). I reviewed it and ran the tests above, including the live runs against boxd.