Repository navigation
v1.91.341.0 fix(ubicloud): no zombie VMs: owner required, 3h TTL, legacy sweep, leftover line (GST-118) - #3652
Merged
Merged
Conversation
…UBICLOUD left line (GST-118) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
…s override, --keep, leak exit status, missing left= line) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ne via UBI_LEFT_FILE, pregate TTL from its deadline) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…d remote pregate Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…(GST-324) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ombie-vms Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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.
What changed
A
/ubicloudrun now ends withUBICLOUD: left=0, the runner's own check that its VM is gone, and new VMs carry a 3h TTL instead of 4h.Text version
Why
On 2026-10-29 the shared Ubicloud project held 16 VMs (256 vCPUs). Three were more than 3 hours old, belonged to nobody anyone could name, and had cost about $15.90 before they were destroyed. None of the 16 names carried a TTL, because they came from an older copy of the runner, so nothing would ever have reaped them. Now a VM can't be created without an owner, every name carries a lifetime that the next
upanywhere enforces, a lane's own old TTL-less VMs get swept after 4 hours, and every run reports whether its own VM is gone.Blast radius
Every caller of
scripts/ubicloud/ubi-runner.shthat creates a VM (up,run,verify,bun run test:ubicloud, the keyed remote pregate, the Drive ubicloud skill oncesync.shruns) now needsUBI_OWNER, and fails before any API call withUBI_OWNER_REQUIREDand the fix line when it is missing (tested: ubicloud-runner.test.ts "up and run refuse without UBI_OWNER before any API call"). The TTL-less legacy sweep touches only the caller's ownubirun-<UBI_OWNER>-*names that are 4 hours old or more, so another lane's TTL-less VM, an untagged one, and names under other prefixes are never reaped; only a TTL lets reap judge another lane's VM (tested against a fake API withubirun-gbra240-…, untagged andteam-dbnames, and the test fails on the earlier any-owner sweep). An earlier version of this branch swept every owner's TTL-less VMs, and one of its remote pregates destroyed 22 of gbrain's eval VMs (GST-324); that is what the owner scoping fixes.Approvals
Source: gstack-approvals record for garrytan/gst-118-no-zombie-vms (display only; not an approval citation).
Summary
A lane that died mid-run, or a stale copy of the runner, could leave a VM billing in the shared project with no owner and no TTL. The runner now refuses to create a VM without
UBI_OWNER, defaults the TTL to 3 hours (UBI_TTL_HOURS, 1-999, checked only when a VM is created), and its reap, which everyupruns first, also destroys the caller's ownubirun-<UBI_OWNER>-*names with no TTL once they areUBI_LEGACY_HOURSold (default 4); another owner's or an untagged TTL-less VM is never touched.runandverifyend withUBICLOUD: left=<0|1|unknown> owner= vm= others=, checked against the project's VM list after teardown; anything butleft=0turns a passing command into exit 1 and prints thedowncommand.The remote pregate refuses without
UBI_OWNER(PREGATE_REMOTE_OWNER_REQUIRED), names its VM with a TTL taken from its stop deadline plus 15 minutes (-t1today), and reportsPREGATE_REMOTE_INFRAunless the runner wroteleft=0toUBI_LEFT_FILE. It never reads that line from the remote command's output. Docs and the/ubicloudskill say the same.Behavior changes.
UBI_TTL_HOURS=0(no TTL) is refused; a lane's own TTL-lessubirun-names are no longer exempt from reap (sync this runner into a lane only after its own TTL-less VMs over 4 hours are finished, or run withUBI_REAP=0until then);up/run/verifywithoutUBI_OWNERrefuse instead of using a random per-machine id. A refusedupstill writes the old randomowner-idfile, because the top-level owner lookup runs first; no VM ever carries that id (kept on purpose, see Plan Completion).Test Coverage
Coverage: 92% value-weighted (23 of 25 paths rated ★★ or better). Test value: 0 tests written, 0 rejected by the authoring gate, 4 existing tests extended, 1 path weakly covered.
cmd_upis checked by a source-text assertion only (★).run -n NAME.Tests ran: pregate.json/remote_gate 18700 (0 failed, tree 0dbf99d5e107)
Pre-Landing Review
Pass 1 found two blocking defects, both fixed in 1923151: TTL validation at startup blocked
downandreap(adversarial native), and theleft=line was parsed from an async log that could be missing or spoofed by remote output (outside voice, openai/gpt-6.1-sol; security raised the same as informational). Six informational findings were fixed in the same commit; eight were skipped with reasons. Pass 2 found nothing at the blocking floor. The final remote pregate then caught aspawnSyncwithout a timeout in one of pass 1's new tests (test/spawnsync-timeout-tripwire.test.ts), fixed in 715e3a1 and cleared by one fix-check reviewer. After that, the any-owner legacy sweep destroyed 22 of gbrain's eval VMs during this /ship's first remote pregate (GST-324). 51af23e scopes the sweep to the caller's own VMs; a second fix-check found nothing at the floor and three informational items: a lane that syncs this runner while its own TTL-less VMs are over 4 hours old loses them; the owner-less reap assertion can't fail without a pre-written owner id; owners longer than 12 normalized characters collide.REVIEW_LOOP: passes=2 blocking_found=2 deferred=0 noted=11 fixed=8 scope=frozen fix_checks=2 dispatches=13
Gate edits: none detected (GATE_SCAN tagged=0 at 51af23e)
Outside review: openai/gpt-6.1-sol on pass 1, completed. The Codex CLI is not installed, so the Codex structured pass is unavailable (missing coverage).
Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
scripts/ubicloud/pregate-remote.sh:258Nothing tests that left= is read only from UBI_LEFT_FILE. The stub tees the same line to stderr and to the file, and the 'none' row prints nothing at all. If the parser went back to reading "$log", every pregate test would still pass, so the spoofing fix in item 2 has no regression test.scripts/ubicloud/ubi-runner.sh:806No test covers the three name-classification log branches in cmd_run (grep for 'no TTL' in test/ubicloud-runner.test.ts finds nothing). The branches also do not match vm_rows. The TTL branch promises a reap for any name ending in -t, such as '-n box-t3' or a four-digit TTL. vm_rows only computes expires for prefixed names with a TTL of 1-3 digits, so the reaper never reaps those names. The legacy branch skips the owner-less 'ubirun--' form that the reaper does match, so for those names it wrongly says 'nothing reaps it'.scripts/ubicloud/pregate-remote.sh:221Tests only check the VM TTL derived from stop_after at its t1 value (every pregate test regex hard-codes -t1). A regression back to a literal -t1, or a broken rounding formula, would pass, and a longer cap wall would then produce VMs the reaper destroys mid-run.scripts/ubicloud/ubi-runner.sh:808Fix (4) left the run log's reap promise out of step with the reaper. vm_rows (lines 307-313) treats a name as reapable when it matches the prefix-owner-epoch form or the ownerlessubirun-<epoch>-form, and it counts a TTL only when the name has an epoch and a 1-3 digit-tsuffix. cmd_run's log uses its own regexes instead, so it is wrong in both directions. A-n ubirun-1761500000-xname, which the legacy sweep does reap, gets told 'nothing reaps it'. A-n myvm-t3or-n ubirun-x-t1234name, which reap never touches, takes the first branch and is told 'any later run of this script reaps it'. The cost is a misleading log line, not a leaked VM, because the printeddowncommand is still correct; but this second copy of the name grammar will drift again.scripts/ubicloud/pregate-remote.sh:223UBI_LEFT_FILE is $logs/run.log.left, inside the same $logs directory that both --pull entries untar remote-produced archives into, and the pulls run before teardown. A VM whose shell controls thetar -czf -stream (for example through ~/.bashrc on the VM) could plant run.log.left. If the planted file has no trailing newline, the runner's>>append joins onto that line and the sed reads left=0. If the runner dies before leftover(), the planted file is read as-is. The impact is small: teardown and the VM-list check run locally and the remote cannot keep the VM alive, so this only hides a destroy that also failed locally. Still, it undercuts the doc's claim that the line is 'out of reach of the command's output'.scripts/ubicloud/pregate-remote.sh:239Across a quota retry, the UBI_LEFT_FILE result of attempt 1 is deleted without being checked. The retry trigger greps the whole log, and that log includes the remote command's own output, so a remote test run that fails and prints 'vCPU quota exhausted' sets off a retry. test/ubicloud-runner.test.ts and test/ubicloud-pregate-remote.test.ts both contain that string. If attempt 1 created a real VM and its teardown reported left=1 or left=unknown, attempt 2 runs rm -f "$log.left", and the final check sees only attempt 2's VM. The gate can then report a confirmed cleanup while attempt 1's VM is still running until its TTL reap. The log is copied to attempt-1.log, but .left is not copied and nothing parses either file.scripts/ubicloud/ubi-runner.sh:806Fix 4 is incomplete. The TTL branch still promises a reap for any name that ends in -t, but vm_rows sets expires only when the name has the ubirun-[owner-]- prefix and the TTL is 1 to 3 digits. So a name like -n foo-t3 or ubirun-x--t1000 is told 'any later run of this script reaps it', and nothing ever reaps it. The new elif has the opposite problem: it misses untagged ubirun-- names, which cmd_reap does reap, and labels them 'nothing reaps it'.scripts/ubicloud/ubi-runner.sh:148leftover() appends to UBI_LEFT_FILE with no error handling; under set -e a failed write aborts run_teardown in the EXIT trap, so a clean left=0 run exits 1 and the down hint or --keep log line is skipped. Fails closed.scripts/ubicloud/ubi-runner.sh:325cmd_reap dies on an invalid UBI_LEGACY_HOURS, but up calls it as cmd_reap || log 'reap failed; continuing', so up/run/verify abort instead of continuing; with UBI_REAP=0 the bad value is accepted silently.scripts/ubicloud/ubi-runner.sh:141run -n still validates UBI_TTL_HOURS though the caller supplies the name, so a stale value blocks pregate before any VM exists; any die before create makes pregate print 'left=missing … destroy ubirun-…' for a VM never created (pre-existing misreport).Exploratory QA
One live run on Ubicloud during the build:
UBI_REAP=0 UBI_OWNER=gsta164 gstack-ubi run -s standard-2 -- trueprintedUBICLOUD: left=0(about $0.01). Every remote pregate in this /ship ended withUBICLOUD: left=0 owner=gsta164 ... others=0. The last one ran withUBI_REAP=0and reaped nothing.Design Review
No frontend files changed — design review skipped.
Eval Results
scripts/eval-select.ts --base origin/mainselects no paid probes and no judges, so no evals ran.Greptile Review
No Greptile comments.
Plan Completion
22 plan items: 14 done, 1 changed, 1 partial, 3 not done, 3 not verifiable from the repository.
UBICLOUD:line at the end ofrun/verify, with no separateresourcescommand.upstill writes the randomowner-idfile (no VM carries it; fixing needs a second owner check at top level).lib/pregate/checks/lanes.tsUBI_OWNER=<code>prefix (lanes.ts:420 executes the obligation command, so a literal<code>would break it; the refusal carries the fix); theship/sections/tests.md.tmplsentence (it selected 24 paid probes plus the ship judge). CREW.md'sREMOTE_PREGATEline is the Captain's edit.Verification Results
Focused: test/ubicloud-runner.test.ts, test/ubicloud-pregate-remote.test.ts, test/spawnsync-timeout-tripwire.test.ts, test/skill-md-size-guard.test.ts and test/parity-suite.test.ts, 60 pass, 0 fail at 51af23e; the changed reap test fails on the earlier any-owner sweep.
bun run typecheckclean,gen:skill-docs(default and codex) fresh, parity suite and skill size guard pass (at 1923151; nothing since touches their inputs). Local pregate at 51af23e: stage 1 pass, lanes requires-remote. Remote pregate at tree 0dbf99d5e107 withUBI_REAP=0: 18700 tests, 0 failed, $0.08. macOS and Windows lanes are cleared by dispatched CI runs at 51af23e (below).TODOS
No TODO items completed in this PR.
Documentation
Status: current. No authored doc still claims the TTL-less legacy sweep covers every owner or untagged names; no edits were needed after 51af23e.
Scope: re-audit of
garrytan/gst-118-no-zombie-vmsat 51af23e against base 723b73e, focused on the owner-scoped TTL-less sweep inscripts/ubicloud/ubi-runner.sh(cmd_reapreaps TTL-lessubirun-<owner>-*VMs only when<owner>is the caller'sUBI_OWNER; TTL-expired VMs of any owner are still reaped). Authored docs in scope: docs/ (excluding docs/designs), README.md, CONTRIBUTING.md, CLAUDE.md, AGENTS.md and ubicloud/; 80 files grep-scanned, sweep-relevant sections read in full.Documentation health:
ubirun-<UBI_OWNER>-*names and says another owner's or an untagged TTL-less VM is never reaped)/ubicloudsection: "its own owner's VMs with no TTL once they are 4 hours old")PREGATE_REMOTE_OWNER_REQUIRED,left=failure; no sweep claim)UBI_OWNERlisted as a prerequisite)Coverage: the owner-scoped sweep and
UBI_LEGACY_HOURShave reference coverage (docs/TESTING_INTERNALS.md, runner--help) and how-to coverage (the/ubicloudskill, Step 1). No tutorial is needed for an operator knob. No new public surface lacks documentation.Diagram drift: none; no diagram names the reaper.
Debt: minor wording only. In ubicloud/SKILL.md.tmpl, "(its TTL will reap it)" is loose for another owner's TTL-less VM; the next sentence corrects it. Optional tighten plus regeneration.
Test plan
UBI_REAP=0 UBI_OWNER=gsta164 gstack-pregate --stage tests --remote --spend-cap 2 --timeout 2700 --allow-repo-commands: 18700 tests, 0 failed, tree 0dbf99d5e107,UBICLOUD: left=0, nothing reapedgstack-pregate --allow-repo-commands: stage 1 pass; lanes requires-remote (remote gate, macOS, Windows)bun test test/ubicloud-runner.test.ts test/ubicloud-pregate-remote.test.ts test/spawnsync-timeout-tripwire.test.ts: 60 pass, 0 fail (with the size guard and parity suite)🤖 Generated with Claude Code
Refs GST-118, GST-324.