fix: refresh Butler vault cache before DNS update
This commit is contained in:
parent
9f7b93d144
commit
c10d2f61b0
1 changed files with 18 additions and 2 deletions
20
app.py
20
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue