Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci(ubi-runner): list --mine and gc cover every VM this machine created, whatever UBI_OWNER the run used
garrytan2c058fefac5b
diff --git a/docs/TESTING.md b/docs/TESTING.mdindex 26d7df9ab1..f7b0e23dc2 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -466,6 +466,8 @@ own VMs. `scripts/ubicloud/ubi-runner.sh usage` shows vCPUs by owner.A sleeping machine kills the run with no signal, so teardown never runs: on Capy, run`ci:ubicloud` as a watched background operation. After any interrupted run, check`ubi-runner.sh list --mine` and reap leftovers with `down NAME` (or `gc HOURS`, own VMs only).+Both cover every VM this machine created, whatever `UBI_OWNER` the run used, and the+run's VM names are also in `vms.txt` in its run directory from before provisioning.The project quota is 512 vCPUs, shared with PR CI; a full gate takes 64, or 160 when it is free.In a multi-lane wave, lanes run `ci:ubicloud:diff` or targeted suites (`bundiff --git a/scripts/ubicloud/README.md b/scripts/ubicloud/README.mdindex 6965b3e212..507625214f 100644--- a/scripts/ubicloud/README.md+++ b/scripts/ubicloud/README.md@@ -72,7 +72,10 @@ operation so the machine stays awake. After any interrupted run, checkdestroys your own VMs older than HOURS). A gate VM nobody reaps still diesonce its expiry passes and the operator reaper next runs with `--apply`.-`ubi-runner.sh list --mine` lists your VMs. `ubi-runner.sh usage` prints VMs+`ubi-runner.sh list --mine` lists your VMs: those tagged with your owner tag+and every VM this machine created under any tag (its local state stays until+`down` confirms it gone), so a run started with a different `UBI_OWNER` is still+listed; stderr names the tags it covered. `ubi-runner.sh usage` prints VMsand vCPUs per owner across the project, which shows who holds the shared quota.Each VM runs `scripts/ubicloud/setup-ci-vm.sh`: the pinned Bun fromdiff --git a/scripts/ubicloud/ubi-runner.sh b/scripts/ubicloud/ubi-runner.shindex 1195f6ea79..11999bdfab 100755--- a/scripts/ubicloud/ubi-runner.sh+++ b/scripts/ubicloud/ubi-runner.sh@@ -39,6 +39,12 @@# Stale-VM sweeps are off by default. With UBI_GC_HOURS set to a positive# number, every `up` first destroys this owner's VMs older than that; `gc HOURS`# runs the same sweep on demand. Neither ever touches another owner's VMs.+#+# "This owner's VMs" (`list --mine`, `gc`, the `up` sweep) are the VMs tagged+# with the caller's owner tag plus every VM this machine created under any tag:+# `up` keeps a VM's state here until `down` confirms it gone, so a run started+# with UBI_OWNER=x whose teardown never ran is still found by a later call that+# did not export the same UBI_OWNER.set -Eeuo pipefail# Keep heredoc bodies on temp files, not the pipe window (test/heredoc-pipe-deadlock.test.ts).BASH_COMPAT=50@@ -170,15 +176,22 @@ vm_rows() {done}+# mine_rows: vm_rows for the VMs tagged with this owner or created from this machine (their `up` state is still here).+mine_rows() {+ local loc name owner+ vm_rows | while read -r loc name owner; do+ if [ "$owner" = "$OWNER" ] || [ -f "$(state_dir "$name")/env" ]; then echo "$loc $name $owner"; fi+ done+}+cmd_gc() {local hours=${1:-$GC_HOURS} now loc name ownerif ! [[ "$hours" =~ ^[0-9]+$ ]] || [ "$hours" -eq 0 ]; then die "gc: give HOURS > 0 (or set UBI_GC_HOURS)"; finow=$(date +%s)- vm_rows | while read -r loc name owner; do- [ "$owner" = "$OWNER" ] || continue+ mine_rows | while read -r loc name owner; do[[ "$name" =~ -([0-9]{10})- ]] || continueif [ $(( (now - BASH_REMATCH[1]) / 3600 )) -ge "$hours" ]; then- log "destroying stale $loc/$name (owner $OWNER, older than ${hours}h)"+ log "destroying stale $loc/$name (owner $owner, older than ${hours}h)"cmd_down "$name" -l "$loc" || log "failed to destroy $loc/$name"fidone@@ -187,7 +200,12 @@ cmd_gc() {cmd_list() {case ${1:-} in"") cli vm list ;;- --mine) vm_rows | awk -v o="$OWNER" '$3==o {print $1 " " $2}' ;;+ --mine)+ local rows others+ rows=$(mine_rows)+ others=$(printf '%s\n' "$rows" | awk -v o="$OWNER" 'NF && $3!=o {print $3}' | sort -u | paste -sd, -)+ log "list --mine: owner tag $OWNER plus VMs this machine created${others:+ (also under: $others)}"+ [ -z "$rows" ] || printf '%s\n' "$rows" | awk '{print $1 " " $2}' ;;*) die "list: unknown option $1 (use --mine)" ;;esac}diff --git a/test/scripts/ubi-runner.test.ts b/test/scripts/ubi-runner.test.tsindex 0462261c49..1980d0501c 100644--- a/test/scripts/ubi-runner.test.ts+++ b/test/scripts/ubi-runner.test.ts@@ -194,6 +194,20 @@ describe("stale sweep and ownership", () => {expect(api.events).toEqual([`destroy ubirun-t1-${OLD}-aaaaaaaa`, `removed ubirun-t1-${OLD}-aaaaaaaa`]);});+ it("list --mine and gc also cover VMs this machine created under another owner tag", async () => {+ const api = serve({ seed });+ const other = `ubirun-other-${OLD}-cccccccc`;+ execFileSync("mkdir", ["-p", join(dir, "state", other)]);+ writeFileSync(join(dir, "state", other, "env"), `NAME=${other}\nLOCATION=eu-central-h1\n`);+ const mine = await run(["list", "--mine"], { UBI_OWNER: "t1" });+ expect(mine.stdout.trim().split("\n").map((l) => l.split(/\s+/)[1])).toEqual([`ubirun-t1-${OLD}-aaaaaaaa`, `ubirun-t1-${NOW}-bbbbbbbb`, other]);+ expect(mine.stderr).toContain("list --mine: owner tag t1 plus VMs this machine created (also under: other)");+ const gc = await run(["gc", "1"], { UBI_OWNER: "t1" });+ expect(gc.code).toBe(0);+ expect(api.events.filter((e) => e.startsWith("destroy ")).sort()).toEqual([`destroy ubirun-t1-${OLD}-aaaaaaaa`, `destroy ${other}`].sort());+ expect(api.vms.has(`ubirun-${OLD}-dddddddd`)).toBe(true);+ });+it("list --mine shows only the caller's VMs; usage sums vCPUs by owner", async () => {serve({ seed });const mine = await run(["list", "--mine"], { UBI_OWNER: "t1" });