fix(vpn): commit before sync_wireguard_config to ensure data visibility

sync_wireguard_config opens its own AdminAsyncSessionLocal connection
which cannot see uncommitted data from the caller's transaction. Add
_commit_and_sync helper that commits first, then regenerates wg0.conf.

Also removes the unused db parameter from sync_wireguard_config.
This commit is contained in:
Jason Staack
2026-03-14 16:42:17 -05:00
parent b4a7494016
commit b5f9bf14df
3 changed files with 27 additions and 18 deletions

View File

@@ -232,13 +232,11 @@ async def delete_tenant(
had_vpn = await get_vpn_config(db, tenant_id)
await db.delete(tenant)
await db.flush()
await db.commit()
# Regenerate wg0.conf without deleted tenant's peers
if had_vpn:
await sync_wireguard_config(db)
await db.commit()
await sync_wireguard_config()
# ---------------------------------------------------------------------------