"""Persistence hook: restart all actual services and explicit operator unseal.""" from pathlib import Path import subprocess import time ROOT=Path(__file__).resolve().parents[1] DC=['docker','compose','--env-file','.env'] def call(*args):subprocess.run(DC+list(args),cwd=ROOT,check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL) sidecars=['api1-tls','api2-tls','broker-tls','otel-collector-tls','prometheus-tls','loki-tls','tempo-tls','grafana-tls'] # Stop shared-network sidecars before replacing the parent's namespace. call('stop',*sidecars) call('restart','postgres','s3','broker','openbao','otel-collector','prometheus','loki','tempo','grafana','api1','api2','publisher','worker','janitor','lb') for _ in range(20): try: call('run','--rm','--no-deps','operator','python','scripts/bootstrap.py','unseal') break except subprocess.CalledProcessError:time.sleep(1) else:raise RuntimeError('operator unseal failed') call('up','-d','--no-deps','--force-recreate',*sidecars)