Skip to content

Reclaim creating-state stale VMs safely; document dense-node host tuning - #60

Merged
CMGS merged 5 commits into
mainfrom
robust/stale-create-sweep
Aug 5, 2026
Merged

Reclaim creating-state stale VMs safely; document dense-node host tuning#60
CMGS merged 5 commits into
mainfrom
robust/stale-create-sweep

Conversation

@CMGS

@CMGS CMGS commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

Two robustness items consuming the cocoon v0.5.8 line:

  1. Startup sweep: vm reconcile-stale-create for creating-state records. The reconcile sweep force-removed every unowned sbx- VM, but rm --force queues on the VM ops lock — against a clone still in flight from a previous daemon life it waits, then deletes the VM the clone just produced. Creating-state records now go through cocoon's stale-create verb (vm: add reconcile-stale-create verb over a shared ownerless-create reclaim cocoon#173), which collects only when the ops lock is free:

    • collected/not-found → gone, no forced remove;
    • busy → left to its in-flight owner and queued for the reap tick, which re-runs the verb until it converges (collected/not-found, or not-creating → normal removal); its tap stays out of the reconcile-time egress table sweep meanwhile;
    • not-creating → the record moved on under the lock; normal removal;
    • verb error (cocoon < v0.5.8) → fall back to the previous forced remove, so older fleets keep today's behavior.

    The verb call is cancellation-immune like removeVM: a SIGTERM landing mid-reconcile must not skip the busy check and fall through to the forced remove it guards (mutation-verified by TestRemoveStaleVMCanceledCtxStillChecksBusy).

  2. docs/deploy.md: dense-node host tuning + control-plane CPU fence. Records what the dense-node measurement rounds settled on: quiet kernel console (bridge-port printk runs synchronously to every registered console while holding rtnl — one attach 44 ms noisy vs 3 ms quiet), udev kept off sandbox taps (~4x fill), an explicit ~64 refill_concurrency for egress-heavy nodes (rtnl collapses rather than plateaus; the auto default overshoots), and cocoon's post-v0.5.8 cgroup_cpus cpuset fence + per-VM cgroup scopes keeping reserved cores free for sandboxd, its cocoon invocations, and the OS.

Hot-path cost

Zero. The verb runs only in the startup sweep, one call per creating-state stale VM (a crash-recovery-only condition), inside the existing runBounded budget. The docs change is documentation.

Evidence

  • make go-test green across all modules; make go-lint 0 issues on both GOOS after a lint cache clean; asl ./... clean on both GOOS for the sandboxd and e2e modules.
  • New tests: outcome tables for the startup sweep and the reap-tick retry (collected / not-found / busy / not-creating / verb-error), busy keeps the tap in the egress sweep's keep set and lands in the retry queue, canceled-ctx cancellation-immunity (fails if WithoutCancel is removed — verified by mutation), running-state orphans never touch the verb.
  • Docs claims cross-checked against cocoon source: the verb and its four outcomes are in v0.5.8 (git tag --contains), the cgroup work is post-v0.5.8 (untagged), cgroup_cpus is a real config key, and the auto refill_concurrency formula yields 256 on 384 cores as stated.

CMGS added 5 commits August 5, 2026 18:47
… verb

The startup sweep force-removed every unowned sbx- VM, but rm --force
queues on the VM ops lock: against a clone still in flight from a
previous life it waits, then deletes the VM the clone just produced.
cocoon v0.5.8's vm reconcile-stale-create collects a creating record
only when that lock is free, so the sweep now routes creating-state
records through it — busy records are left to their owner (cocoon's GC
collects them on its own cadence), and a verb error (older cocoon)
falls back to the forced remove. The verb call is cancellation-immune
like removeVM: a canceled ctx must not skip the busy check and fall
through to the remove it guards.
Record the fleet recipe dense-node measurement rounds settled on:
quiet kernel console (bridge-port printk holds rtnl), udev kept off
sandbox taps, an explicit ~64 refill_concurrency for egress-heavy
nodes (rtnl collapses rather than plateaus), multi-daemon sharding
behind the mesh, and cocoon's post-v0.5.8 cgroup_cpus fence keeping
reserved cores free for the control plane. Also note the startup
sweep's stale-create path in Running.
Batch-end /code+/simplify+comment pass over the branch (whole-repo scans
against the 2026-08-02 clean baseline). Applied: two misattached doc
comments re-anchored to their declarations (sdk files_test fakeSandbox,
silkdtest readChunk/Fake split); interface-label and restating comments
deleted (peer Pull/pullFrom, pty_test); two edit-narration test docs
compressed to their invariants (peer_test dedup, checkpoint_test
redirect); AppendBulkRequest godoc drops the perf-benefit phrase;
sysutil.rs module doc no longer overclaims that all unsafe lives there;
retryRemoval adopts the package's switch-with-init form; the busy log
line says queued-for-retry, which is what now happens; the two identical
stale-create test tables share one row type.
Three approved cuts, net -14 prod: claimFollow extracts the
claim->redirect->no_redirect-retry skeleton Client.New and
Checkpoint.New each hand-rolled; doJSONPtr collapses the four
doJSON-then-pointer tails (info, drain x2, pools); logSweepResult
single-sources the benign-sweep switch-log block copy-pasted across
archive/idle/reap — whose copies had already drifted (the reap-archive
failure line lost the word sandbox its success line carries).
@CMGS
CMGS merged commit 9548928 into main Aug 5, 2026
3 checks passed
@CMGS
CMGS deleted the robust/stale-create-sweep branch August 5, 2026 12:38
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