Files
box/bin/relay-health-check.sh
Muse Sidechat 66c8900a58 feat: setup-fed watchdog supervision for all registry nodes
Close the def/dev supervision gap at the source: every node brought
up gets watched, and every supervisor enumerates the registry.

- bin/ensure-node-supervision.sh (new, idempotent): appends the
  NODES.md row (netvm-names port, honors CDP_PORT_OVERRIDE so it
  never fights provision's picker) and installs/enables
  chromebox-watchdog-<node>.timer. --all heals drift (registry +
  /etc/netvm identities). Template verified byte-identical to the
  installed def unit.
- netvm-node-up.sh: calls ensure (non-fatal) at the end. Provision
  and the onboarding pipeline reach it transitively.
- relay-health-check.sh, cdp-latency-check.sh: registry-driven
  watched_nodes() + LIB_ONLY guards (were hardcoded 4 nodes).
- tests/test_node_supervision.py (6): row add/idempotent/override,
  timer render, node-up wiring, both watched_nodes().
- CHROMEBOX-RUNBOOK.md: setup-fed supervision section.

Pairs with the registry-driven relay/chromebox watchdogs: new rows
are picked up on the next run with no per-node code edits.
2026-10-06 19:28:29 +00:00

44 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# relay-health-check.sh — check all registry CDP relay endpoints on bl.
# Self-contained: no nested SSH quoting. Sources pinned ports from netvm-names.sh.
#
# Output: "name:code" per relay on stdout.
# Exit 0 if all return 200; exit 1 otherwise (lists failures on stderr).
#
# Called by the cdp-relay-health-monitor cron and by `box-ctl.py relay-health`.
set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=/dev/null
source "$SCRIPT_DIR/netvm-names.sh"
# Registry-driven node list (was hardcoded 4 nodes; def/dev had no
# relay-health coverage — 2026-10-06).
watched_nodes() {
"$SCRIPT_DIR/netvm-registry.py" 2>/dev/null | cut -d: -f1
}
# Allow sourcing for tests without running checks.
if [ "${RELAY_HEALTH_CHECK_LIB_ONLY:-}" = "1" ]; then
return 0 2>/dev/null || exit 0
fi
NODES="$(watched_nodes)"
if [ -z "$NODES" ]; then
echo "node registry empty/unreadable" >&2
exit 1
fi
FAILED=0
# shellcheck disable=SC2086 (intended word splitting: one node per word)
for node in $NODES; do
netvm_names "$node"
url="http://${PEER_IP}:${CDP_PORT}/json/version"
code=$(curl -s -m 8 -o /dev/null -w "%{http_code}" "$url" 2>/dev/null || echo "000")
echo "${node}:${code}"
if [ "$code" != "200" ]; then
echo "FAIL: ${node} relay ${PEER_IP}:${CDP_PORT} returned ${code}" >&2
FAILED=1
fi
done
exit $FAILED