fix(storage): preserve preexisting Matrix health failures during restart

This commit is contained in:
2026-09-28 20:47:38 +02:00
parent 2b947c5e8f
commit 552a90e9e1
4 changed files with 78 additions and 3 deletions

View File

@@ -314,6 +314,7 @@ class Migration:
"matrixPaths": self.engine.matrix_backup_paths, "retainedServices": sorted(retained),
"containers": {name: {"id": c["Id"], "image": c["Image"],
"running": c["State"]["Running"], "restart": c["HostConfig"]["RestartPolicy"],
"health": c["State"].get("Health", {}).get("Status"),
"networks": c["NetworkSettings"]["Networks"]} for name, c in by_service.items()}}
# Planning errors must not leave a usable partial state file.
u.write_json(self.home / "original.json", config)
@@ -560,9 +561,19 @@ class Migration:
require(self.state.get("writesReleased"), "Schreibfreigabe fehlt.")
require(sha_file(self.root / "docker-compose.yml") == sha_file(self.home / "target.json"), "Aktive Compose-Datei verändert.")
names = [n for n, c in self.state["containers"].items() if c["running"] and n not in ("minio", "createbuckets", "traefik")]
self.compose(self.root / "docker-compose.yml", "up", "-d", "--pull", "never", "--wait", "--wait-timeout", "240", *names)
# Preserve Matrix without letting an already failing optional healthcheck
# cause a new FEDEO outage after cutover. Core services must always pass.
degraded = [n for n in names if n in u.LEGACY_MATRIX_SERVICES
and self.state["containers"][n].get("health") == "unhealthy"]
self.compose(self.root / "docker-compose.yml", "up", "-d", "--pull", "never", *names)
self.compose(self.root / "docker-compose.yml", "up", "-d", "--no-deps", "--pull", "never",
"--wait", "--wait-timeout", "240", *[n for n in names if n not in degraded])
for name in degraded:
cid = self.compose(self.root / "docker-compose.yml", "ps", "--all", "--quiet", name).strip()
require(cid and "\n" not in cid and self.inspect(cid)["State"]["Running"],
"Alter Matrix-Dienst wurde nicht wieder gestartet: " + name)
self.compose(self.root / "docker-compose.yml", "up", "-d", "--no-deps", "--pull", "never", "traefik")
self.save("complete")
self.save("complete", preexistingUnhealthyServices=degraded)
def rollback(self):
require(self.state and not self.state.get("writesReleased"), "Nach Schreibfreigabe ist eine geprüfte Rückmigration erforderlich.")