monitoring: pre-launch stacks report INFO not WARN

Empty EXPECT_CURRENCY + remote (prod LFP) is not live yet.
Preserve empty currency across child scripts (fix := vs =).
Exchange /config keys soft on remote stacks.
This commit is contained in:
Hernâni Marques 2026-07-17 18:54:04 +02:00
parent f3a429d69d
commit 4cf923b271
No known key found for this signature in database
2 changed files with 45 additions and 11 deletions

View file

@ -24,8 +24,15 @@ check_url() {
esac
}
# Pre-launch remote stack: local=0 and no expected currency (e.g. prod LFP not live yet).
# Missing endpoints → INFO, not WARN (infra not supposed to serve yet).
is_prelaunch_stack() {
[ "${LOCAL_STACK:-1}" = "0" ] && [ -z "${EXPECT_CURRENCY:-}" ]
}
# Soft check: OK on expect, WARN on foreign stack if down, ERROR on local stack.
# Always treats 301/302/303/307/308→200 (follow) as success when 200 is expected.
# Pre-launch (no currency): INFO instead of WARN for missing endpoints.
check_url_soft() {
local label="$1" expect="$2" url="$3"
local code
@ -43,7 +50,11 @@ check_url_soft() {
;;
esac
if [ "${LOCAL_STACK:-1}" = "0" ]; then
if is_prelaunch_stack; then
info "$label $url" "HTTP $code — pre-launch / not serving yet"
else
warn "$label $url" "got $code (optional on remote domain)"
fi
else
fail "$label $url" "got $code want $expect"
fi
@ -81,7 +92,11 @@ check_legal_doc() {
if [ "$code" != "200" ]; then
rm -f "$f"
if [ "$soft" = "1" ]; then
if is_prelaunch_stack; then
info "$label" "HTTP $code — pre-launch / not serving yet · $url"
else
warn "$label" "HTTP $code$url"
fi
else
fail "$label" "HTTP $code$url"
fi
@ -181,9 +196,13 @@ sys.exit(0)
PY
}
# --- exchange (core; always required) --- www.exchange-NN
# --- exchange (core; hard on local stack, soft on remote) --- www.exchange-NN
set_group exchange
if [ "${LOCAL_STACK:-1}" = "1" ]; then
check_url "exchange /config" 200 "$EXCHANGE_PUBLIC/config"
else
check_url_soft "exchange /config" 200 "$EXCHANGE_PUBLIC/config"
fi
code=$(http_body "$EXCHANGE_PUBLIC/config" "$tmp/ec.json")
if [ "$code" = "200" ]; then
expect_currency "exchange" "$tmp/ec.json"
@ -195,7 +214,11 @@ if [ "$code" = "200" ]; then
fi
rm -f /tmp/alt-ex.$$
fi
if [ "${LOCAL_STACK:-1}" = "1" ]; then
check_url "exchange /keys" 200 "$EXCHANGE_PUBLIC/keys"
else
check_url_soft "exchange /keys" 200 "$EXCHANGE_PUBLIC/keys"
fi
# /keys should also expose currency_specification.alt_unit_names when present
code=$(http_body "$EXCHANGE_PUBLIC/keys" "$tmp/ek.json")
if [ "$code" = "200" ]; then
@ -271,6 +294,8 @@ check_perf() {
*)
if [ "${LOCAL_STACK:-1}" = "1" ]; then
fail "$label" "HTTP $code want $expect · ${ms} ms · $url"
elif is_prelaunch_stack; then
info "$label" "HTTP $code · ${ms} ms · pre-launch · $url"
else
warn "$label" "HTTP $code want $expect · ${ms} ms · $url"
fi
@ -682,10 +707,12 @@ check_legal_doc "exchange /privacy" "$EXCHANGE_PUBLIC/privacy" "privacy|FADP|rev
# trailing slash: 200 or redirect to bare path
code=$(http_code "$EXCHANGE_PUBLIC/terms/")
case "$code" in
200|301|302) ok "exchange /terms/" "HTTP $code" ;;
200|301|302|303|307|308) ok "exchange /terms/" "HTTP $code" ;;
*)
if [ "${LOCAL_STACK:-1}" = "1" ]; then warn "exchange /terms/" "HTTP $code"
else warn "exchange /terms/" "HTTP $code"
if is_prelaunch_stack; then
info "exchange /terms/" "HTTP $code — pre-launch"
else
warn "exchange /terms/" "HTTP $code"
fi
;;
esac
@ -821,8 +848,14 @@ check_legal_doc "merchant /terms" "$MERCHANT_PUBLIC/terms" "terms|dual|GOA|CHF|e
check_legal_doc "merchant /privacy" "$MERCHANT_PUBLIC/privacy" "privacy|FADP|revDSG|data|GOA|CHF|merchant"
code=$(http_code "$MERCHANT_PUBLIC/terms/")
case "$code" in
200|301|302) ok "merchant /terms/" "HTTP $code" ;;
*) warn "merchant /terms/" "HTTP $code (expect 302 → /terms)" ;;
200|301|302|303|307|308) ok "merchant /terms/" "HTTP $code" ;;
*)
if is_prelaunch_stack; then
info "merchant /terms/" "HTTP $code — pre-launch"
else
warn "merchant /terms/" "HTTP $code (expect 302 → /terms)"
fi
;;
esac
# ---------------------------------------------------------------------------

View file

@ -31,7 +31,8 @@
: "${SSH_CMD_TIMEOUT:=12}" # hard cap for whole remote script (seconds)
: "${SKIP_SSH:=0}"
# Expected currency for public /config checks (empty = report only, don't fail)
: "${EXPECT_CURRENCY:=GOA}"
# Only if unset (not if intentionally empty = pre-launch / report-only)
: "${EXPECT_CURRENCY=GOA}"
# 1 = this is the local koopa/hacktivism stack (inside/e2e/SSH make sense)
: "${LOCAL_STACK:=1}"
# Probe merchant host candidates when applying a generic domain (0=off)