Files
felhom.eu/documentation/audits/night-2026-10-25/tools/r1288rig.py
T

59 lines
3.1 KiB
Python

#!/usr/bin/env python3
"""r1288rig.py — R-1288 live on the night's rig (rc.2): the Tester 1 order with a throwaway Tandoor — install, back up,
remove keeping backups, reinstall (its first backup sets install A aside: one alarm), restore A's set-aside copy →
the replaced install's unit is set aside AT the restore („replaced by the restored install"), no second alarm; the
next backup sets nothing aside. Removed through the product at the end."""
import json, os, re, sys, time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import rigw # noqa: E402 (must come first: it points the walk at the rig)
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../catalog-sweep-2026-10-24/tools"))
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../restore-truth-2026-10-25/tools"))
import sweep as sw # noqa: E402
import unitprobe2 as up # noqa: E402
w, fxm = sw.w, sw.fxm
APP = "tandoor"
AS = "/mnt/felhom-drives/adat/felhom-data/backups/set-aside/tandoor"
def say(*a):
print(time.strftime("%H:%M:%SZ", time.gmtime()), *a, flush=True)
w.say = say
fx = fxm.FIXTURES[APP]
sub = getattr(fx, "sub", APP)
w.login()
t0 = int(time.time())
try:
w.deploy(APP, sub) and w.wait_app(sub, "/", tries=90, delay=5)
tok = fx.seed(w, sub, say)
sw.backup_now({}, say)
sw.remove(APP, keep=True, say=say)
w.deploy(APP, sub, dict(w.GENERATED.get(APP) or {}))
for _ in range(60):
time.sleep(10)
if sw.g(f"docker logs --since {t0} felhom-controller 2>&1 | grep -c 'recovery unit of an earlier install'").strip() not in ("", "0"):
break
say("set-aside dirs after the reinstall's backup:", sw.g(f"find /mnt/felhom-drives -path '*set-aside/tandoor/*' -maxdepth 6 -mindepth 6 -type d 2>/dev/null | wc -l").strip())
html = up.page("/backups/restore")
m = re.search(r'action="/backup/kept/restore".*?name="id" value="([0-9a-f]{16})"', html, re.S)
t_r = int(time.time())
head, loc = up.post_form("/backup/kept/restore", {"id": m.group(1), "confirm": "1"})
say("POST /backup/kept/restore ->", head)
rec = {}
up.wait_restore("kept", rec)
say("restore:", rec["kept"]["status"][:200])
time.sleep(20)
say("item back:", bool(tok) and bool(fx.verify(w, sub, tok, say)))
say("controller lines since the restore:")
print(sw.g(f"docker logs --since {t_r} felhom-controller 2>&1 | grep -E 'replaced by the restored install|SET ASIDE|set aside|Event pushed: backup_run_failures' | cut -c1-260"))
say("set-aside dirs after the restore:", sw.g(f"find /mnt/felhom-drives -path '*set-aside/tandoor/*' -maxdepth 6 -mindepth 6 -type d 2>/dev/null | wc -l").strip())
t_b = int(time.time())
sw.backup_now({}, say)
say("after the next backup — set-aside lines:", sw.g(f"docker logs --since {t_b} felhom-controller 2>&1 | grep -c 'recovery unit of an earlier install'").strip(),
"| set-aside dirs:", sw.g(f"find /mnt/felhom-drives -path '*set-aside/tandoor/*' -maxdepth 6 -mindepth 6 -type d 2>/dev/null | wc -l").strip())
finally:
sw.remove(APP, keep=False, say=say)
say("after remove:", sw.leftovers(APP, sub))