fix 1.23.5: per-job mon page publish (no full-tree rsync --delete)

Shared /var/www/monitoring-sites is multi-agent. Full-tree --delete wiped
sibling families (e.g. monitoring-max-ladder after main/surface runs).
Publish only HTML_OK_DIR/HTML_ERR_DIR per host; apply-monitoring-live merges.
This commit is contained in:
Hernâni Marques 2026-07-22 03:35:05 +02:00
parent 9b065c10ab
commit f38142cbd3
No known key found for this signature in database
7 changed files with 61 additions and 13 deletions

View file

@ -7,7 +7,7 @@
# 2) line-buffered run log (written continuously)
# 3) RUN_TIMEOUT wall clock for taler-monitoring.sh (default 600s)
# 4) always write HTML (first run / empty staging too) + Forgejo commit link
# 5) rsync to DEPLOY_WWW_ROOT (ERROR if not writable — v1.3.1)
# 5) publish this job's page dirs only to DEPLOY_WWW_ROOT (never full-tree --delete)
# 6) monpages post-check: public FQDN must serve monitoring HTML
# 7) exit code: STRICT_EXIT default 1 (v1.7.1) — unit fails if publish/public pages fail
#
@ -454,16 +454,55 @@ for host in $MON_HOSTS; do
echo "public URL (expected): https://${host}${HTML_URL_OK}"
done
# Publish to live web root when possible (v1.3.1+: never silent-skip)
# Publish to live web root when possible (v1.3.1+: never silent-skip).
# Multi-agent shared tree (monitoring, max-ladder, surface, aptdeploy, …):
# NEVER rsync --delete the whole staging/www root — that wiped sibling pages.
# Publish only this job's HTML_OK_DIR / HTML_ERR_DIR under each MON_HOSTS entry.
publish_job_mon_pages() {
local host d src dst
local ok_dir="${HTML_OK_DIR:-monitoring}"
local err_dir="${HTML_ERR_DIR:-monitoring_err}"
for host in $MON_HOSTS; do
[ -n "$host" ] || continue
mkdir -p "$DEPLOY_WWW/$host"
for d in "$ok_dir" "$err_dir"; do
[ -n "$d" ] || continue
src="$HTML_BASE/$host/$d"
dst="$DEPLOY_WWW/$host/$d"
if [ -d "$src" ]; then
mkdir -p "$dst"
# --delete only within this page dir (stale files inside the page)
if ! rsync -a --delete --delay-updates "$src/" "$dst/"; then
echo "ERROR: rsync page failed: $src/ → $dst/" >&2
return 1
fi
echo " published $host/$d/"
else
# intentional absence (clean OK run removes _err) → drop only this page live
if [ -e "$dst" ]; then
rm -rf "$dst"
echo " removed $host/$d/ (absent in staging for this job)"
fi
fi
done
if [ -f "$HTML_BASE/$host/COMMIT" ]; then
cp -a "$HTML_BASE/$host/COMMIT" "$DEPLOY_WWW/$host/COMMIT"
fi
if [ -f "$HTML_BASE/$host/COMMIT_URL" ]; then
cp -a "$HTML_BASE/$host/COMMIT_URL" "$DEPLOY_WWW/$host/COMMIT_URL"
fi
done
return 0
}
if [ -n "$DEPLOY_WWW" ]; then
if [ -w "$DEPLOY_WWW" ] 2>/dev/null; then
# --delay-updates: write to temp names then rename (less partial-file exposure)
if rsync -a --delete --delay-updates "$HTML_BASE/" "$DEPLOY_WWW/"; then
echo "synced → $DEPLOY_WWW/ (delay-updates)"
if publish_job_mon_pages; then
echo "synced job pages → $DEPLOY_WWW/ (per-dir, no full-tree delete)"
# brief settle so concurrent monpages curls do not hit mid-rename FS views
sleep "${MONPAGES_PUBLISH_SETTLE_S:-0.3}" 2>/dev/null || sleep 1
else
echo "ERROR: rsync to DEPLOY_WWW_ROOT=$DEPLOY_WWW failed" >&2
echo "ERROR: publish to DEPLOY_WWW_ROOT=$DEPLOY_WWW failed" >&2
ec=1
fi
elif [ -e "$DEPLOY_WWW" ]; then