ubicloud: usage is an awk syntax error on macOS, which also disables the vCPU quota preflight
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- awk, bash, typescript
- Ambito
- cli
Direzione di ricerca
Leggi scripts/ubicloud/ubi-runner.sh intorno a cmd_usage e quota_preflight, quindi esamina test/ubicloud-runner.test.ts e l'elenco macos-named-regressions in .github/workflows/free-tests.yml. Esegui i test del runner Ubicloud su macOS, se disponibile. Il lavoro è completato quando usage stampa i totali previsti senza un errore di sintassi awk e il controllo preliminare della quota rifiuta una richiesta che supera il limite.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened
On macOS, gstack-ubi usage fails with an awk syntax error and exits 2:
awk: syntax error at source line 4
context is
for (o in cpu) printf "%-14s %4d %6d%s\n", o, vms[o], cpu[o], o >>> == <<<
awk: illegal statement at source line 4
awk: illegal statement at source line 4
The larger effect is on up: quota_preflight reads the total from cmd_usage, gets an empty string, and returns 0. So on macOS the vCPU preflight never refuses: with 20 vCPUs in use, a 16-vCPU ceiling (UBI_QUOTA_VCPUS=16) and a standard-4 request, it lets the create through; with the line fixed, it dies with "vCPU quota exhausted" as intended.
Cause
for (o in cpu) printf "%-14s %4d %6d%s\n", o, vms[o], cpu[o], o == me ? " (you)" : "" | "sort -k3,3nr"
macOS ships the one-true-awk (/usr/bin/awk, "awk version 20200816"), whose grammar rejects an unparenthesized == inside a print/printf argument list. The | "sort" redirect is not the trigger; this fails too:
/usr/bin/awk 'BEGIN { o = "a"; me = "a"; printf "%s%s\n", o, o == me ? " (you)" : "" }'
CI does not see it: free-tests is green on 047dad78, and test/ubicloud-runner.test.ts runs only on the Linux shards because it is not in the macos-named-regressions list.
Steps to reproduce
On macOS, from a gstack checkout at 047dad78 (no Ubicloud account needed; a local stand-in answers POST /cli for a project with two VMs):
cat > /tmp/fake_ubi_two.py <<'EOF'
# Answers POST /cli for a project with two VMs: one standard-4 owned by
# lane7, one standard-16 that this runner did not name.
import json, sys
from http.server import BaseHTTPRequestHandler, HTTPServer
class H(BaseHTTPRequestHandler):
def do_POST(self):
argv = json.loads(self.rfile.read(int(self.headers["Content-Length"])))["argv"]
if argv[:2] == ["vm", "list"]:
body = "eu-central-h1 ubirun-lane7-1761900000-ab12-t3\neu-north-h1 someone-elses-vm\n"
else:
body = "size: standard-4\n" if "lane7" in argv[1] else "size: standard-16\n"
b = body.encode()
self.send_response(200); self.send_header("Content-Length", str(len(b))); self.end_headers(); self.wfile.write(b)
def log_message(self, *a): pass
HTTPServer(("127.0.0.1", 18733), H).serve_forever()
EOF
python3 /tmp/fake_ubi_two.py & srv=$!; sleep 1
UBICLOUD_API_URL=http://127.0.0.1:18733 UBICLOUD_API_KEY=offline UBI_RUNNER_STATE=$(mktemp -d) UBI_OWNER=lane7 \
bash scripts/ubicloud/ubi-runner.sh usage; echo "exit=$?"
kill $srv
Expected:
OWNER VMS VCPUS
(other) 1 16
lane7 1 4 (you)
total 2 20
Actual: the syntax error above, exit 2.
Proposed fix
Parenthesize the ternary (valid in every awk):
--- a/scripts/ubicloud/ubi-runner.sh
+++ b/scripts/ubicloud/ubi-runner.sh
@@ -381,7 +381,7 @@
vms[o]++; cpu[o] += n; total += n; count++ }
END {
printf "%-14s %4s %6s\n", "OWNER", "VMS", "VCPUS"
- for (o in cpu) printf "%-14s %4d %6d%s\n", o, vms[o], cpu[o], o == me ? " (you)" : "" | "sort -k3,3nr"
+ for (o in cpu) printf "%-14s %4d %6d%s\n", o, vms[o], cpu[o], (o == me ? " (you)" : "") | "sort -k3,3nr"
close("sort -k3,3nr")
printf "%-14s %4d %6d\n", "total", count, total
}'
Verified on macOS /usr/bin/awk 20200816: usage prints the expected table and exits 0, and quota_preflight (20 vCPUs used, ceiling 16, standard-4 requested) refuses with "vCPU quota exhausted". No other print/printf in scripts/ubicloud/*.sh has an unparenthesized comparison. Suggested guard: add test/ubicloud-runner.test.ts to the macos-named-regressions file list, which would also catch the pack issue, #3680. (The whole file has not been run on macOS here, so it may surface more than these two.)
Readiness report
Hit on the 1.91.333.0 install below; the repro above is against main at 047dad78 (1.91.357.0), where the line is unchanged. Home paths are shortened to ~, and the paths of local CLAUDE.md files are removed from the last check line.
gstack doctor
gstack doctor 1.91.333.0
ok install root ~/.claude/skills/gstack: claude global current (1.91.333.0), codex global current (1.91.333.0)
ok rescue refs none in ~/.claude/skills/gstack
ok state root ~/.gstack durable=yes (selected by default)
ok bun 1.4.4 at /opt/homebrew/bin/bun (floor 1.3.3, tested 1.4.2)
ok hooks 9 hook(s) parse
ok codex codex-cli 0.163.0; self-locate ok; model gpt-6.1-sol (source: ~/.codex/config.toml model)
ok codex probe cached MODEL_OK, 18m ago (not re-run; --live probes now)
not configured artifacts sync off; cross-machine artifacts sync is unavailable
ok browse bundle browse/dist built
ok binaries find-browse, design, pdf, gstack-global-discover launch (4 of 4)
ok cso native helper 1.91.333.0 (11c17d466af3)
ok claude code 2.1.303 (Claude Code) at ~/.local/bin/claude
ok session journal largest of 2: 1.6 MiB
ok guard log 816 decisions (61 denied)
ok CLAUDE.md no gstack section lists skills
14 ok, 0 warn, 1 not configured, 0 fail
Environment
- Host: Claude Code 2.1.303
- OS: macOS 26.6.2 (25G83), arm64;
/usr/bin/awk"awk version 20200816" - gstack: hit on 1.91.333.0, reproduced on
main047dad78(1.91.357.0)
- Lingua principale
- TypeScript
- Stelle
- 138k
- Fork
- 20.5k
- Merge medio
- 8h 37m
- PR unite (30g)
- 320
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di garrytan/gstack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di garrytan/gstack
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Slaymish/HealthAgent#7 ·
-
area: engine topic: math type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Get-Concord-AI/concord-mcp#310 ·
I maintainer di solito rispondono entro 1 giorno
-
Correct install_claude: 'marketplace add' over a different source is refused, not replaced in placeApertatype:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
nightgauge/nightgauge#2804 ·
I maintainer di solito rispondono entro 1 giorno