From e6e6189b53b711231d900e4398484f113fdf6c74 Mon Sep 17 00:00:00 2001 From: repo-worker-code-g Date: Fri, 6 Nov 2026 23:08:26 -0600 Subject: [PATCH] backup: keep retired Meta exporter data optional --- nixos/home/pm-dashboard-backup-date.test.sh | 6 ++++- .../home/pm-dashboard-backup-manifest.test.sh | 25 +++++++++++++------ nixos/home/pm-dashboard-backup-prune.test.sh | 3 ++- nixos/home/pm-dashboard-backup-record.test.sh | 18 ++++++------- nixos/home/pm-dashboard-backup.sh | 17 ++++++------- nixos/home/pm-dashboard-backup.test.sh | 12 +++++++-- 6 files changed, 51 insertions(+), 30 deletions(-) diff --git a/nixos/home/pm-dashboard-backup-date.test.sh b/nixos/home/pm-dashboard-backup-date.test.sh index f91efcd657..43fb330e87 100755 --- a/nixos/home/pm-dashboard-backup-date.test.sh +++ b/nixos/home/pm-dashboard-backup-date.test.sh @@ -90,7 +90,11 @@ run_scenario() { printf '{}\n' >"$home/.local/state/pm-aggregator/actions.json" # Full required set (#1025): a missing required member now fails # the run at verify, so the fixture carries every required file. - for f in comments.json fleet-feed.json quota-current.json registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json; do printf '{}\n' >"$home/.local/state/pm-aggregator/$f"; done + for f in actions.json comments.json fleet-feed.json quota-current.json registry.json \ + quota-gatherer-state.json quota-gatherer-heartbeat.json events.json \ + coverage-snapshot.json aa-last-good.json; do + printf '{}\n' >"$home/.local/state/pm-aggregator/$f" + done printf '{}\n' >"$home/atlas/meta-quota-export/latest.json" printf '{}\n' >"$home/atlas/meta-quota-export/history.jsonl" HOME="$home" PATH="$BIN:$PATH" BWS_ACCESS_TOKEN="" \ diff --git a/nixos/home/pm-dashboard-backup-manifest.test.sh b/nixos/home/pm-dashboard-backup-manifest.test.sh index 8d9b4556e8..74cad1acb9 100755 --- a/nixos/home/pm-dashboard-backup-manifest.test.sh +++ b/nixos/home/pm-dashboard-backup-manifest.test.sh @@ -6,9 +6,10 @@ # whatever staging produced — a dataset member deleted/renamed at # the source silently shrank the backup set with every check green. # The script now declares the expected set once (EXPECTED_SET): -# 7 aggregator state files + 2 meta-quota-export files are REQUIRED, -# db-dumps is required when the DB dump step ran (optional when it -# did not), and the snapshots tree + 3 journal logs are OPTIONAL. +# 10 aggregator state files are REQUIRED, meta-quota-export files are +# OPTIONAL, and db-dumps is required when the DB dump step ran +# (optional when it did not). The snapshots tree + 2 journal logs are +# OPTIONAL. # manifest.json records every member's status, and the verify step # fails the run — naming the member, before any upload, cursor # unchanged — when a required member is missing. @@ -62,6 +63,7 @@ STUB { printf '#!%s\n' "$BASH"; cat <<'STUB' echo "stub journal line" +printf '%s\n' "$*" >>"$HOME/.journalctl-calls" exit 0 STUB } >"$BIN/journalctl" @@ -199,6 +201,7 @@ assert_member deleted-required aggregator/registry.json required missing # --- missing-optional completes and is recorded ------------------------------- setup_home missing-optional +rm -rf "$RUN_HOME/atlas/meta-quota-export" run_backup missing-optional if [[ "$RC" -eq 0 ]]; then ok "missing-optional: script exited 0" @@ -213,16 +216,22 @@ fi assert_member missing-optional aggregator/snapshots optional missing assert_member missing-optional db-dumps optional missing assert_member missing-optional aggregator/actions.json required present -assert_member missing-optional meta-quota-export/history.jsonl required present +assert_member missing-optional meta-quota-export/latest.json optional missing +assert_member missing-optional meta-quota-export/history.jsonl optional missing assert_member missing-optional journals/pm-aggregator.log optional present +if grep -q -- 'meta-quota-export.service' "$RUN_HOME/.journalctl-calls"; then + fail "missing-optional: retired meta-quota-export journal was queried" +else + ok "missing-optional: retired meta-quota-export journal was not queried" +fi if manifest_json missing-optional | python3 -c ' import json, sys m = json.load(sys.stdin) -sys.exit(0 if len(m.get("expected", [])) == 20 else 1) +sys.exit(0 if len(m.get("expected", [])) == 19 else 1) '; then - ok "missing-optional: manifest lists all 20 expected members" + ok "missing-optional: manifest lists all 19 expected members" else - fail "missing-optional: manifest expected list is not the full 20-member set" + fail "missing-optional: manifest expected list is not the full 19-member set" fi # --- dump step ran but produced no dir: conditionally required ---------------- @@ -250,6 +259,8 @@ else fail "dump-ran-with-dir: expected exit 0, got $RC; log: $(cat "$TMP_ROOT/dump-ran-with-dir.log")" fi assert_member dump-ran-with-dir db-dumps required present +assert_member dump-ran-with-dir meta-quota-export/latest.json optional present +assert_member dump-ran-with-dir meta-quota-export/history.jsonl optional present if (( failures > 0 )); then echo "pm-dashboard-backup manifest tests: $failures failure(s)" >&2 diff --git a/nixos/home/pm-dashboard-backup-prune.test.sh b/nixos/home/pm-dashboard-backup-prune.test.sh index 26f6b78942..a9cbd03d65 100644 --- a/nixos/home/pm-dashboard-backup-prune.test.sh +++ b/nixos/home/pm-dashboard-backup-prune.test.sh @@ -55,7 +55,8 @@ mkdir -p "$HOME_DIR/.local/state/pm-aggregator" "$HOME_DIR/atlas/meta-quota-expo # --- fixture data set ------------------------------------------------------- for f in actions.json comments.json fleet-feed.json quota-current.json \ - registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json; do + registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json \ + events.json coverage-snapshot.json aa-last-good.json; do echo "{\"fixture\": \"$f\"}" > "$HOME_DIR/.local/state/pm-aggregator/$f" done echo '{"fixture": "latest"}' > "$HOME_DIR/atlas/meta-quota-export/latest.json" diff --git a/nixos/home/pm-dashboard-backup-record.test.sh b/nixos/home/pm-dashboard-backup-record.test.sh index 03784564c2..2f8ea04377 100644 --- a/nixos/home/pm-dashboard-backup-record.test.sh +++ b/nixos/home/pm-dashboard-backup-record.test.sh @@ -97,8 +97,7 @@ chmod +x "$BIN/bws" "$BIN/journalctl" "$BIN/rclone" run_scenario() { local name="$1" fail_mode="$2" dump_mode="${3:-absent}" local home="$TMP_ROOT/$name/home" - mkdir -p "$home/backups/dashboard" "$home/.local/state/pm-aggregator" \ - "$home/atlas/meta-quota-export" + mkdir -p "$home/backups/dashboard" "$home/.local/state/pm-aggregator" local dump_script="$home/no-such-dump-script.sh" if [[ $dump_mode == "ok" ]]; then dump_script="$home/dump-ok.sh" @@ -116,11 +115,11 @@ run_scenario() { } >"$dump_script" chmod +x "$dump_script" fi - for f in actions.json comments.json fleet-feed.json quota-current.json registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json; do + for f in actions.json comments.json fleet-feed.json quota-current.json registry.json \ + quota-gatherer-state.json quota-gatherer-heartbeat.json events.json \ + coverage-snapshot.json aa-last-good.json; do printf '{}\n' >"$home/.local/state/pm-aggregator/$f" done - printf '{}\n' >"$home/atlas/meta-quota-export/latest.json" - printf '{}\n' >"$home/atlas/meta-quota-export/history.jsonl" HOME="$home" PATH="$BIN:$PATH" BWS_ACCESS_TOKEN="" \ RCLONE_FAIL="$fail_mode" RCLONE_STUB_DIR="$TMP_ROOT/$name/rclone-store" \ PM_DB_DUMP_SCRIPT="$dump_script" \ @@ -202,13 +201,12 @@ check_record r2fail "$TMP_ROOT/assert-r2fail.py" # exit_code 143 -- never a fresh "complete" record the watchdog would # accept as healthy (Codex finding on PR 2989). sig_home="$TMP_ROOT/sigterm/home" -mkdir -p "$sig_home/backups/dashboard" "$sig_home/.local/state/pm-aggregator" \ - "$sig_home/atlas/meta-quota-export" -for f in actions.json comments.json fleet-feed.json quota-current.json registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json; do +mkdir -p "$sig_home/backups/dashboard" "$sig_home/.local/state/pm-aggregator" +for f in actions.json comments.json fleet-feed.json quota-current.json registry.json \ + quota-gatherer-state.json quota-gatherer-heartbeat.json events.json \ + coverage-snapshot.json aa-last-good.json; do printf '{}\n' >"$sig_home/.local/state/pm-aggregator/$f" done -printf '{}\n' >"$sig_home/atlas/meta-quota-export/latest.json" -printf '{}\n' >"$sig_home/atlas/meta-quota-export/history.jsonl" setsid env HOME="$sig_home" PATH="$BIN:$PATH" BWS_ACCESS_TOKEN="" \ BWS_BLOCK=1 BWS_BLOCK_MARKER="$TMP_ROOT/sigterm.blocked" \ RCLONE_STUB_DIR="$TMP_ROOT/sigterm/rclone-store" \ diff --git a/nixos/home/pm-dashboard-backup.sh b/nixos/home/pm-dashboard-backup.sh index 6609adaf6e..72de21e294 100755 --- a/nixos/home/pm-dashboard-backup.sh +++ b/nixos/home/pm-dashboard-backup.sh @@ -322,10 +322,10 @@ mkdir -p "$STAGE/aggregator" "$STAGE/meta-quota-export" "$STAGE/journals" "$OUTD # the source silently shrank the backup set. Classes preserve the # intent the staging code below has always had: existing state files # are required (their WARN-for-missing becomes a failed run at verify); -# the snapshots tree and the journal logs are optional (journals keep -# their tolerated-unavailable placeholder, but are now recorded); -# db-dumps is CONDITIONALLY required — required when the DB dump step -# ran (DUMP_RAN=1), optional otherwise. +# retired meta-quota-export files, the snapshots tree and active journal +# logs are optional; journals keep their tolerated-unavailable +# placeholder, but are now recorded; db-dumps is CONDITIONALLY required +# — required when the DB dump step ran (DUMP_RAN=1), optional otherwise. EXPECTED_SET="required file aggregator/actions.json required file aggregator/comments.json required file aggregator/fleet-feed.json @@ -338,14 +338,13 @@ required file aggregator/coverage-snapshot.json required file aggregator/aa-last-good.json optional file aggregator/views.json optional tree aggregator/charge-inputs -required file meta-quota-export/latest.json -required file meta-quota-export/history.jsonl +optional file meta-quota-export/latest.json +optional file meta-quota-export/history.jsonl conditional tree db-dumps conditional file projector/pmp_links.sql optional tree aggregator/snapshots optional file journals/pm-aggregator.log -optional file journals/quota-gatherer.log -optional file journals/meta-quota-export.log" +optional file journals/quota-gatherer.log" # --- data set (explicit list only; the aggregator .env is deliberately NOT # --- included — no config/secret files belong in this archive) --- @@ -434,7 +433,7 @@ case "$LAST" in *[!0-9]* | "") LAST=0 ;; esac W=$((NOW_EPOCH - 86400)) if [ "$LAST" -gt 0 ] && [ "$LAST" -lt "$W" ]; then W="$LAST"; fi SINCE_STR="$(date -d "@$W" '+%F %T')" -for svc in pm-aggregator quota-gatherer meta-quota-export; do +for svc in pm-aggregator quota-gatherer; do journalctl --user -u "$svc.service" --since "$SINCE_STR" --no-pager -o short-iso \ >"$STAGE/journals/$svc.log" 2>/dev/null || echo "(journal unavailable for $svc)" >"$STAGE/journals/$svc.log" diff --git a/nixos/home/pm-dashboard-backup.test.sh b/nixos/home/pm-dashboard-backup.test.sh index f702359fd9..d693e594c1 100755 --- a/nixos/home/pm-dashboard-backup.test.sh +++ b/nixos/home/pm-dashboard-backup.test.sh @@ -105,7 +105,11 @@ run_scenario() { printf '{}\n' >"$home/.local/state/pm-aggregator/actions.json" # Full required set (#1025): a missing required member now fails # the run at verify, so the fixture carries every required file. - for f in comments.json fleet-feed.json quota-current.json registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json; do printf '{}\n' >"$home/.local/state/pm-aggregator/$f"; done + for f in actions.json comments.json fleet-feed.json quota-current.json registry.json \ + quota-gatherer-state.json quota-gatherer-heartbeat.json events.json \ + coverage-snapshot.json aa-last-good.json; do + printf '{}\n' >"$home/.local/state/pm-aggregator/$f" + done printf '{}\n' >"$home/atlas/meta-quota-export/latest.json" printf '{}\n' >"$home/atlas/meta-quota-export/history.jsonl" echo "$PRESET" >"$home/backups/dashboard/.last-run-epoch" @@ -160,7 +164,11 @@ mkdir -p "$tf_home/backups/dashboard" "$tf_home/.local/state/pm-aggregator" \ printf '{}\n' >"$tf_home/.local/state/pm-aggregator/actions.json" # Full required set (#1025): a missing required member now fails # the run at verify, so the fixture carries every required file. -for f in comments.json fleet-feed.json quota-current.json registry.json quota-gatherer-state.json quota-gatherer-heartbeat.json; do printf '{}\n' >"$tf_home/.local/state/pm-aggregator/$f"; done +for f in actions.json comments.json fleet-feed.json quota-current.json registry.json \ + quota-gatherer-state.json quota-gatherer-heartbeat.json events.json \ + coverage-snapshot.json aa-last-good.json; do + printf '{}\n' >"$tf_home/.local/state/pm-aggregator/$f" +done printf '{}\n' >"$tf_home/atlas/meta-quota-export/latest.json" printf '{}\n' >"$tf_home/atlas/meta-quota-export/history.jsonl" HOME="$tf_home" PATH="$TARBIN:$BIN:$PATH" BWS_ACCESS_TOKEN="" \