Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ubi-runner: UBI_REAP=false, no or off no longer turns the reap on (#8096 item 3)

garrytandcd430cb9140
diff --git a/scripts/ubicloud/ubi-runner.sh b/scripts/ubicloud/ubi-runner.sh
index b4dcef55c0..9922704a50 100755
--- a/scripts/ubicloud/ubi-runner.sh
+++ b/scripts/ubicloud/ubi-runner.sh
@@ -20,6 +20,8 @@
# - watched keeps one log per call (ci:ubicloud runs several on one VM at
# once) and only after a kill.
# - Bash 5.2 lost-signal-trap guard (set -E, FAILED, finish).
+# - UBI_REAP takes the usual false spellings (0/false/no/off) and refuses
+# anything it cannot read, instead of treating every value but 0 as on.
#
# Scratch record: every VM this machine creates is appended to a VM-id file
# (UBI_VM_RECORD; default ~/.capy/work/ubi-runner/vms.tsv when ~/.capy/work
@@ -148,6 +150,12 @@ for v in IDLE_TIMEOUT RUN_TIMEOUT HEARTBEAT QUOTA_WAIT; do
[[ "${!v}" =~ ^[0-9]+$ ]] || die "UBI_$v must be a whole number of seconds (0 disables it)"
done
[ -z "$QUOTA_VCPUS" ] || [[ "$QUOTA_VCPUS" =~ ^[0-9]+$ ]] || die "UBI_QUOTA_VCPUS must be a whole number of vCPUs"
+# gbrain: UBI_REAP=false (or no/off) must not turn reaping on.
+case $(printf %s "$REAP" | tr '[:upper:]' '[:lower:]') in
+ 0|false|no|off) REAP=0 ;;
+ 1|true|yes|on) REAP=1 ;;
+ *) die "UBI_REAP must be 1 or 0 (true/false, yes/no and on/off also work), not '$REAP'" ;;
+esac
owner_id() {
local raw=${UBI_OWNER:-} file="$STATE_ROOT/owner-id" tmp
@@ -1061,7 +1069,7 @@ usage: ubi-runner.sh <command> [args]
VMs are named $PREFIX-<owner>-<epoch>-<suffix>-t<ttl hours>; up, run and verify need
UBI_OWNER (e.g. your thread code); run and verify end with a UBICLOUD: left=<n> line.
defaults: size=$DEFAULT_SIZE location=$DEFAULT_LOCATION (env UBI_SIZE, UBI_LOCATION)
-env: UBI_TTL_HOURS (${TTL_HOURS}h in the name, 1-999), UBI_REAP (default 0 in gbrain; 1: up reaps first),
+env: UBI_TTL_HOURS (${TTL_HOURS}h in the name, 1-999), UBI_REAP (default 0 in gbrain; 1/true/yes/on: up reaps first),
UBI_LEGACY_HOURS (${LEGACY_HOURS}h: reap's bound for this owner's TTL-less ubirun-* names),
UBI_IDLE_TIMEOUT (${IDLE_TIMEOUT}s of silence kills the remote command, exit 124; 0 disables),
UBI_RUN_TIMEOUT (${RUN_TIMEOUT}s wall clock; 0 unlimited), UBI_HEARTBEAT (${HEARTBEAT}s between heartbeat lines),
diff --git a/test/scripts/ubi-runner-run.test.ts b/test/scripts/ubi-runner-run.test.ts
index 28dd8b9334..e31269a9ec 100644
--- a/test/scripts/ubi-runner-run.test.ts
+++ b/test/scripts/ubi-runner-run.test.ts
@@ -201,6 +201,28 @@ describe("owner and reap", () => {
}
expect(creates()).toEqual([]);
}, 60_000);
+
+ // #8096 item 3: every UBI_REAP value but 0 used to turn the reap on.
+ it("UBI_REAP=false, no, off (any case) reaps nothing; true, yes, on reap; an unreadable value refuses before any API call", async () => {
+ serve({ rejectCreates: true, seed: [{ name: "ubirun-other-1000000000-bbbb-t1" }] });
+ for (const value of ["false", "FALSE", "no", "off", "0"]) {
+ const r = await run(["up"], { UBI_REAP: value });
+ expect(r.code).toBe(1);
+ expect(r.stderr).not.toContain("reaping");
+ expect(r.stderr).not.toContain("reap skipped");
+ }
+ expect(destroyed()).toEqual([]);
+ const maybe = await run(["up"], { UBI_REAP: "maybe" });
+ expect(maybe.code).toBe(1);
+ expect(maybe.stderr).toContain("UBI_REAP must be 1 or 0 (true/false, yes/no and on/off also work), not 'maybe'");
+ expect(creates()).toHaveLength(5);
+ for (const value of ["true", "Yes", "on"]) {
+ serve({ rejectCreates: true, seed: [{ name: "ubirun-other-1000000000-bbbb-t1" }] });
+ const r = await run(["up"], { UBI_REAP: value });
+ expect(r.stderr).toMatch(/reaping expired eu-central-h1\/ubirun-other-1000000000-bbbb-t1/);
+ expect(destroyed()).toEqual(["ubirun-other-1000000000-bbbb-t1"]);
+ }
+ }, 90_000);
});
describe("run leftover line", () => {