From c10d2f61b016353e5036f55f0533dac2279a421c Mon Sep 17 00:00:00 2001 From: sascha Date: Sat, 8 Aug 2026 14:05:08 +0200 Subject: [PATCH] fix: refresh Butler vault cache before DNS update --- app.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index b2cfa6b..32078e7 100644 --- a/app.py +++ b/app.py @@ -977,10 +977,26 @@ print(backup) return {"status": "reloaded", "backup": backup} -async def _upsert_dns_records(zone: str, name: str) -> dict: +def _get_hetzner_dns_token() -> str: + token = _read("HETZNER_DNS_TOKEN") + if token: + return token + rc, _out, err = _ssh( + "sascha@10.4.1.116", + "sudo /app-config/homelab-butler/vault-sync.sh", + timeout=120, + ) + if rc != 0: + raise RuntimeError(f"Vault cache sync failed: {err[-300:]}") + _load_vault_cache() token = _read("HETZNER_DNS_TOKEN") if not token: - raise RuntimeError("HETZNER_DNS_TOKEN is unavailable") + raise RuntimeError("HETZNER_DNS_TOKEN is unavailable after vault sync") + return token + + +async def _upsert_dns_records(zone: str, name: str) -> dict: + token = await asyncio.to_thread(_get_hetzner_dns_token) headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"} api = "https://api.hetzner.cloud/v1" async with httpx.AsyncClient(timeout=30) as client: