Container: Vault-Prüfung ohne festen Dateiaufbau (wie systemd)
Deploy mindnet DEV (Container) / deploy (push) Successful in 50s
Deploy mindnet DEV (Container) / deploy (push) Successful in 50s
Der Preflight verlangte _system/dictionary/edge_vocabulary.md, die es nur im NAS-Vault gibt. Der Dev-Vault vault_master ist anders aufgebaut, systemd prüft nichts davon. Jetzt: Vault muss lesbar und nicht leer sein; eine bestimmte Datei nur noch optional über MINDNET_VAULT_SENTINEL. Default für MINDNET_VAULT_ROOT wie in app/config.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6a2ab522fc
commit
347ca50e71
4 files changed
+47
-19
No files matched your search
+19
-7
@@ -102,19 +102,31 @@ def _is_read_only_mount(path: Path) -> bool:
|
||||
return bool(os.statvfs(path).f_flag & os.ST_RDONLY)
|
||||
|
||||
|
||||
DEFAULT_VAULT_ROOT = "./vault_master" # Default aus app/config.py
|
||||
|
||||
|
||||
def check_vault() -> None:
|
||||
if not _flag("MINDNET_VAULT_REQUIRED", "true"):
|
||||
return
|
||||
root = Path(os.getenv("MINDNET_VAULT_ROOT", ""))
|
||||
if not str(root) or not root.is_dir():
|
||||
root = Path(os.getenv("MINDNET_VAULT_ROOT") or DEFAULT_VAULT_ROOT)
|
||||
if not root.is_dir():
|
||||
raise PreflightError(f"Vault-Verzeichnis fehlt: '{root}'.")
|
||||
# Ein ausgefallenes NAS hinterlässt einen leeren Mountpunkt; der Sentinel unterscheidet das.
|
||||
sentinel = root / os.getenv("MINDNET_VAULT_SENTINEL", "_system/dictionary/edge_vocabulary.md")
|
||||
# Ein ausgefallenes NAS hinterlässt einen leeren Mountpunkt.
|
||||
try:
|
||||
with sentinel.open("rb") as f:
|
||||
f.read(1)
|
||||
empty = next(root.iterdir(), None) is None
|
||||
except OSError:
|
||||
raise PreflightError(f"Vault-Sentinel nicht lesbar: '{sentinel}' (NAS nicht gemountet?).") from None
|
||||
raise PreflightError(f"Vault '{root}' nicht lesbar (NAS nicht gemountet?).") from None
|
||||
if empty:
|
||||
raise PreflightError(f"Vault '{root}' ist leer (NAS nicht gemountet?).")
|
||||
# Optional: zusätzlich eine bestimmte Datei verlangen (z. B. auf dem NAS-Vault).
|
||||
sentinel_name = os.getenv("MINDNET_VAULT_SENTINEL", "").strip()
|
||||
if sentinel_name:
|
||||
sentinel = root / sentinel_name
|
||||
try:
|
||||
with sentinel.open("rb") as f:
|
||||
f.read(1)
|
||||
except OSError:
|
||||
raise PreflightError(f"Vault-Sentinel nicht lesbar: '{sentinel}' (NAS nicht gemountet?).") from None
|
||||
if _flag("MINDNET_VAULT_READONLY", "true") and not _is_read_only_mount(root):
|
||||
raise PreflightError(f"Vault '{root}' ist nicht schreibgeschützt gemountet (':ro' erforderlich).")
|
||||
|
||||
|
||||
@@ -28,10 +28,14 @@ def main(mode: str) -> int:
|
||||
print(f"health: {mode} nicht erreichbar ({type(e).__name__})")
|
||||
return 1
|
||||
if mode == "api" and os.getenv("MINDNET_VAULT_REQUIRED", "true").lower() == "true":
|
||||
root = Path(os.getenv("MINDNET_VAULT_ROOT", ""))
|
||||
sentinel = root / os.getenv("MINDNET_VAULT_SENTINEL", "_system/dictionary/edge_vocabulary.md")
|
||||
if not sentinel.is_file():
|
||||
print(f"health: Vault-Sentinel fehlt ({sentinel})")
|
||||
root = Path(os.getenv("MINDNET_VAULT_ROOT") or "./vault_master")
|
||||
sentinel_name = os.getenv("MINDNET_VAULT_SENTINEL", "").strip()
|
||||
try:
|
||||
ok = (root / sentinel_name).is_file() if sentinel_name else next(root.iterdir(), None) is not None
|
||||
except OSError:
|
||||
ok = False
|
||||
if not ok:
|
||||
print(f"health: Vault leer oder nicht lesbar ({root})")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
Reference in new issue
Block a user