fix(#970,#973): retry gateway reload on failure; always enable HIVE_WEB_SOCKET
This commit is contained in:
parent
5cf18ad7c7
commit
b83edc40c6
5 changed files with 88 additions and 82 deletions
|
|
@ -30,12 +30,11 @@ pub const AGENT_SOCKET_DIR: &str = "/run/hive-agent";
|
|||
pub const SOCKET_FILENAME: &str = "web.sock";
|
||||
|
||||
/// Marker file the harness drops next to the socket after a
|
||||
/// successful `bind_unix`. Presence = "this agent has opted in to
|
||||
/// `hyperhive.web.useUnixSocket = true` and its harness has bound
|
||||
/// the socket"; absence = "the harness is still on TCP, don't
|
||||
/// publish the unix upstream for this agent yet". Without this gate
|
||||
/// the gateway would `proxy_pass` to a non-existent socket for every
|
||||
/// sub-agent that hasn't flipped the option yet.
|
||||
/// successful `bind_unix`. Presence = "harness has bound the socket,
|
||||
/// unix upstream is live"; absence = "harness hasn't started yet or
|
||||
/// hasn't been rebuilt under the new config — keep TCP fallback".
|
||||
/// Without this gate the gateway would `proxy_pass` to a non-existent
|
||||
/// socket for an agent that's still starting up after a rebuild.
|
||||
///
|
||||
/// Renamed from `.bound` (legacy) to match the `hyperhive-` prefix
|
||||
/// convention for all harness-written state files. `build_map`
|
||||
|
|
@ -70,8 +69,8 @@ pub fn socket_path_for(name: &str) -> PathBuf {
|
|||
/// Includes manager and sub-agents. Filters by `READY_MARKER`
|
||||
/// presence: only agents whose harness has actually bound the unix
|
||||
/// socket appear in the map. Without this, the gateway would
|
||||
/// `proxy_pass` to a non-existent socket for every sub-agent that
|
||||
/// hasn't yet flipped `hyperhive.web.useUnixSocket = true`.
|
||||
/// `proxy_pass` to a non-existent socket for agents that haven't
|
||||
/// been rebuilt yet or are mid-restart.
|
||||
///
|
||||
/// Accepts either the new `hyperhive-socket-bound` marker or the legacy
|
||||
/// `.bound` marker so existing containers keep their gateway routing
|
||||
|
|
@ -166,12 +165,17 @@ pub fn write(names: &[String]) -> Result<()> {
|
|||
}
|
||||
|
||||
/// Spawn the marker poll task. Periodically re-runs `write` so the
|
||||
/// JSON map picks up newly-bound sockets (an agent flipping
|
||||
/// `hyperhive.web.useUnixSocket = true`, rebuilding, then having its
|
||||
/// harness drop a fresh `.bound` marker) without needing an explicit
|
||||
/// hook on container start. `write` is idempotent (skips the rename
|
||||
/// when content unchanged) so the steady-state cost is one directory
|
||||
/// stat per agent per poll interval.
|
||||
/// JSON map picks up newly-bound sockets after a rebuild (harness
|
||||
/// drops a fresh `.bound` marker on start) without needing an explicit
|
||||
/// hook on container
|
||||
/// start. `write` is idempotent (skips the rename when content
|
||||
/// unchanged) so the steady-state cost is one directory stat per
|
||||
/// agent per poll interval.
|
||||
///
|
||||
/// Also calls `gateway_nginx::reload_if_pending` on every tick to
|
||||
/// retry a gateway nginx reload that may have failed on the previous
|
||||
/// tick (e.g. gateway container temporarily down). This recovers
|
||||
/// gateway routing without needing a manual gateway restart.
|
||||
///
|
||||
/// Mirrors the spawn-loop shape used by `crash_watch`,
|
||||
/// `reminder_scheduler`, etc. — the existing background-task
|
||||
|
|
@ -198,6 +202,9 @@ pub fn spawn_poll() {
|
|||
if let Err(e) = crate::gateway_nginx::write(&names) {
|
||||
tracing::debug!(error = ?e, "gateway_nginx poll write failed");
|
||||
}
|
||||
// Retry a pending nginx reload that failed on a
|
||||
// previous tick (no-op if no reload is pending).
|
||||
crate::gateway_nginx::reload_if_pending();
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::debug!(error = ?e, "agent_sockets poll: failed to list agents");
|
||||
|
|
|
|||
Loading…
Reference in a new issue