Repository navigation
fix(sbx): a stopped template worker's VMs are ended by the unit's ExecStopPost - #800
Conversation
[email protected] runs with KillMode=control-group, but the worker's Firecracker VMs are not in the unit's cgroup: jailer places each one in a pool-N cgroup under the worker's slice, a sibling of the service's own cgroup. A stop that lands while the worker cannot tear its pool down itself (during the standby fill, on a crash, at TimeoutStopSec) leaves the VM running with its guest memory resident, outside every budget, until that worker's next start sweeps it -- which may be never if the template is retired. The unit now runs ExecStopPost=-<libexec>/sbx-reap-vms.sh %i after every exit. The helper (deploy/sbx/reap-vms.sh) derives the slice from the instance name the way install-host.sh writes SH_PARENT_CGROUP (sbx.slice/sbx-<id>.slice), and touches only its immediate pool-<digits> children, the names vmpool's isPooledCgroupDirName accepts: never the service's own cgroup, another worker's slice or any other directory. It writes 1 to cgroup.kill (falling back to SIGKILL of the pids in cgroup.procs on a kernel without it), then waits up to SBX_REAP_TIMEOUT (10 s) for each cgroup.events to report populated 0. It never fails the stop: problems are logged to the unit's journal and it exits 0. SBX_CGROUP_ROOT is the test seam. install-host.sh installs the helper beside the janitor's libexec path, rewrites the unit's ExecStopPost= path for SBX_LIBEXEC_DIR (validated before anything is touched), and records it as a shared `unit` line, so the last worker's uninstall removes it with the template unit. Refs rossoctl#795 Signed-off-by: Rong Chang <[email protected]>
The runbook's KVM-host section says where a worker's VMs live (pool-N cgroups under its slice), what the unit's ExecStopPost= helper does and logs, and how to find a leaked VM by cgroup and reap it, with the warning not to do so while the worker runs. The README and the uninstall section list sbx-reap-vms.sh among the installed shared files. Refs rossoctl#795 Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
This adds ExecStopPost=-…/sbx-reap-vms.sh %i to [email protected], along with deploy/sbx/reap-vms.sh. On every exit, the script kills the populated pool-<n> children of the worker's own slice (cgroup.kill, or a SIGKILL fallback), waits up to SBX_REAP_TIMEOUT, and always exits 0.
Checked against the code:
- The id regex matches
valid_id, and the slice matches theSH_PARENT_CGROUPthat install-host writes. - The
pool-<digits>allowlist matches vmpool'sisPooledCgroupDirName. - The unit's own cgroup is never matched.
uninstall_workerstops the slice beforeremove_shared_units, so the reaper is still present for the last stop.- The 10 s default fits inside
TimeoutStopSec=30.
One nit is inline.
Merge state: dirty. README.md, RUNBOOK.md and tests/install-host.test.sh conflict with main's ab347c1 (the digest-keyed jail path /srv/sbx/jail/j<12 hex>). When rebasing, keep main's jail wording in the uninstall lines.
Author: webchang (MEMBER — maintainer)
Areas reviewed: Shell, systemd unit, Docs, Tests
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (16/16) on the old base
AI-assisted review, approved by a maintainer before posting.
| log "not a worker id: '$id'; nothing reaped" | ||
| exit 0 | ||
| fi | ||
| [[ "$TIMEOUT" =~ ^[0-9]+$ ]] || { log "SBX_REAP_TIMEOUT='$TIMEOUT' is not whole seconds; using 10"; TIMEOUT=10; } |
There was a problem hiding this comment.
nit: ^[0-9]+$ accepts 08/09. Then $((TIMEOUT * 10)) (l.93) aborts with "value too great for base", so the script exits 1 before it waits or logs. The kill has already been sent and the - prefix hides the failure, but the "never fails / always logs" promise breaks. Use ^[1-9][0-9]*$ (or 10#$TIMEOUT), and consider capping it below TimeoutStopSec=30 (e.g. ≤ 25). Above that, systemd SIGKILLs the step mid-wait.
clawgenti
left a comment
There was a problem hiding this comment.
- must-fix: the branch no longer merges into
main(GitHub reportsCONFLICTING):deploy/sbx/README.mdanddeploy/sbx/RUNBOOK.mdconflict with what landed since the base86d63503(#757, #767). Rebase and re-runmake test-deploy. The PR body already expects overlaps with #782/#799; this one is withmainitself.
The reaper does what the PR says: it touches only immediate pool-<digits> children of sbx.slice/sbx-<id>.slice (the same rule as isPooledCgroupDirName), the id check matches valid_id, and SBX_LIBEXEC_DIR is validated before install_units puts it into the sed replacement. One suggestion is inline: a leading-zero SBX_REAP_TIMEOUT breaks the "always exits 0" promise.
- Author: webchang (MEMBER — maintainer)
- Areas reviewed: Shell (
reap-vms.sh,install-host.sh), systemd unit ([email protected]), tests (install-host.test.sh), docs (README, RUNBOOK §10/§12) - Agent/IDE config (.claude/.vscode): none
- Commits: 2 commits, all signed-off: yes
- CI status: passing (all 16 checks green, including deploy-scripts, deploy-scripts-bash32 and shellcheck). Merge state is
DIRTY(conflicts withmain).
Verified by:
bash deploy/sbx/tests/install-host.test.shon the PR head: 42 ok, exit 0- shellcheck 0.11 over
deploy/sbx/*.shand the test, diffed againstmain: no new warnings. One new info-level SC2015 inreap-vms.sh:69, below CI's-S warning git merge-tree origin/main pr-800: conflicts in README.md and RUNBOOK.md.gh pr view --json mergeablereportsCONFLICTING- ran
reap-vms.shagainst a fake cgroup tree withSBX_REAP_TIMEOUT=08:value too great for base, thenpolls: unbound variable, exit 1 - read
remove_shared_unitsand the manifestunithandling: the helper is removed with the last worker's uninstall, as claimed
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| log "not a worker id: '$id'; nothing reaped" | ||
| exit 0 | ||
| fi | ||
| [[ "$TIMEOUT" =~ ^[0-9]+$ ]] || { log "SBX_REAP_TIMEOUT='$TIMEOUT' is not whole seconds; using 10"; TIMEOUT=10; } |
There was a problem hiding this comment.
suggestion: ^[0-9]+$ accepts a leading-zero value such as 08 or 09, and then polls=$((TIMEOUT * 10)) (line 93) reads it as octal and aborts: 08: value too great for base. Under set -u the next line then fails on polls: unbound variable, so the script exits 1 right after the kill, without the wait or the still populated log. The - on ExecStopPost= keeps the stop from failing, but the header's "it exits 0" contract and the wait both break. I reproduced it against a fake cgroup tree with SBX_REAP_TIMEOUT=08.
Suggested fix: normalise it to base 10 after the check:
[[ "$TIMEOUT" =~ ^[0-9]+$ ]] || { log "SBX_REAP_TIMEOUT='$TIMEOUT' is not whole seconds; using 10"; TIMEOUT=10; }
TIMEOUT=$((10#$TIMEOUT))Conflicts in deploy/sbx/README.md, RUNBOOK.md and tests/install-host.test.sh, both sides kept: main's digest-keyed jail path and short test temp directory, and this branch's sbx-reap-vms.sh among the shared files and its trap that ends the reaper tests' leftover processes. Refs rossoctl#795 Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Re-review at 5b2b4e3. That head is one merge of main (d4babb8) into d8ec057, which I approved earlier. I checked it with git show --remerge-diff. It has three hand-resolved conflicts, and each one keeps both sides correctly:
- README.md and RUNBOOK.md: the uninstall lines now list
sbx-reap-vms.shamong the shared files and use main's digest-keyed jail path/srv/sbx/jail/j<12 hex of the id>. That covers the rebase note from my last review. - tests/install-host.test.sh: main's short
mktemp -d /tmp/ih.XXXX(the jail path has to fit a Unix socket) now sits alongside this branch's trap that kills leftover reaper-testsleeps.
install-host.sh auto-merged. Its diff against main contains only this PR's own changes, and reap-vms.sh and the unit have not changed since d8ec057. All 16 checks are green on this head, including deploy-scripts and deploy-scripts-bash32, and the PR now merges cleanly.
My nit on reap-vms.sh:40 (leading-zero SBX_REAP_TIMEOUT → octal abort) is still open, and so is clawgenti's matching comment. Neither has a reply. It does not block merging.
Author: webchang (MEMBER — maintainer)
Areas reviewed: merge resolution (Docs, Shell tests); install-host.sh auto-merge
Agent/IDE config (.claude/.vscode): none
Commits: 1 new merge commit, signed-off: yes
CI status: passing (16/16); mergeable: clean
AI-assisted review, approved by a maintainer before posting.
|
need rebase and resolve conflicts |
Conflicts in install-host.sh and tests/install-host.test.sh: main's SBX_WORKER_BIN ExecStart substitution and its sbx.slice stop, plus this branch's VM reaper install, its ExecStopPost substitution and its tests. Both sides kept. Refs rossoctl#795 Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up review at 9a14762: a merge of main (634781a) into the branch, answering the "need rebase and resolve conflicts" request. Reviewed the merge by diffing the PR's net change against its base before the merge (5b2b4e3 vs d4babb8) and after (9a14762 vs 634781a). The only differences are two hand resolutions, and both are right. (1) install-host.sh install_units: the new -e ExecStopPost= sed expression joins main's multi--e form with the ExecStart= rewrite, so all three rewrites apply to [email protected]. (2) install-host.test.sh: the last-uninstall pass message now combines main's "stops sbx.slice" with the reaper removal. The PR adds nothing else.
Author: webchang (MEMBER — maintainer)
Agent/IDE config (.claude/.vscode): none
CI: pending on this head when drafted (deploy-scripts, deploy-scripts-bash32, check); the rest pass.
Still open from earlier, non-blocking: reap-vms.sh:40 accepts SBX_REAP_TIMEOUT=08/09 through ^[0-9]+$, and bash arithmetic then reads them as invalid octal.
Upstream main (949dc5f) adds SBX_WORKER_AT_BOOT (rossoctl#799), the worker stop's VM reap (rossoctl#800), and template tags, edits and owner transfer (rossoctl#774). This branch claims no API version. Conflicted: - deploy/sbx/install-host.sh (main): both checks kept, this branch's SBX_READ_AHEAD_KB refusal and then main's SBX_WORKER_AT_BOOT one, each before the host is touched. Also changed in the merge: - install-host.sh's header, the README and the RUNBOOK's read-ahead section say sbx-read-ahead.service is enabled whatever SBX_WORKER_AT_BOOT says, so a host agent's later worker starts read ahead too; install-host.test.sh checks it (a worker installed with SBX_WORKER_AT_BOOT=0 still enables the read-ahead, not the worker). - deploy/sbx/README.md: a blank line after the read-ahead paragraph, which ran into the next one. - [email protected] (auto-merged): main's ExecStopPost and this branch's After=sbx-read-ahead.service both kept. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…te lifecycle stack Upstream main 0dc3d01 (API 1.21.0) carries the reviewed, final form of the features this branch held in early, integrated versions, through the PRs filed from this fork (rossoctl#755-rossoctl#776, rossoctl#781, rossoctl#782, rossoctl#784-rossoctl#786, rossoctl#789-rossoctl#794, rossoctl#798-rossoctl#800) and the maintainer's lease mode, grants and lease clients (rossoctl#763, rossoctl#802, rossoctl#807, rossoctl#808, rossoctl#810, rossoctl#812, rossoctl#814). Where upstream has a feature, upstream's version wins: its code, tests, openapi, CHANGELOG (byte identical), docs and specs. The fork was 736 commits behind and 390 ahead (merge base dd0ce71). Conflict resolution (148 files, 82 both-modified, 66 both-added): every conflicted file is upstream's side as is (byte identical to 0dc3d01). No conflicted file differs from 0dc3d01 in this commit. One file merged without a conflict and was set back to upstream's: - packages/mocactl/src/sbx/push.ts: the auto-merge added the fork's baselineAtHead a second time beside upstream's own (fb28e06's function, already upstream); upstream's file as is. With that, this commit's tree is 0dc3d01's plus the 18 files only the fork has (below). Every other file the fork changed is upstream's. Conflicted files, all resolved to upstream's side (0dc3d01): - deploy/k8s/overlays/ocp-combined/kustomization.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-addressing.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-relay.yaml (AA) - deploy/microvm/P4-ON-P6.md (UU) - deploy/microvm/build-rootfs.sh (UU) - deploy/microvm/build-snapshot.sh (UU) - deploy/microvm/setup-microvm.sh (UU) - deploy/microvm/tests/build-rootfs.test.sh (UU) - deploy/microvm/tests/build-snapshot.test.sh (UU) - deploy/microvm/tests/setup-microvm.test.sh (UU) - deploy/sbx/README.md (UU) - deploy/sbx/RUNBOOK.md (UU) - deploy/sbx/host-agent.sh (AA) - deploy/sbx/install-host.sh (UU) - deploy/sbx/sbx-host-agent-wanted.service (AA) - deploy/sbx/sbx-host-agent-wanted.timer (AA) - deploy/sbx/sbx-host-agent.service (AA) - deploy/sbx/[email protected] (UU) - deploy/sbx/setup.sh (UU) - deploy/sbx/template-onboarding/GUIDE.md (AA) - deploy/sbx/template-onboarding/ONBOARDING.md (AA) - deploy/sbx/template-onboarding/README.md (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.gate-record.json (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.json (AA) - deploy/sbx/template-onboarding/governance/GATING-RULES.md (AA) - deploy/sbx/template-onboarding/governance/PROCESS.md (AA) - deploy/sbx/template-onboarding/governance/README.md (AA) - deploy/sbx/template-onboarding/template-build.sh (AA) - deploy/sbx/template-onboarding/template-register.sh (AA) - deploy/sbx/template-onboarding/tests/examples.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-build.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-register.test.sh (AA) - deploy/sbx/template-onboarding/verify-provenance.py (AA) - deploy/sbx/templates-check.sh (AA) - deploy/sbx/tests/host-agent.test.sh (AA) - deploy/sbx/tests/install-host.test.sh (UU) - deploy/sbx/tests/overlay-combined.test.sh (AA) - deploy/sbx/tests/setup.test.sh (UU) - deploy/sbx/tests/templates-check.test.sh (AA) - deploy/vm/tests/setup-vm.test.sh (UU) - docs/api/CHANGELOG.md (UU) - docs/api/harness-openapi.yaml (UU) - docs/api/openapi.yaml (UU) - docs/concepts/sandboxes-and-tiers.md (UU) - docs/reference/change-policy.md (UU) - docs/reference/cli-mocactl.md (UU) - docs/reference/configuration.md (UU) - docs/reference/http-api.md (UU) - docs/sbx/user-guide.md (UU) - docs/specs/2026-10-15-sbx0-internal-sandbox-service-design.md (UU) - docs/specs/2026-10-30-session-sandbox-templates-design.md (AA) - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md (AA) - docs/specs/2026-11-05-combined-control-plane-design.md (AA) - docs/specs/2026-11-08-enrollment-and-roles-api-design.md (AA) - docs/specs/2026-11-08-sandbox-egress-records-design.md (AA) - docs/specs/2026-11-08-subject-trust-gate-records-design.md (AA) - docs/specs/README.md (UU) - harness/src/run-turn.ts (UU) - harness/src/sandbox-affinity.ts (UU) - harness/src/select-sandbox.ts (UU) - harness/test/select-sandbox-templates.test.ts (AA) - harness/test/turn-seed.test.ts (AA) - harness/test/turn-stream.test.ts (UU) - packages/control-plane/src/activation-lock.ts (AA) - packages/control-plane/src/activation.ts (AA) - packages/control-plane/src/egress-handlers.ts (UU) - packages/control-plane/src/egress-log.ts (AA) - packages/control-plane/src/errors.ts (UU) - packages/control-plane/src/exchange.ts (UU) - packages/control-plane/src/handler-util.ts (UU) - packages/control-plane/src/handlers.ts (UU) - packages/control-plane/src/host-handlers.ts (AA) - packages/control-plane/src/identity.ts (UU) - packages/control-plane/src/index.ts (UU) - packages/control-plane/src/main.ts (UU) - packages/control-plane/src/member-handlers.ts (AA) - packages/control-plane/src/members.ts (AA) - packages/control-plane/src/ownership.ts (UU) - packages/control-plane/src/provenance.ts (AA) - packages/control-plane/src/routes.ts (UU) - packages/control-plane/src/sandbox-config.ts (UU) - packages/control-plane/src/sandbox-handlers.ts (UU) - packages/control-plane/src/server.ts (UU) - packages/control-plane/src/template-catalog.ts (AA) - packages/control-plane/src/template-policy.ts (AA) - packages/control-plane/src/token.ts (UU) - packages/control-plane/test/activation.test.ts (AA) - packages/control-plane/test/egress-redis.test.ts (AA) - packages/control-plane/test/errors.test.ts (UU) - packages/control-plane/test/host-flow.test.ts (AA) - packages/control-plane/test/members.test.ts (AA) - packages/control-plane/test/openapi-contract.test.ts (UU) - packages/control-plane/test/provenance.test.ts (AA) - packages/control-plane/test/repository-allowlist.test.ts (AA) - packages/control-plane/test/route-authz-enumeration.test.ts (UU) - packages/control-plane/test/route-profile.test.ts (UU) - packages/control-plane/test/routes.test.ts (UU) - packages/control-plane/test/sandbox-egress.test.ts (AA) - packages/control-plane/test/sandbox-handlers.test.ts (UU) - packages/control-plane/test/session-templates.test.ts (AA) - packages/control-plane/test/subject-trust.test.ts (AA) - packages/control-plane/test/template-admin.test.ts (AA) - packages/control-plane/test/template-catalog.test.ts (AA) - packages/control-plane/test/template-create.test.ts (AA) - packages/knative-server/src/server.ts (UU) - packages/knative-server/src/turn-auth.ts (UU) - packages/knative-server/test/turn-auth.test.ts (UU) - packages/mocactl/src/api/errors.ts (UU) - packages/mocactl/src/api/frames.ts (UU) - packages/mocactl/src/cli.ts (UU) - packages/mocactl/src/core/session-manager.ts (UU) - packages/mocactl/src/core/session-options.ts (UU) - packages/mocactl/src/headless.ts (UU) - packages/mocactl/src/sbx/api.ts (UU) - packages/mocactl/src/sbx/call-record.ts (AA) - packages/mocactl/src/sbx/cli.ts (UU) - packages/mocactl/src/sbx/commands.ts (UU) - packages/mocactl/src/sbx/dry-run.ts (AA) - packages/mocactl/src/sbx/exec.ts (UU) - packages/mocactl/src/sbx/run.ts (UU) - packages/mocactl/src/sbx/templates.ts (AA) - packages/mocactl/test/contract.test.ts (UU) - packages/mocactl/test/harness.test.ts (UU) - packages/mocactl/test/headless.test.ts (UU) - packages/mocactl/test/helpers/sbx.ts (UU) - packages/mocactl/test/run-record.test.ts (AA) - packages/mocactl/test/sbx-admin-subjects.test.ts (AA) - packages/mocactl/test/sbx-cli.test.ts (UU) - packages/mocactl/test/sbx-egress.test.ts (AA) - packages/mocactl/test/sbx-exec.test.ts (UU) - packages/mocactl/test/sbx-templates.test.ts (AA) - packages/mocactl/test/session-manager.test.ts (UU) - packages/mocactl/test/session-options.test.ts (UU) - remote-worker/cmd/microvm-worker/main.go (UU) - remote-worker/cmd/microvm-worker/template_record.go (AA) - remote-worker/cmd/microvm-worker/template_record_test.go (AA) - remote-worker/cmd/microvm-worker/verify_cache.go (AA) - remote-worker/cmd/microvm-worker/verify_cache_test.go (AA) - remote-worker/internal/egress/audit_test.go (UU) - remote-worker/internal/session/labels.go (UU) - remote-worker/internal/vmpool/errors.go (UU) - remote-worker/internal/vmpool/guestconn.go (UU) - remote-worker/internal/vmpool/guestconn_test.go (UU) - remote-worker/internal/vmpool/launcher_firecracker.go (UU) - remote-worker/internal/vmpool/launcher_firecracker_egress_unix_test.go (UU) - remote-worker/internal/vmpool/snapshot.go (UU) - remote-worker/internal/vmpool/snapshot_test.go (UU) - remote-worker/internal/vmpool/verifycache.go (AA) Fork-only files, kept as they are (upstream has no such file): - deploy/sbx/mint-login.sh, deploy/sbx/tests/mint-login.test.sh: a test login minted with the deployment's signing key. Checked against upstream: makeSigner/mint, SANDBOX_API_ISSUER, the moca-mu1 Secret and its label, the env keys it reads and mocactl's sbx-auth.json shape are all still upstream's. - deploy/sbx/template-onboarding/deck/ (README, requirements, the two generators, deck_kit.py, the two PDFs, .gitignore): the fork's decks. - deploy/sbx/template-onboarding/GUIDE.pdf: regenerated from upstream's GUIDE.md in a later commit. - deploy/sbx/template-onboarding/governance/GAPS-AND-ASSUMPTIONS.md and INVENTORY-2026-11-02.md: the fork's register and inventory. - docs/specs/2026-11-09-cold-start-pacing-design.md, 2026-11-09-memory-aware-placement-design.md and 2026-11-10-mocactl-template-commands-design.md: the fork's design notes; upstream folded their content into its lifecycle spec (§6.4 memory, §6.5 pacing) and the user guide (mocactl). - docs/tools/gen_pdf.py, docs/tools/gen_toc.py: the PDF and TOC tools. Fork-only behaviour, decided one by one (from git log 0dc3d01..f125c02 --no-merges, checked against 0dc3d01): Ported onto upstream's code, each in its own commit after this one: - The pinned-session retire guard (c571226): a retire is refused (409 build_in_use) while an active Moca Pi session is pinned to the build. Upstream's buildsInUse checks live sandboxes only and its comment says pinned sessions are still to be checked. - Reuse only while a host holds the snapshot (G29, 521efe5): upstream reuses any registered build with the same inputs; its own lifecycle spec (§4, Reuse) says a registered build is reused only while a host reports holding its snapshot. - install-host.sh --uninstall-shared and the mounted legacy jail guard (5e66397): upstream has neither. - GUIDE §4b.4's base example without skip_git_identity_check (f125c02): upstream applies X12 under every profile, so its example create would be refused. - Links from upstream's READMEs to the fork-only files above. Dropped, because upstream's design replaces them on purpose: - Removal of admin-rejected builds: upstream stops them and never removes them (the user's decision in rossoctl#786). - The harness-profile catalog's fallback to SH_SESSION_TEMPLATES (902255b): upstream serves the harness profile the store's templates only (its test was renamed so); a combined plane is unaffected. - The fork's register ids (G-numbers), window dates and results pointers inside the documents upstream now has (RUNBOOK, README, GUIDE, ONBOARDING, PROCESS, GATING-RULES, P4-ON-P6, the specs): upstream's text wins; the fork's own documents above keep them. - The fork's image-builder-specific wording in GATING-RULES.md: upstream's generic wording (the image builder) is taken as is. Dropped, could be re-proposed (no upstream equivalent, but the port is an API change or its intent upstream is unclear): - TurnPlacement.template, a turn result naming the session's sandbox template (9d6004d): a harness API field; upstream's CHANGELOG is kept byte identical. - An imported build's catalog entry and create record carrying the declared seed (20d0995): sessions are seeded the same (upstream falls back to the declared seed); only the field in the catalog API goes. - mocactl: sbx create --seed checking the seeded HEAD against the spec's baseline_commit; activate --wait stopping at once on not_held or memfile_mismatch; ApiError's readiness, readinessReason and queuePosition in refusals; an admin write refused when the control plane URL came only from the login; the admin-write issuer check for the combined profile; the dry run's X1.offline check and its guest_mb and git-less advice; the quota, policy and build lines' extra fields (quotaSource, selfAttest, allowedRepositories, heldBy, attestation). Upstream's reviewed client (rossoctl#767, rossoctl#768) left them out; the server still enforces every rule. Already upstream (not lost): build reuse (G21), the verify cache, the host agent's --keep-shared removals, read-ahead, the hash_version 2 check in the microVM worker, M7, G39, G42, G43, G48, G49, G50, mocactl --record, --version, the minted login's own control plane, activate --wait sizing, and every other fork feature listed in the task. The relay's per-client tokens: not on this branch (the fork's sandbox-relay main.ts is older upstream code), so nothing to resolve. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #795. Two signed-off commits on main (86d6350), in
deploy/sbxonly.What it does: stopping a template worker now takes its VMs with it, whatever path the worker's own exit takes. The VMs live in sibling
pool-Ncgroups under the worker's slice, whichKillMode=control-groupdoesn't reach.[email protected]):ExecStopPost=-/usr/local/libexec/sbx-reap-vms.sh %i. It runs after the worker exits, on a clean stop, a crash or a timeout. The-means it can never fail the stop.deploy/sbx/reap-vms.sh, installed as$SBX_LIBEXEC_DIR/sbx-reap-vms.sh):valid_idrule, and derives the slice assbx.slice/sbx-<id>.slice. IfSH_PARENT_CGROUPdisagrees, it logs that and still touches only the derived slice;pool-<n>children, the same names the worker's own orphan sweep accepts. It never touches the service's own cgroup or another worker's slice;1tocgroup.kill. Wherecgroup.killis absent (kernels before 5.14) or the write fails, it SIGKILLs the pids incgroup.procs;SBX_REAP_TIMEOUT(default 10 s, inside the unit'sTimeoutStopSec=30) forcgroup.eventsto showpopulated 0;sbx-reap-vms:lines to the unit's journal, and removes no cgroup, since the worker reuses them.install-host.sh: installs the helper and points the unit at it. The helper is recorded in the manifest under the existingunitkind, so the last worker's uninstall removes it with the other shared files.SBX_LIBEXEC_DIRand the helper's presence are checked before systemd is touched.Scope:
pool-<n>cgroups only. SBX0's workers run Firecracker under jailer's pooled cgroups. The legacyvm-<n>directories and Cloud Hypervisor'svm-vm-<n>.scopeunits that the orphan sweep also accepts don't occur here, and a CH scope is its own unit that systemd stops.Not in this PR: a worker-side wait for in-flight restores on SIGTERM, so a clean stop never needs the post step, would be a possible follow-up. The unit's step stays as the guarantee either way.
Tests (
deploy/sbx/tests/install-host.test.sh):SBX_LIBEXEC_DIRis refused beforesystemctl;pool-0(throughcgroup.kill) andpool-1(the SIGKILL fallback) are emptied before it returns, and an emptypool-2is left unwritten. The service's cgroup, apool-x, a.scopeand another worker's slice are untouched;declare -A), as on main, after the new cases pass;make test-deploypasses.Not yet run on a KVM host. The live check is the issue's: stop a worker during its pool fill, then confirm no
pool-*cgroup with processes and no Firecracker process is left.Expected overlaps: #782 and #799 also change
install-host.shand the worker unit, so whichever merges later rebases a few lines.Assisted-By: Claude Code