gates / gates (push) Successful in 5s
RomM writes saves to /romm/assets, which sat in the image's anonymous /romm volume: no app backup took it (measured on demo-hp). romm_assets is now a named volume (compose + both steps files); gate image-volumes keeps it. default_creds removed from grafana, gokapi, kimai, code-server, nzbget, nextcloud, transmission, prowlarr (HU + EN): the box said 'starts with a known, shared password' about logins it generated. Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
140 lines
5.4 KiB
Python
140 lines
5.4 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""check-image-volumes.py — a household-data path an image keeps in its own anonymous VOLUME is mounted by the template.
|
|
|
|
python3 scripts/check-image-volumes.py # every template (+ its steps/ files)
|
|
python3 scripts/check-image-volumes.py --root DIR # another checkout (the decoy harness)
|
|
|
|
WHY (R-1097, 2026-10-16). RomM 5.3.1's image declares `VOLUME /romm`, and the app writes the household's saves, save
|
|
states and screenshots to `/romm/assets` (`ASSETS_BASE_PATH`, backend/config/__init__.py:39). The template mounted
|
|
nothing there, so Docker gave the container an ANONYMOUS volume — and the app backup takes only the named volumes the
|
|
compose declares and the drive folders it binds (`backup.ResolveDockerVolumeNames`). Measured on demo-hp 9201: every
|
|
earlier RomM backup held romm_config, romm_db_data, romm_redis_data — and no saves
|
|
(felhom.eu audits/burndown-apps-2026-10-16/P1). The fix is a named volume; this gate keeps it there.
|
|
|
|
THE REGISTRY is measured, not guessed: each entry is an image whose own VOLUME holds household data, with the path(s)
|
|
the app writes that data to. Add an entry when a measurement finds one (`docker inspect` of the running container:
|
|
a 64-hex volume name at a data path). A path is satisfied by a mount AT that path on a service running that image —
|
|
a named volume or a bind. A mount at a parent (`/romm`) or a child (`/romm/assets/x`) is not the same thing and fails.
|
|
|
|
STANDARD LIBRARY ONLY (the CI runner has no PyYAML): services, `image:` and short-syntax `volumes:` entries are read by
|
|
indentation; comments never count.
|
|
"""
|
|
import io
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# image repository (no tag, no digest) → data paths it keeps in its own anonymous VOLUME
|
|
REGISTRY = {
|
|
"rommapp/romm": ["/romm/assets"], # R-1097, measured on demo-hp 9201 2026-10-16
|
|
}
|
|
|
|
|
|
def strip_comment(line):
|
|
out, q = [], None
|
|
for c in line:
|
|
if q:
|
|
if c == q:
|
|
q = None
|
|
elif c in "'\"":
|
|
q = c
|
|
elif c == "#":
|
|
break
|
|
out.append(c)
|
|
return "".join(out).rstrip()
|
|
|
|
|
|
def repo_of(image):
|
|
image = image.strip().strip("'\"").split("@", 1)[0]
|
|
last = image.rsplit("/", 1)[-1]
|
|
if ":" in last:
|
|
image = image[: len(image) - len(last)] + last.split(":", 1)[0]
|
|
return image
|
|
|
|
|
|
def services(path):
|
|
"""{service: (image repo, [mount targets])} from a compose file."""
|
|
out, cur, in_svcs, in_vols = {}, None, False, False
|
|
with io.open(path, encoding="utf-8") as f:
|
|
for raw in f:
|
|
line = strip_comment(raw.rstrip("\n"))
|
|
if not line.strip():
|
|
continue
|
|
ind = len(line) - len(line.lstrip(" "))
|
|
if ind == 0:
|
|
in_svcs = line.startswith("services:")
|
|
cur = None
|
|
continue
|
|
if not in_svcs:
|
|
continue
|
|
if ind == 2 and line.strip().endswith(":"):
|
|
cur = line.strip()[:-1]
|
|
out[cur] = ["", []]
|
|
in_vols = False
|
|
continue
|
|
if cur is None:
|
|
continue
|
|
if ind == 4:
|
|
in_vols = line.strip() == "volumes:"
|
|
m = re.match(r"^\s{4}image:\s*(\S+)", line)
|
|
if m:
|
|
out[cur][0] = repo_of(m.group(1))
|
|
continue
|
|
if in_vols and ind >= 6:
|
|
m = re.match(r"^\s*-\s*(.+)$", line)
|
|
if m:
|
|
spec = m.group(1).strip().strip("'\"")
|
|
parts = spec.split(":")
|
|
if len(parts) >= 2:
|
|
out[cur][1].append(parts[1])
|
|
return out
|
|
|
|
|
|
def compose_files(tdir):
|
|
for app in sorted(os.listdir(tdir)):
|
|
d = os.path.join(tdir, app)
|
|
p = os.path.join(d, "docker-compose.yml")
|
|
if os.path.isfile(p):
|
|
yield app, p
|
|
sd = os.path.join(d, "steps")
|
|
if os.path.isdir(sd):
|
|
for fn in sorted(os.listdir(sd)):
|
|
if fn.endswith(".yml") and not fn.endswith(".felhom.yml"):
|
|
yield app, os.path.join(sd, fn)
|
|
|
|
|
|
def main(argv):
|
|
root = ROOT
|
|
for a in argv:
|
|
if a.startswith("--root="):
|
|
root = a.split("=", 1)[1]
|
|
if "--root" in argv:
|
|
root = argv[argv.index("--root") + 1]
|
|
tdir = os.path.join(root, "templates")
|
|
if not os.path.isdir(tdir):
|
|
print("check-image-volumes: no templates/ under %s — nothing to judge (a failure, never a pass)" % root)
|
|
return 3
|
|
bad, judged = [], 0
|
|
for app, p in compose_files(tdir):
|
|
for svc, (repo, targets) in services(p).items():
|
|
for need in REGISTRY.get(repo, []):
|
|
judged += 1
|
|
if need not in targets:
|
|
bad.append("%s: service %s (%s) does not mount %s — the image keeps it in an anonymous volume, "
|
|
"which no app backup takes (R-1097). Mount a named volume there." % (
|
|
os.path.relpath(p, root), svc, repo, need))
|
|
if bad:
|
|
print("check-image-volumes: %d FAILURE(S)" % len(bad))
|
|
for b in bad:
|
|
print(" - " + b)
|
|
return 1
|
|
print("check-image-volumes gate OK — %d registered data path(s) mounted" % judged)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv[1:]))
|