Stop the stopgap reporting success for a job that never ran
Soul lost a run to CRLF and it still exited 0. The cause: this file's own line endings travel with the heredoc, so the remote bash fails on `set -euo pipefail\r` before `set -e` is in force, limps past the failure and exits clean. A verification runner that can report success without running anything is worse than no runner. Two guards, because one was not enough to notice this for a day. The remote now strips carriage returns before bash sees them, and it prints a verdict sentinel the local side requires; a missing sentinel is treated as failure rather than as silence. A .gitattributes keeps the file LF on disk so the first guard is rarely needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
75efac6d56
commit
b12016a3f2
2 changed files with 27 additions and 1 deletions
1
tools/stopgap/.gitattributes
vendored
Normal file
1
tools/stopgap/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
* text=auto eol=lf
|
||||
|
|
@ -72,7 +72,14 @@ esac
|
|||
# so every argument is quoted here. Without that, `a && b` in the command runs
|
||||
# b on the host.
|
||||
remote_args=$(printf '%q ' "$name" "$sha" "$image" "$cpus" "$mem" "$slots" "${KEEP:-0}" "$cmd")
|
||||
ssh "${sshopts[@]}" "$host" "bash -s -- $remote_args" <<'REMOTE'
|
||||
# The heredoc below travels with whatever line endings this file has on disk.
|
||||
# On Windows that is CRLF, and the remote bash then fails on `set -euo pipefail
`
|
||||
# BEFORE `set -e` is in force, so the script limps on and can exit 0 — a job that
|
||||
# never ran, reported as success (seen 2026-09-23). `tr -d` strips the CRs on the
|
||||
# far side before bash ever sees them. The sentinel below is the second guard: if
|
||||
# the remote script dies early, no verdict line is printed and the local side
|
||||
# refuses to report a status it did not receive.
|
||||
(ssh "${sshopts[@]}" "$host" "tr -d '
' | bash -s -- $remote_args" <<'REMOTE'
|
||||
set -euo pipefail
|
||||
name=$1 sha=$2 image=$3 cpus=$4 mem=$5 slots=$6 keep=$7 cmd=$8
|
||||
root=~/eureka-verify
|
||||
|
|
@ -111,5 +118,23 @@ sudo nice -n 10 docker run --rm --cpus="$cpus" --memory="$mem" \
|
|||
status=$?
|
||||
set -e
|
||||
echo "ygg-verify: exit $status" >&2
|
||||
echo "__YGG_VERDICT__ $status"
|
||||
exit $status
|
||||
REMOTE
|
||||
) | {
|
||||
# The remote prints __YGG_VERDICT__ <status> as its last line. Strip it from the
|
||||
# output and exit with it. If it never arrives the remote script died before its
|
||||
# own exit line, so refuse to report a status that was never produced.
|
||||
verdict=97
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
"__YGG_VERDICT__ "*) verdict=${line#__YGG_VERDICT__ }; continue ;;
|
||||
esac
|
||||
printf '%s\n' "$line"
|
||||
done
|
||||
if [ "$verdict" = 97 ]; then
|
||||
echo "ygg-verify: NO VERDICT from the remote job - treating as failure" >&2
|
||||
exit 97
|
||||
fi
|
||||
exit "$verdict"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue