ygg-verify: 5 slots at 8 GiB, and kill jobs that idle 15 minutes

On 2026-09-30 three hung test binaries held all three slots for up to an hour
at ~2% CPU while Yggdrasil sat at load 1.5 of 16. The operator wants
Yggdrasil pinned. CPU caps now oversubscribe on purpose (jobs run niced);
memory is the ceiling, so the per-job cap drops to 8 GiB. The watchdog samples
docker stats each minute and kills a container under 5% of a core for IDLE
seconds (default 900), reporting it red.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-29 12:00:12 +02:00
commit 6c413cc110

View file

@ -24,10 +24,17 @@
# stays inside the work directory and is never shared between checkouts.
# 4. Removes the work directory unless KEEP=1, and exits with the job's status.
#
# At most $SLOTS jobs run at once on Yggdrasil (operator raised this to 3 on
# 2026-09-22: "the other cores are mostly sitting idle"). Each job is capped at
# 4 of the 16 CPUs and 12 GiB, so verification takes 12 CPUs at most and the
# live services keep four.
# At most $SLOTS jobs run at once on Yggdrasil. The operator raised this to 3 on
# 2026-09-22 ("the other cores are mostly sitting idle") and asked on 2026-09-30
# for Yggdrasil to be "absolutely pinned", so it is 5. Each job is capped at 4
# CPUs and 8 GiB (MEM overrides per job). The CPU caps oversubscribe the 16
# cores on purpose: jobs run at nice 10, so the live services still win the
# scheduler. Memory is the real ceiling: 5 x 8 GiB leaves the services their
# ~17 GiB of the 62.
#
# A job whose container sits under $5% of one core for $IDLE seconds
# (default 900) is killed and comes back red: on 2026-09-30 three hung test
# binaries held every slot for up to an hour at ~2% CPU while agents queued.
#
# There is no hand-written mutation harness: the operator retired it on
# 2026-09-22. Mutation testing uses the ecosystem's tools on a cut's diff.
@ -48,6 +55,7 @@
# Usage (Git Bash on Starfire):
# ygg-verify.sh <local-repo> <rev> <image> '<command>'
# TIMEOUT=<seconds> caps the job (default 3600); a killed job exits non-zero.
# IDLE=<seconds> kills a job idle that long (default 900; 0 disables).
# DOCKER_ARGS='<extra docker run flags>' passes through to the container's
# own `docker run`, appended after the fixed flags and before the image name
# (e.g. DOCKER_ARGS='--sysctl net.ipv6.conf.all.disable_ipv6=0' or
@ -64,8 +72,8 @@
set -euo pipefail
repo=${1:?local repo}; rev=${2:?revision}; image=${3:?image}; cmd=${4:?command}
host=${YGG_HOST:-ygg}; cpus=${CPUS:-4}; mem=${MEM:-12g}; slots=${SLOTS:-3}
timeout_s=${TIMEOUT:-3600}
host=${YGG_HOST:-ygg}; cpus=${CPUS:-4}; mem=${MEM:-8g}; slots=${SLOTS:-5}
timeout_s=${TIMEOUT:-3600}; idle_s=${IDLE:-900}
docker_args=${DOCKER_ARGS:-}
here=$(cd "$(dirname "$0")" && pwd)
sshopts=(-o BatchMode=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=4)
@ -87,7 +95,7 @@ esac
# ssh joins its arguments into one string that the remote shell splits again,
# 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" "$timeout_s" "$docker_args")
remote_args=$(printf '%q ' "$name" "$sha" "$image" "$cpus" "$mem" "$slots" "${KEEP:-0}" "$cmd" "$timeout_s" "$docker_args" "$idle_s")
# 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
@ -97,7 +105,7 @@ remote_args=$(printf '%q ' "$name" "$sha" "$image" "$cpus" "$mem" "$slots" "${KE
# 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 timeout_s=$9 docker_args=${10}
name=$1 sha=$2 image=$3 cpus=$4 mem=$5 slots=$6 keep=$7 cmd=$8 timeout_s=$9 docker_args=${10} idle_s=${11}
root=~/eureka-verify
case "$image" in
eureka-verify-rust:*)
@ -131,7 +139,24 @@ echo "ygg-verify: $name@${sha:0:10} slot $slot, image $image, cpus $cpus, mem $m
cname="eureka-verify-$slot-$$"
# The subshell must not inherit the slot lock: its sleep outlives a job that
# finishes early, and an inherited fd held slot 2 for an hour (2026-09-23).
( exec {fd}>&- 2>/dev/null; sleep "$timeout_s"; sudo docker kill "$cname" >/dev/null 2>&1 && echo "ygg-verify: TIMEOUT after ${timeout_s}s, container killed" >&3 ) 3>&2 &
# It also kills a job that has idled for $idle_s seconds: docker's CPU% is per
# core, and a hung test reads ~2%, a working one tens to hundreds.
( exec {fd}>&- 2>/dev/null
start=$(date +%s); idle=0
while sleep 60; do
if [ $(( $(date +%s) - start )) -ge "$timeout_s" ]; then
sudo docker kill "$cname" >/dev/null 2>&1 && echo "ygg-verify: TIMEOUT after ${timeout_s}s, container killed" >&3
exit 0
fi
[ "$idle_s" -gt 0 ] || continue
cpu=$(sudo docker stats --no-stream --format '{{.CPUPerc}}' "$cname" 2>/dev/null | tr -d '%' || true)
[ -n "$cpu" ] || continue
if awk -v c="$cpu" 'BEGIN { exit !(c < 5.0) }'; then idle=$((idle + 60)); else idle=0; fi
if [ "$idle" -ge "$idle_s" ]; then
sudo docker kill "$cname" >/dev/null 2>&1 && echo "ygg-verify: IDLE ${idle_s}s under 5% CPU, container killed (a test is probably hung)" >&3
exit 0
fi
done ) 3>&2 &
watchdog=$!
set +e
sudo nice -n 10 docker run --rm --name "$cname" --cpus="$cpus" --memory="$mem" \