feat(#1591): surface pending-login + crashing-agent banner warnings

This commit is contained in:
damocles 2026-06-10 01:03:27 +02:00 committed by mara
commit 2157c3ae01
4 changed files with 188 additions and 1 deletions

View file

@ -463,6 +463,13 @@ where
}
}
/// Window over which container crashes count toward the `agents_crashing`
/// banner warning. Wide enough that a crash-looping container (restarted
/// by `Restart=on-failure` every few seconds) keeps the warning lit
/// between flaps, short enough that a single recovered crash clears within
/// minutes.
const CRASH_WARNING_WINDOW: std::time::Duration = std::time::Duration::from_mins(10);
async fn api_state(headers: HeaderMap, State(state): State<AppState>) -> axum::Json<StateSnapshot> {
let host = headers
.get("host")
@ -523,6 +530,18 @@ async fn api_state(headers: HeaderMap, State(state): State<AppState>) -> axum::J
.map(QuestionView::from_question)
.collect();
// Banner warnings: host probes (disk) + agent-state (pending logins,
// crashing agents). Built before the response struct because the
// agent-state producer borrows `containers`, which moves in below.
let server_warnings = {
let mut w = crate::host_stats::server_warnings();
w.extend(crate::host_stats::agent_state_warnings(
&containers,
&state.coord.recent_crash_counts(CRASH_WARNING_WINDOW),
));
w
};
axum::Json(StateSnapshot {
seq,
hostname,
@ -564,7 +583,7 @@ async fn api_state(headers: HeaderMap, State(state): State<AppState>) -> axum::J
.ok()
.filter(|s| !s.is_empty()),
peer_hives: parse_peer_hives(),
server_warnings: crate::host_stats::server_warnings(),
server_warnings,
})
}