fix(frank-archon): raise the ttm knob from a root ExecStartPre — User=dank cannot write it
a9da65e put the raise inside the serve script, which runs as `User=dank`: the knob is root-owned 0644, so `-w` is false and the write silently failed — the gate printed its refusal on a cap it had just failed to move. The privileged path is systemd's `+` prefix: `ExecStartPre=+scripts/ttm-preflight.sh --raise` runs as root even under `User=`, before ExecStart, so `Restart=always` can never outrun it. The lib is now also executable (`--raise` sources the env file and verifies), and keeps a `sudo -n` fallback for a human running the gate from a shell. Seam: the refusal cases run with a PATH that has `cat`+`bash` and NO `sudo` (root writes a 444 file, so a passwordless dev box would have tested nothing), and both now assert the gate's own exit 1, not merely non-zero. New seam covers the unit line and the `--raise` entry point end to end (writable knob -> raised, no args -> usage exit 2).
This commit is contained in:
1 parent
a9da6589a6
commit
a6f55f4cc6
3 files changed
+76
-5
No files matched your search
@@ -33,6 +33,16 @@ BUILD="$REPO_ROOT/scripts/convert-swift15-w4dn8.sh"
|
||||
HFGET="$REPO_ROOT/scripts/hfget.sh"
|
||||
TEMPLATE="$REPO_ROOT/scripts/qwen38-froggeric-v22.5.jinja"
|
||||
|
||||
# A PATH with `cat` (the gate reads knobs with it) and NO `sudo`, so the
|
||||
# privileged fallback cannot rescue a write the test means to fail.
|
||||
nosudo_bin() {
|
||||
local bin="$BATS_TEST_TMPDIR/nosudo-bin"
|
||||
mkdir -p "$bin"
|
||||
ln -sf "$(command -v cat)" "$bin/cat"
|
||||
ln -sf "$(command -v bash)" "$bin/bash"
|
||||
echo "$bin"
|
||||
}
|
||||
|
||||
@test "frank-archon unit, serve script, env, fetch and build scripts and template exist" {
|
||||
[ -f "$UNIT" ]
|
||||
[ -x "$SERVE" ]
|
||||
@@ -298,8 +308,11 @@ TEMPLATE="$REPO_ROOT/scripts/qwen38-froggeric-v22.5.jinja"
|
||||
|
||||
echo 32253039 > "$dir/pages_limit"
|
||||
chmod 444 "$dir/pages_limit" # the write refused: cap cannot move
|
||||
run bash -c '. "$1"; ttm_ensure_cap' _ "$TTM_LIB"
|
||||
[ "$status" -ne 0 ]
|
||||
# The refusal case must not have `sudo` on PATH: the gate's privileged
|
||||
# fallback runs `sudo -n`, and on a passwordless host root can write a 444
|
||||
# file, which would silently test nothing.
|
||||
run env PATH="$(nosudo_bin)" bash -c '. "$1"; ttm_ensure_cap' _ "$TTM_LIB"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"ERROR: ttm pages cap is 125988 MiB"* ]]
|
||||
[ "$(cat "$dir/pages_limit")" = "32253039" ]
|
||||
}
|
||||
@@ -323,12 +336,35 @@ TEMPLATE="$REPO_ROOT/scripts/qwen38-froggeric-v22.5.jinja"
|
||||
[ "$output" = "117187" ]
|
||||
|
||||
chmod 444 "$dir/pages_limit" "$dir/pages_max" # both writes refused
|
||||
run bash -c '. "$1"; ttm_ensure_cap' _ "$TTM_LIB"
|
||||
[ "$status" -ne 0 ]
|
||||
run env PATH="$(nosudo_bin)" bash -c '. "$1"; ttm_ensure_cap' _ "$TTM_LIB"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"ERROR: ttm pages cap is 117187 MiB"* ]]
|
||||
[ "$(cat "$dir/pages_max")" = "30000000" ]
|
||||
}
|
||||
|
||||
@test "the gate runs as a root pre-start hook, where the knob write is legal" {
|
||||
# The knob is root-owned 0644 and the service runs as User=dank, so the
|
||||
# gate CANNOT raise it from the service process. systemd's `+` prefix on
|
||||
# ExecStartPre runs as root even under User= — the canonical privileged
|
||||
# path — and the gate's own --raise mode is what that line calls.
|
||||
grep -q '^ExecStartPre=+/home/dank/serverAppConfigs/scripts/ttm-preflight.sh --raise$' "$UNIT"
|
||||
|
||||
# Behaviour of that entry point: sourced env values, knob raised, exit 0.
|
||||
local dir="$BATS_TEST_TMPDIR/ttm3" envf="$BATS_TEST_TMPDIR/ttm3.env"
|
||||
mkdir -p "$dir"
|
||||
printf 'FRANK_ARCHON_TTM_MIN_MIB=150000\nFRANK_ARCHON_TTM_TARGET_MIB=204800\n' > "$envf"
|
||||
echo 32253039 > "$dir/pages_limit"
|
||||
run env FRANK_ARCHON_ENV_FILE="$envf" FRANK_ARCHON_TTM_SYS_DIR="$dir" \
|
||||
bash "$TTM_LIB" --raise
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$dir/pages_limit")" = "52428800" ]
|
||||
|
||||
# Usage is a named failure, not a silent no-op.
|
||||
run bash "$TTM_LIB"
|
||||
[ "$status" -eq 2 ]
|
||||
[[ "$output" == *"--raise"* ]]
|
||||
}
|
||||
|
||||
@test "the serve script clears stale containers and self-heals via podman wait" {
|
||||
# A crashed unit can leave the container name registered forever after;
|
||||
# the legacy identities hold the same GPUs and die here too. Then block
|
||||
|
||||
Reference in new issue
Block a user