release 1.18.2: refuse stale mon HTML / box-drawing generator assets

This commit is contained in:
Hernâni Marques 2026-07-19 09:02:55 +02:00
parent 7b3a345b7d
commit 4bdb08bf3c
No known key found for this signature in database
GPG key ID: CB5738652768F7E9
5 changed files with 83 additions and 14 deletions

View file

@ -353,13 +353,29 @@ htmlify_host() {
mkdir -p "$HTML_BASE/$host/${HTML_OK_DIR}" "$HTML_BASE/$host/${HTML_ERR_DIR}"
if [ -n "$SITE_GEN" ] && [ -f "$SITE_GEN/console_to_html.py" ]; then
# PYTHONWARNINGS: never let SyntaxWarning leak into the suite log (tee).
# stderr → agent log file only, not the mon console stream.
# Never convert with a pre-1.15.8 generator (old assets → SyntaxWarning + bad sticky JS).
if grep -qE 'if \(/\^\[[╔╗╚╝║═]' "$SITE_GEN/console_to_html.py" 2>/dev/null; then
echo "ERROR: refuse stale site-gen $SITE_GEN/console_to_html.py (box-drawing JS regex)" >&2
return 1 2>/dev/null || exit 1
fi
# SyntaxWarning = generator regression: fail convert (do not publish old-style pages).
# Other stderr still goes to agent log file only, not the mon console stream.
_mon_html_py() {
PYTHONWARNINGS=ignore::SyntaxWarning \
python3 "$SITE_GEN/console_to_html.py" "$@" 2>>"${LOG_DIR:-/tmp}/console_to_html.err"
local _out="" _i
for _i in "$@"; do
if [ "$_i" = "--out" ]; then _out=1; continue; fi
if [ "$_out" = "1" ]; then _out="$_i"; break; fi
done
PYTHONWARNINGS=error::SyntaxWarning \
python3 "$SITE_GEN/console_to_html.py" "$@" 2>>"${LOG_DIR:-/tmp}/console_to_html.err" || return 1
# Never leave pre-1.15.8 sticky JS in a just-written page (stale log text is filtered in converter).
if [ -n "$_out" ] && [ -f "$_out" ] && grep -qE 'if \(/\^\[[╔╗╚╝║═]' "$_out" 2>/dev/null; then
echo "ERROR: generated mon HTML still has stale box-drawing JS: $_out" >&2
return 1
fi
return 0
}
_mon_html_py \
if ! _mon_html_py \
--lang "${TALER_MON_LANG:-en}" \
--log "$LOG" \
--out "$mon_err" \
@ -373,37 +389,49 @@ htmlify_host() {
--page-label "$PAGE_LABEL" \
--path-err "$HTML_URL_ERR" \
--link-other "$HTML_URL_OK"
then
echo "ERROR: mon HTML convert failed (err page) for $host — refuse publish of stale/broken assets" >&2
return 1 2>/dev/null || exit 1
fi
if [ "$ec" -eq 0 ]; then
_mon_html_py \
--lang "${TALER_MON_LANG:-en}" \
if ! _mon_html_py \
--lang "${TALER_MON_LANG:-en}" \
--log "$LOG" \
--out "$mon" \
--hostname "$host" \
--mode ok \
--commit "${COMMIT:-}" \
--commit-url "${COMMIT_URL:-}" \
--suite-version "${SUITE_VERSION:-unknown}" \
--suite-version-url "${SUITE_VERSION_URL:-}" \
--suite-version "${SUITE_VERSION:-unknown}" \
--suite-version-url "${SUITE_VERSION_URL:-}" \
--suite-path "$SUITE_PATH" \
--page-label "$PAGE_LABEL" \
--path-err "$HTML_URL_ERR" \
--link-other ""
then
echo "ERROR: mon HTML convert failed (ok page) for $host" >&2
return 1 2>/dev/null || exit 1
fi
rm -rf "$HTML_BASE/$host/${HTML_ERR_DIR}"
echo "html $host${HTML_URL_OK} only (clean · ${COMMIT_SHORT:-?})"
else
_mon_html_py \
--lang "${TALER_MON_LANG:-en}" \
if ! _mon_html_py \
--lang "${TALER_MON_LANG:-en}" \
--log "$LOG" \
--out "$mon" \
--hostname "$host" \
--mode redirect \
--commit "${COMMIT:-}" \
--commit-url "${COMMIT_URL:-}" \
--suite-version "${SUITE_VERSION:-unknown}" \
--suite-version-url "${SUITE_VERSION_URL:-}" \
--suite-version "${SUITE_VERSION:-unknown}" \
--suite-version-url "${SUITE_VERSION_URL:-}" \
--suite-path "$SUITE_PATH" \
--page-label "$PAGE_LABEL" \
--path-err "$HTML_URL_ERR"
then
echo "ERROR: mon HTML convert failed (redirect page) for $host" >&2
return 1 2>/dev/null || exit 1
fi
echo "html $host${HTML_URL_OK} stub + ${HTML_URL_ERR} (ec=$ec · ${COMMIT_SHORT:-?})"
fi
else

View file

@ -142,4 +142,12 @@ fi
ln -sfn "$SUITE_DIR" "$HOME/taler-monitoring" 2>/dev/null || true
chmod +x taler-monitoring.sh check_*.sh host-agent/*.sh site-gen/*.sh site-gen/*.py 2>/dev/null || true
# Drop bytecode so a stale site-gen never wins over the tree we just reset to.
rm -rf "$SUITE_DIR/site-gen/__pycache__" 2>/dev/null || true
# Refuse known-bad pre-1.15.8 generator (box-drawing JS regex → SyntaxWarning noise)
if [ -f "$SUITE_DIR/site-gen/console_to_html.py" ] \
&& grep -qE 'if \(/\^\[[╔╗╚╝║═]' "$SUITE_DIR/site-gen/console_to_html.py" 2>/dev/null; then
_upd_die "site-gen/console_to_html.py still has pre-1.15.8 box-drawing JS regex — refuse stale generator"
return 1 2>/dev/null || exit 1
fi
return 0 2>/dev/null || true