fix: M8 review findings (restore ownership, barrier tool, World0 claimRef, CI selection, drill verdicts)

P1: restore-world.sh claims its objects path (mkdir) and the database (a held
session with a restore try-lock and the exclusive upgrade lock), and removes only
what it created, so a losing restore never drops a winner's schema.
P2: barrier Ready-pod selection via shared jsonpath helper with fixtures; barrier
pod fsGroup; script-generated pods inspected by the policy check; World0 PV claim
references protected; ci-paths.sh uses the event's real base and runs on
uncertainty; fault-drill asserts RTO and needs positive quarantine evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-30 22:53:11 -04:00
co-authored by Claude Opus 5.5
parent 5b482ad6a3
commit 3a34ae39bc
21 changed files with 584 additions and 80 deletions
+34 -9
View File
@@ -21,6 +21,13 @@
# made with `kubectl set env` / `kubectl patch` on the evo-region Deployment and
# reverted on exit, including on failure, back to the Git values (so Argo returns to
# Synced); World0 is refused before anything touches the cluster.
#
# Verdicts (tools/ops/lib/drill.sh): each kill must recover within RTO_BUDGET_MS
# (default 60000, ADR-0075); the empty scenario needs positive quarantine evidence.
# A missing observation fails the drill. Limits of log-based evidence: an owner's
# acknowledgements are read from its streamed log, finalized after it is gone; a line
# written but never streamed before a forced kill is not observed, so the
# zero-lost-acknowledgement check covers every observed acknowledgement only.
set -euo pipefail
usage() { echo "usage: $0 <dev|stage> [kills|full|empty|db-outage|all] [--context <name>]" >&2; exit 2; }
[ $# -ge 1 ] || usage
@@ -35,9 +42,13 @@ case "$scenario" in kills|full|empty|db-outage|all) shift || true ;; --context)
k=(kubectl --request-timeout=30s)
[ "${1:-}" = "--context" ] && [ -n "${2:-}" ] && k+=(--context "$2")
ns="evolution-$env"
rto_budget="${RTO_BUDGET_MS:-60000}"
# shellcheck source=lib/drill.sh
. "$(cd "$(dirname "$0")" && pwd)/lib/drill.sh"
selector=app.kubernetes.io/name=evo-region
work="$(mktemp -d)"
log_pids=()
declare -A capture_pid=()
now_ms() { date +%s%3N; }
say() { echo "$(date -u +%H:%M:%S) $*"; }
@@ -65,6 +76,13 @@ metric() { # metric <pod> <series>: from the pod's own /metrics (bash /dev/tcp).
capture() { # Streams a pod's log to $work/<pod>.log for acknowledgement accounting.
"${k[@]}" logs -n "$ns" -f "$1" > "$work/$1.log" 2>/dev/null &
log_pids+=($!)
capture_pid[$1]=$!
}
finalize() { # Waits (up to 15 s) for a gone pod's log stream to end, so its log is complete.
local pid="${capture_pid[$1]:-}"
[ -n "$pid" ] || return 0
for _ in $(seq 1 75); do kill -0 "$pid" 2> /dev/null || return 0; sleep 0.2; done
kill "$pid" 2> /dev/null || true
}
max_ack() { awk '$1 == "ack" {if ($3 > m) m = $3} END {print m + 0}' "$work/$1.log"; }
recovered_at() { # committed tick from the pod's "phase running epoch=E committed=C" line.
@@ -104,24 +122,31 @@ say "loaded pod=$pod ($(recovered_at "$pod"))"
if [ "$scenario" = kills ] || [ "$scenario" = all ]; then
for round in 1 2 3; do
sleep 10
acked="$(max_ack "$pod")"
start="$(now_ms)"
"${k[@]}" delete pod -n "$ns" "$pod" --grace-period=0 --force > /dev/null 2>&1
loaded_pod "$pod"; next="$POD"
POD="$(ready_pod "$pod" 120)" || fail "round $round: no Ready successor within 120 s"
rto=$(( $(now_ms) - start ))
next="$POD"
capture "$next"
wait_for_line "$next" '^ack ' 60 || fail "$next acknowledges nothing under load"
finalize "$pod"
acked="$(max_ack "$pod")" # Everything the dead owner was observed to acknowledge.
read -r epoch committed <<< "$(recovered_at "$next")"
say "kill round=$round rto_ms=$rto dead_acked_max=$acked recovered_committed=$committed epoch=$epoch pod=$next"
[ "$acked" -le "$committed" ] || fail "round $round lost acknowledgements ($acked > $committed)"
say "kill round=$round rto_ms=$rto budget_ms=$rto_budget dead_acked_max=$acked recovered_committed=$committed epoch=$epoch pod=$next"
verdict="$(rto_verdict "$rto" "$rto_budget")"
[ "$verdict" = PASS ] || fail "round $round: $verdict"
verdict="$(acks_verdict "$acked" "$committed")"
[ "$verdict" = PASS ] || fail "round $round lost acknowledgements: $verdict"
pod="$next"
done
fi
if [ "$scenario" = full ] || [ "$scenario" = all ]; then
sleep 5
acked="$(max_ack "$pod")"
set_env REGION_RESERVE_MIB=1048576
full_pod="$(ready_pod "$pod" 120)" || fail "full: host did not recover (recovery needs no space)"
capture "$full_pod"
finalize "$pod"; acked="$(max_ack "$pod")" # The drained owner's complete log.
sleep 30
new_acks="$(awk '$1 == "ack"' "$work/$full_pod.log" | wc -l)"
available="$(metric "$full_pod" evo_region_objects_available_bytes)"
@@ -138,10 +163,10 @@ fi
if [ "$scenario" = empty ] || [ "$scenario" = all ]; then
sleep 5
acked="$(max_ack "$pod")"
"${k[@]}" patch -n "$ns" deployment/evo-region --type json -p \
'[{"op":"replace","path":"/spec/template/spec/volumes/0","value":{"name":"objects","emptyDir":{"sizeLimit":"64Mi"}}}]' > /dev/null
sleep 45
finalize "$pod"; acked="$(max_ack "$pod")" # The drained owner's complete log.
if ready_pod "$pod" 1 > /dev/null; then fail "empty: a host became Ready on an empty volume"; fi
empty_pod="$(current_pods | grep -v "^$pod$" | head -1)"
[ -n "$empty_pod" ] || fail "empty: no replacement pod was created"
@@ -153,9 +178,9 @@ if [ "$scenario" = empty ] || [ "$scenario" = all ]; then
quarantined="$(cat "$work/$empty_pod.current.log" "$work/$empty_pod.previous.log" | grep -c '^phase quarantined' || true)"
say "empty pod=$empty_pod ready=never restarts=${restarts:-0} last_exit=${exit_code:-none} quarantined_lines=$quarantined"
say "empty last log lines:"; tail -n 5 "$work/$empty_pod.previous.log" "$work/$empty_pod.current.log" | sed 's/^/ /'
if [ "${exit_code:-}" != 4 ] && [ "$quarantined" -eq 0 ]; then
say "WARN empty: no quarantine evidence (exit 4 or a 'phase quarantined' line); see the logs above"
fi
lines="$(cat "$work/$empty_pod.current.log" "$work/$empty_pod.previous.log" | grep -c '^phase ' || true)"
verdict="$(empty_verdict "${restarts:-0}" "${exit_code:-}" "$quarantined" "$lines")"
[ "$verdict" = PASS ] || fail "empty: $verdict"
"${k[@]}" patch -n "$ns" deployment/evo-region --type json -p \
'[{"op":"replace","path":"/spec/template/spec/volumes/0","value":{"name":"objects","persistentVolumeClaim":{"claimName":"aevolution-objects"}}}]' > /dev/null
loaded_pod "$empty_pod"; pod="$POD"