Capture isolated evidence with full provenance and exit codes

This commit is contained in:
Artyom
2026-11-06 01:54:30 +03:00
parent 5596ca935c
commit 1aec062aba
10 changed files with 102 additions and 22 deletions
+6 -4
View File
@@ -1,16 +1,18 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
out=${EVIDENCE_DIR:-evidence}
mkdir -p "$out"
replicas() {
docker inspect -f '{{.Config.Hostname}} {{.State.Status}} started={{.State.StartedAt}} finished={{.State.FinishedAt}}' $(docker compose ps -aq "${API_SERVICE:-api}")
}
url=${1:-http://localhost:8080}
shift=0
while [ "$shift" -lt "${2:-0}" ]; do curl -fsS -o /dev/null "$url/health/live"; shift=$((shift + 1)); done
tmp=evidence/failover.tmp
tmp="$out"/failover.tmp
since=$(date -u +%FT%TZ)
{
echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"
echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse HEAD)"
echo "== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt"
replicas
echo "\$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh"
@@ -27,5 +29,5 @@ stopped=$(replicas | awk '$2 == "exited" {print $1}')
echo "== after restore"
replicas
} >> "$tmp" 2>&1
mv "$tmp" "evidence/failover-$stopped.txt"
cat "evidence/failover-$stopped.txt"
mv "$tmp" "$out/failover-$stopped.txt"
cat "$out/failover-$stopped.txt"