monitoring: silence stage false WARNs (308, og-goa, shop-ui)

Follow privacy redirects; skip GOA-only assets off-GOA; longer
external store timeout; TESTPAYSAN shop-ui paths; accept paivana 402.
This commit is contained in:
Hernâni Marques 2026-07-17 18:50:16 +02:00
parent 9950bb05dd
commit c9fdae9540
No known key found for this signature in database

View file

@ -24,7 +24,8 @@ check_url() {
esac
}
# Soft check: OK on expect, WARN on foreign stack if down, ERROR on local stack
# 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.
check_url_soft() {
local label="$1" expect="$2" url="$3"
local code
@ -32,6 +33,15 @@ check_url_soft() {
case ",$expect," in
*",$code,"*) ok "$label $url" ;;
*)
# Follow redirects (308 Permanent Redirect is common for trailing slash)
case "$code" in
301|302|303|307|308)
code=$(curl -skS --max-redirs 5 -L -m "${TIMEOUT}" -o /dev/null -w '%{http_code}' "$url" 2>/dev/null || echo 000)
case ",$expect," in
*",$code,"*) ok "$label $url" "via redirect → HTTP $code"; return ;;
esac
;;
esac
if [ "${LOCAL_STACK:-1}" = "0" ]; then
warn "$label $url" "got $code (optional on remote domain)"
else
@ -835,8 +845,12 @@ if [ "${LOCAL_STACK:-1}" = "1" ] && [ "${E2E_PAIVANA:-1}" != "0" ]; then
fi
info "paivana Location" "${loc:0:140}"
;;
402)
# Paywall may answer Payment Required with body (healthy, not 502)
ok "paivana /" "HTTP 402 Payment Required (paywall up)"
;;
200)
warn "paivana /" "HTTP 200 (expected paywall redirect to template)"
warn "paivana /" "HTTP 200 (expected paywall redirect/402 to template)"
;;
*)
warn "paivana /" "HTTP ${pcode:-000}${PAIVANA_PUBLIC}/ (e2e pay may still work via template)"
@ -1014,30 +1028,30 @@ check_one_landing() {
return
fi
# Required static: qrcode.min.js. GOA og image is soft off-GOA (stage has no og-goa-shop.png).
# Required static: qrcode.min.js. og-goa-shop.png only on GOA/local.
if _landing_probe "${base}/intro/qrcode.min.js"; then
a_ok=$((a_ok + 1))
else
a_fail=$((a_fail + 1))
fail_sample="${fail_sample}${fail_sample:+; }HTTP ${_landing_code} ${base}/intro/qrcode.min.js"
fi
if [ "${EXPECT_CURRENCY:-}" = "GOA" ] || [ "${LOCAL_STACK:-0}" = "1" ]; then
if _landing_probe "${base}/intro/og-goa-shop.png"; then
a_ok=$((a_ok + 1))
else
if [ "${EXPECT_CURRENCY:-}" = "GOA" ] || [ "${LOCAL_STACK:-0}" = "1" ]; then
a_fail=$((a_fail + 1))
fail_sample="${fail_sample}${fail_sample:+; }HTTP ${_landing_code} ${base}/intro/og-goa-shop.png"
else
a_soft=$((a_soft + 1))
soft_sample="${soft_sample}${soft_sample:+; }HTTP ${_landing_code} og-goa-shop.png (GOA asset)"
fi
fi
# qr-logo: hard on GOA (wallet QR frame); soft elsewhere if missing
if _landing_probe "${base}/intro/qr-logo.png"; then
a_ok=$((a_ok + 1))
else
if [ "${EXPECT_CURRENCY:-}" = "GOA" ] || [ "${LOCAL_STACK:-0}" = "1" ]; then
a_soft=$((a_soft + 1))
soft_sample="${soft_sample}${soft_sample:+; }HTTP ${_landing_code} qr-logo.png"
fi
fi
n=$(extract_landing_urls "$base" "$html" "$pref" 2>/dev/null || echo "own=0 ext=0")
own_n=0
@ -1066,11 +1080,14 @@ check_one_landing() {
done < "${pref}.own"
fi
# External: soft counts
# External: soft counts (stores can be slow — longer timeout + browser UA)
if [ -f "${pref}.ext" ]; then
local _ext_to="${EXT_TIMEOUT:-25}"
while IFS= read -r u; do
[ -n "$u" ] || continue
code=$(curl -skS --max-redirs 5 -L -m "${TIMEOUT}" -o /dev/null -w '%{http_code}' "$u" 2>/dev/null || echo 000)
code=$(curl -skS --max-redirs 5 -L -m "${_ext_to}" \
-A "Mozilla/5.0 (compatible; taler-monitoring/1.0)" \
-o /dev/null -w '%{http_code}' "$u" 2>/dev/null || echo 000)
case "$code" in
200|204|301|302|303|307|308) ext_ok=$((ext_ok + 1)) ;;
*)
@ -1136,8 +1153,11 @@ if [ "${LOCAL_STACK:-1}" = "1" ] || [ -n "${BANK_PUBLIC:-}" ]; then
_ba_ok=0
_ba_soft=0
_ba_msg=""
# GOA landings ship shop-pay.*; stage TESTPAYSAN uses monnaies /assets/shop-ui.js
if [ "${EXPECT_CURRENCY:-}" = "GOA" ] || [ "${LOCAL_STACK:-0}" = "1" ]; then
if _landing_probe "$BANK_PUBLIC/intro/shop-pay.js"; then _ba_ok=$((_ba_ok + 1)); else _ba_soft=$((_ba_soft + 1)); _ba_msg="${_ba_msg}shop-pay.js; "; fi
if _landing_probe "$BANK_PUBLIC/intro/shop-pay.css"; then _ba_ok=$((_ba_ok + 1)); else _ba_soft=$((_ba_soft + 1)); _ba_msg="${_ba_msg}shop-pay.css; "; fi
fi
dw_code=$(http_body "$BANK_PUBLIC/intro/demo-withdraw.json" "$tmp/dw.json")
case "$dw_code" in
200)
@ -1183,14 +1203,31 @@ if [ "${LOCAL_STACK:-1}" = "1" ] || [ -n "${BANK_PUBLIC:-}" ]; then
fi
fi
# Merchant shop assets — one soft line
# Merchant shop assets — GOA: shop-pay.*; stage TESTPAYSAN: /assets/shop-ui.js + shops.css
_ma=0
_ma_need=2
_ma_label="shop-pay.js + .css"
if [ "${EXPECT_CURRENCY:-}" = "GOA" ] || [ "${LOCAL_STACK:-0}" = "1" ]; then
_landing_probe "$MERCHANT_PUBLIC/intro/shop-pay.js" && _ma=$((_ma + 1))
_landing_probe "$MERCHANT_PUBLIC/intro/shop-pay.css" && _ma=$((_ma + 1))
if [ "$_ma" -eq 2 ]; then
ok "landing merchant shop assets" "shop-pay.js + .css"
else
warn "landing merchant shop assets" "${_ma}/2 present (soft)"
_ma_label="shop-ui.js + shops.css"
_landing_probe "$MERCHANT_PUBLIC/assets/shop-ui.js" && _ma=$((_ma + 1))
_landing_probe "$MERCHANT_PUBLIC/assets/shops.css" && _ma=$((_ma + 1))
fi
if [ "$_ma" -eq "$_ma_need" ]; then
ok "landing merchant shop assets" "${_ma_label}"
else
if [ "${EXPECT_CURRENCY:-}" = "GOA" ] || [ "${LOCAL_STACK:-0}" = "1" ]; then
warn "landing merchant shop assets" "${_ma}/${_ma_need} present (soft) · want ${_ma_label}"
else
# stage: soft INFO if missing; WARN only if zero
if [ "$_ma" -eq 0 ]; then
warn "landing merchant shop assets" "0/${_ma_need} · want ${_ma_label}"
else
info "landing merchant shop assets" "${_ma}/${_ma_need} · ${_ma_label}"
fi
fi
fi
# ---------------------------------------------------------------------------