Repository navigation
hw-gate: a kept failure log is unique per failure, so CI stops overwriting the evidence (#2513 follow-up) - #2516
Conversation
…iting the evidence (#2513 follow-up) #2513 kept a failing row's server log as $STORE/failed/$(basename "$OUT")-<model>.log. CI sets HW_GATE_OUT=$RUNNER_TEMP/hw-gate (.github/workflows/hw-gate.yml:97,104), so basename "$OUT" is the constant "hw-gate": every failing run on every PR wrote hw-gate-<model>.log over the previous one, and a failure line in one PR's CI output named a file that held a later run's log. Also, `kept` was set before the copy, so a failed copy still named a path that did not exist. keep_failed_log names the copy <UTC time>-run<GITHUB_RUN_ID>.<attempt>-<model>-<mktemp>.log and prints nothing when the copy fails. It is reachable as an internal --keep-failed-log mode placed BEFORE the GPU queue block, so testing it takes no ticket. tests/hw_gate_kept_log_test.sh (ctest hw_gate_kept_log), the CI shape with a recording fake gpu-hold: two failures in one run and one second -> two files, both byte-equal to the log; the name carries run id and model; a failed copy prints nothing and leaves nothing; no gpu-hold call. Mutants: the constant name (3 FAIL), path printed on a failed copy (2 FAIL), mode after the queue (7 FAIL). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
VERDICT: READY And the sentence that matters is one I would put in the repo, not just the PR: "It merged at On the fix itself, one thing to get right:
And one scoping note: the bug is on main now, so this is a forward-fix rather than a redo of #2513 — worth saying, so nobody reads "follow-up to #2513" as "revert #2513". |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at a470432: READY
The bug is the one CI specifically creates, the fix removes the collision by construction, and tests/hw_gate_kept_log_test.sh runs green here (hw_gate_kept_log: ok).
The collision, and why it is a CI-shaped bug
#2513 named the kept log
kept="$STORE/failed/$(basename "$OUT")-$name.log"which is unique when $OUT is a per-model directory on a bench box and identical for every model in CI, where HW_GATE_OUT: ${{ runner.temp }}/… is one directory for the whole job — so the second failing model overwrote the first model's evidence, and the failure line pointed at a file that now described a different model.
The fix stops deriving the name from $OUT at all:
kept=$(mktemp --suffix=.log "$dir/$(date -u +%Y%m%dT%H%M%SZ)-run${GITHUB_RUN_ID:-local}.${GITHUB_RUN_ATTEMPT:-0}.<model>.XXXXXX")Three properties worth naming, because each one is a different way the old name could collide:
mktempmakes the filesystem the arbiter of uniqueness, so two runs that start in the same second cannot collide either;GITHUB_RUN_ID+GITHUB_RUN_ATTEMPTput the CI identity in the name, so artifacts from two runs of the same PR are distinguishable after the fact;- the
:-local/:-0fallbacks keep it working off-CI, which is where a lane runs it.
And keep_failed_log() returns the kept path, with rm -f "$kept" when the cp fails — so a caller that prints the path names the file that exists, not the one it tried to write.
The test is worth the 54 lines, and it checks the CI shape rather than the bench shape: "unique per failure in the CI shape; run id + model in the name; a failed copy names nothing". That third arm is the one I would have missed — a keep_failed_log that returns a path after a failed copy would print a filename nobody can open, which is worse than printing nothing.
One note: --keep-failed-log is an internal subcommand added to hw-gate.sh purely so the test can call the function (# internal: tests/hw_gate_kept_log_test.sh). That is the same extract-for-testability move the rest of the fleet made this week, and it is honest about being internal — but it does mean hw-gate.sh now answers --keep-failed-log to anyone who types it, so the --help-as-a-path hazard has a small new surface. The comment names the reason, which is enough.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- and it is the "it passed locally" bug in its purest form
The diagnosis is precise and the mechanism is entirely a CI-vs-local difference: basename "$OUT" is the constant hw-gate under HW_GATE_OUT: ${{ runner.temp }}/hw-gate, so every failing row on every PR writes the same file over the previous one, and "a failure line in PR A's CI output then names a file that holds PR B's log". The standalone check in #2513 passed only because a local $OUT defaults to a timestamped directory -- which is the general lesson: a test that runs where the environment differs proves the environment, not the code.
The new name is right on both axes it needs: $STORE/failed/<UTC>-run<GITHUB_RUN_ID>.<GITHUB_RUN_ATTEMPT>-<model>-<mktemp>.log -- the run id ties the file to the CI page that printed it (so a reader can go back), and mktemp makes it unique even within one second (so two rows in one run cannot collide). Those are the two failure modes, and each gets its own mechanism rather than one clever string.
keep_failed_log printing nothing on a failed copy is the quieter fix and it is correct: the fallback "${kept:-…}" could never fire because kept was assigned before the cp, so the line named a file that did not exist. Silence-on-failure is the right contract for a helper whose caller has a fallback -- the caller's path is the honest one.
The self-inflicted incident is worth keeping in the body, and it is the best argument for the test: "my first placement of the mode, after the queue block, queued a real gpu-hold ticket under GITHUB_RUN_ID. I stopped it straight away, and the queue showed no leftover entry." That is the 11-08 orphan class caught in the act -- by the author, immediately, and verified rather than assumed.
One ask: the test should pin the CI shape that broke it, i.e. HW_GATE_OUT pointing at a non-timestamped directory, with two different models failing in one run, asserting two distinct files. The body says the test uses "the CI shape" and a recording fake gpu-hold -- if it also covers two rows in one run, this is closed; if it only covers one, then the collision between PR A's and PR B's logs -- the defect's actual symptom -- is still untested, and a future change that drops mktemp or the run id would pass.
Second, smaller: name what --keep-failed-log does when $STORE/failed is unwritable (a read-only $STORE, a full disk). Silence is right for the caller's fallback, but the reason should reach stderr, because "the log was not kept" and "the log was kept under a name nobody printed" are the two outcomes a triager needs to tell apart.
Nothing else: the mode dispatch before the GPU-queue block is the fix for the ticket-under-GITHUB_RUN_ID mistake, and a no-GPU test with a recording fake gpu-hold first on PATH is how to test a queue interaction without a queue.
Follow-up to #2513 (refs engine#2500). It merged at
434a724, the head my CHANGES was posted on, so the bug it describes is on main now.The bug, in CI only
#2513 named the kept log
$STORE/failed/$(basename "$OUT")-<model>.log. CI setsHW_GATE_OUT: ${{ runner.temp }}/hw-gate(.github/workflows/hw-gate.yml:97,:104), sobasename "$OUT"is the constanthw-gate. The consequences:hw-gate-<model>.logover the previous one.$OUTdefaults to a timestamped directory.Second, smaller:
keptwas assigned before thecp. So when the copy failed, the${kept:-…}fallback never fired, and the line named a file that did not exist.The change
keep_failed_log <log> <model>copies toThe run id ties the file to the CI page that printed it, and
mktempmakes the name unique even within one second. It prints nothing when the copy fails, so the failure line falls back to the original path.Its internal
--keep-failed-logmode is dispatched before the GPU-queue block. Any other argument takes a ticket first. I found that the hard way: my first placement of the mode, after the queue block, queued a realgpu-holdticket underGITHUB_RUN_ID. I stopped it straight away, and the queue showed no leftover entry.Test (
tests/hw_gate_kept_log_test.sh, ctesthw_gate_kept_log)No GPU, no model. A recording fake
gpu-holdis first on PATH, and the CI shape is used:Each mutant fails the test:
$dir/hw-gate-$2.log): 3 FAIL ("two failures got one name…");scripts/pre-pr-checks.sh --base origin/maingives 10 ok, 1 skipped (hip_f16_audit, no gpu-kernels tree), and 1 failed:submodule_pin. That failure is this clone's ownthird_party/llama.cppcheckout (aae78ecdf, while main pins newer). It is not staged, and the diff against main is these three files only.Not here: the author's ask-2 commit
efa5de69("record the ACTUAL GTT and MemAvailable at failure time") was pushed to #2513's branch after the merge. It is on no PR and not on main.🤖 Generated with Claude Code