The janitor now returns one JSON line per job it cancels (repo, workflow, job, reason, runs_on, waited_s) into a spool; the emitter ships them as ci.job_cancelled (declared with Telemetry Boss) and truncates the spool only after a 2xx. Run status recompute folded into the same statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 lines
533 B
Bash
Executable File
11 lines
533 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Cancel jobs no runner can ever take (see cancel_unrunnable.sql). Run on Veron as root.
|
|
set -euo pipefail
|
|
SPOOL="${JANITOR_SPOOL:-/var/lib/windy-git/janitor-cancelled.jsonl}"
|
|
mkdir -p "$(dirname "$SPOOL")"
|
|
out=$(docker exec -i windy-git-db-1 sh -c 'psql -U "$POSTGRES_USER" -d gitea -At -v ON_ERROR_STOP=1' \
|
|
< "$(dirname "$0")/cancel_unrunnable.sql")
|
|
printf '%s\n' "$out" | grep '^{' >> "$SPOOL" || true
|
|
n=$(printf '%s\n' "$out" | grep -c '^{' || true)
|
|
echo "[janitor] cancelled ${n} unrunnable job(s)"
|