release 1.9.0: monpages top/bottom content markers + surface required

Require meaningful monitoring HTML: sticky-bar/generated at top, footer
or taler-mon:bottom at end; ERROR if body is progress-only. Mid-run
(incomplete meta or progress without complete foot) relaxes bottom only.
GOA always checks taler-monitoring-surface. Generator emits taler-mon
markers and taler-mon-page complete|incomplete meta.
This commit is contained in:
Hernâni Marques 2026-07-19 00:32:35 +02:00
parent e7a3cd558f
commit 757090cbff
No known key found for this signature in database
GPG key ID: CB5738652768F7E9
6 changed files with 163 additions and 20 deletions

View file

@ -192,11 +192,15 @@ build_urls() {
case "$inv" in
job)
_job_urls
# v1.9.0: normal GOA runs always require surface page (content-checked)
if [ "$fam" = "goa" ]; then
printf 'https://taler.hacktivism.ch/taler-monitoring-surface/\n'
fi
;;
full|auto|*)
# Always include this jobs paths (host-agent post-check).
_job_urls
# Stack inventory: GOA = all suite mon sites; FP = only FP mon hosts.
# Stack inventory: GOA = landings + surface; FP = only FP mon hosts.
if [ "$fam" = "goa" ] || [ "$fam" = "fp" ]; then
_catalog_urls "$fam"
# On-disk discovery (err pages only exist after failed runs; extras welcome)
@ -225,7 +229,7 @@ is_monitoring_html() {
&& grep -qiE '404|not found|page introuvable' "$f" 2>/dev/null; then
return 1
fi
if grep -qE 'sticky-bar|version-link|taler-monitoring|class="sticky' "$f" 2>/dev/null; then
if grep -qE 'sticky-bar|version-link|taler-monitoring|class="sticky|taler-mon:top' "$f" 2>/dev/null; then
return 0
fi
if head -c 4096 "$f" | grep -qiE '<!DOCTYPE html|<html' \
@ -238,6 +242,113 @@ is_monitoring_html() {
return 1
}
# Highest progress percent in page body (0 if none). Pattern: ┌ 42%┐ or ┌100%┐
_progress_max_pct() {
local f="$1"
local m
m=$(grep -oE '┌[[:space:]]*[0-9]+%┐' "$f" 2>/dev/null \
| grep -oE '[0-9]+' | sort -n | tail -1 || true)
printf '%s' "${m:-0}"
}
# Mid-run: incomplete meta / redirect stub, or progress never reached 100% and no complete foot.
_page_mid_run() {
local f="$1"
local pct
if grep -qE 'name="taler-mon-page"[[:space:]]+content="incomplete"' "$f" 2>/dev/null \
|| grep -q 'taler-mon:bottom:incomplete' "$f" 2>/dev/null \
|| grep -qE 'http-equiv="refresh".*monitoring_err|mode-redirect' "$f" 2>/dev/null; then
return 0
fi
# finished page always has complete foot or classic footer
if grep -q 'taler-mon:bottom:complete' "$f" 2>/dev/null \
|| grep -qE 'id="mon-footer"' "$f" 2>/dev/null; then
return 1
fi
pct=$(_progress_max_pct "$f")
# max progress seen < 100% and no complete footer → still running
if [ "${pct:-0}" -gt 0 ] && [ "${pct:-0}" -lt 100 ]; then
if ! grep -qE 'Console-style render of taler-monitoring|Rendu console de taler-monitoring' "$f" 2>/dev/null; then
return 0
fi
fi
return 1
}
# Validate top/bottom markers + meaningful body (v1.9.0).
# Sets _MON_CONTENT_MSG; returns 0=ok, 1=hard fail, 2=soft/mid-run bottom skip
validate_mon_content() {
local f="$1" url="$2"
local top_ok=1 bot_ok=1 body_ok=1 mid=0 pct
_MON_CONTENT_MSG=""
# --- top markers (always required) ---
if ! head -c 12000 "$f" | grep -qE 'sticky-bar|id="status-bar"|taler-mon:top'; then
top_ok=0
_MON_CONTENT_MSG="missing top marker (sticky-bar / status-bar / taler-mon:top)"
elif ! head -c 16000 "$f" | grep -qE 'data-generated-iso|name="generated"|version-link|taler-mon-page'; then
top_ok=0
_MON_CONTENT_MSG="missing top meta (generated / version-link / taler-mon-page)"
fi
# --- meaningful body: real checks, not only progress bars ---
if grep -qE 'class="line (ok|error|warn|blocker|info)"|┌ OK|┌ ERROR|┌ WARN|┌ BLOCKER|┌ INFO|class="box"' "$f" 2>/dev/null; then
body_ok=1
elif grep -qE 'taler-mon:bottom:incomplete|mode-redirect|has failures' "$f" 2>/dev/null; then
body_ok=1 # redirect stub still has sticky + box
else
# only progress / empty?
if grep -qE '┌[[:space:]]*[0-9]+%┐|█|░' "$f" 2>/dev/null \
&& ! grep -qE '┌ OK|┌ ERROR|class="line ok"' "$f" 2>/dev/null; then
body_ok=0
_MON_CONTENT_MSG="${_MON_CONTENT_MSG:+$_MON_CONTENT_MSG; }only progress bars / no check lines"
elif ! grep -qE 'console|host-agent|taler-monitoring|monitoring' "$f" 2>/dev/null; then
body_ok=0
_MON_CONTENT_MSG="${_MON_CONTENT_MSG:+$_MON_CONTENT_MSG; }no meaningful suite content"
fi
fi
# --- bottom markers ---
if grep -q 'taler-mon:bottom:complete' "$f" 2>/dev/null \
|| tail -c 8000 "$f" | grep -qE 'id="mon-footer"|</footer>|Console-style render of taler-monitoring'; then
bot_ok=1
elif grep -q 'taler-mon:bottom:incomplete' "$f" 2>/dev/null; then
bot_ok=1 # incomplete is an explicit bottom marker
mid=1
else
bot_ok=0
_MON_CONTENT_MSG="${_MON_CONTENT_MSG:+$_MON_CONTENT_MSG; }missing bottom marker (footer / taler-mon:bottom)"
fi
if _page_mid_run "$f"; then
mid=1
fi
pct=$(_progress_max_pct "$f")
if [ "$top_ok" != "1" ]; then
_MON_CONTENT_MSG="TOP: $_MON_CONTENT_MSG"
return 1
fi
if [ "$body_ok" != "1" ]; then
_MON_CONTENT_MSG="BODY: $_MON_CONTENT_MSG"
return 1
fi
if [ "$bot_ok" != "1" ]; then
if [ "$mid" = "1" ]; then
_MON_CONTENT_MSG="BOTTOM soft (mid-run progress ${pct}%): $_MON_CONTENT_MSG"
return 2
fi
_MON_CONTENT_MSG="BOTTOM: $_MON_CONTENT_MSG"
return 1
fi
if [ "$mid" = "1" ] && [ "${pct:-0}" -gt 0 ] && [ "${pct:-0}" -lt 100 ]; then
_MON_CONTENT_MSG="mid-run progress ${pct}% (bottom markers relaxed)"
return 2
fi
_MON_CONTENT_MSG="top+body+bottom markers OK"
return 0
}
_is_bare_url() {
local url="$1"
case " ${MONPAGES_BARE_URLS:-} " in
@ -261,7 +372,7 @@ _mon_fail_or_soft() {
check_one() {
local url="$1"
local body code hint soft=0
local body code hint soft=0 vc
body=$(mktemp)
code=$(curl -skS -L --max-redirs 5 -m "${TIMEOUT}" -o "$body" -w '%{http_code}' "$url" 2>/dev/null || echo 000)
if _is_bare_url "$url" && [ "${MONPAGES_BARE_STRICT:-0}" != "1" ]; then
@ -290,17 +401,36 @@ check_one() {
rm -f "$body"
return 0
fi
if is_monitoring_html "$body"; then
if grep -qE 'sticky-bar|version-link' "$body" 2>/dev/null; then
ok "public mon page" "$url -> HTTP 200 monitoring HTML"
else
warn "public mon page" "$url -> HTTP 200 HTML but weak markers (stub/bootstrap?)"
fi
if ! is_monitoring_html "$body"; then
hint=$(head -c 120 "$body" | tr '\n' ' ' | tr -cd '[:print:] ')
_mon_fail_or_soft "public mon page not monitoring HTML" \
"$url -> HTTP 200 body!=suite (${hint}...)" || { rm -f "$body"; return 1; }
rm -f "$body"
return 0
fi
hint=$(head -c 120 "$body" | tr '\n' ' ' | tr -cd '[:print:] ')
_mon_fail_or_soft "public mon page not monitoring HTML" "$url -> HTTP 200 body!=suite (${hint}...)" || { rm -f "$body"; return 1; }
# v1.9.0: top + bottom markers + meaningful content
set +e
validate_mon_content "$body" "$url"
vc=$?
set -e
case "$vc" in
0)
ok "public mon page" "$url -> HTTP 200 · ${_MON_CONTENT_MSG}"
;;
2)
# mid-run: bottom may be incomplete — not ERROR
warn "public mon page mid-run" "$url -> ${_MON_CONTENT_MSG}"
ok "public mon page" "$url -> HTTP 200 suite HTML (mid-run bottom relaxed)"
;;
*)
if [ "$soft" = "1" ]; then
warn "public mon page content" "$url -> ${_MON_CONTENT_MSG}"
else
_mon_fail_or_soft "public mon page content" \
"$url -> ${_MON_CONTENT_MSG}" || { rm -f "$body"; return 1; }
fi
;;
esac
rm -f "$body"
return 0
}