c0re: emit /var/lib/hyperhive/agent-ports.json on meta sync for gateway (#15)
This commit is contained in:
parent
c43ff5d80b
commit
e197efd3a6
3 changed files with 178 additions and 0 deletions
|
|
@ -101,6 +101,20 @@ pub async fn sync_agents(
|
|||
let topology_changed = crate::topology::reconcile(&agent_names)
|
||||
.with_context(|| format!("reconcile {}", crate::topology::topology_path().display()))?;
|
||||
|
||||
// Refresh /var/lib/hyperhive/agent-ports.json so the hive-gateway
|
||||
// nginx sees the new agent set (#15 / #740). The file is the
|
||||
// single source of truth for which agents the gateway proxies to,
|
||||
// since the gateway container lives in system config and can't be
|
||||
// rebuilt from meta-flake events. Atomic write (tmp + rename) so
|
||||
// a partial write never trips the gateway's read.
|
||||
if let Err(e) = crate::agent_ports::write(&agent_names) {
|
||||
// Best-effort: a failed write doesn't block the meta-flake
|
||||
// regen + container ops that follow. The gateway falls back
|
||||
// to whatever map is currently on disk (or an empty map on
|
||||
// first boot, meaning no per-agent routing yet).
|
||||
tracing::warn!(error = ?e, "agent_ports::write failed (non-fatal)");
|
||||
}
|
||||
|
||||
if initial {
|
||||
git(&dir, &["init", "--initial-branch=main"]).await?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue