Watch
0
0
Fork
You've already forked hyperhive
0

hive-c0re: keep is_running unbounded, bound only the periodic status reads

Bounding is_running turned a hung systemctl into "not running" for
callers that record or act on the answer: the broad-stop restore set
dropped the agent, start_many could rebuild-and-restart a running
agent, reconcile could seed Offline. is_running is back to the
unbounded call it was.

The periodic workers read through the bounded running_state instead:
crash_watch (unchanged), and the swarm_agent_status publisher via the
new container_view::read_agent_status_bounded, which skips the agent
for that sweep when the unit state is unreadable. The GetAgentMeta
socket handler keeps the unbounded read_agent_status_live.
This commit is contained in:
atlas 2026-10-09 16:18:58 +02:00
commit 7214b4c22f
3 changed files with 44 additions and 14 deletions

View file

@ -312,8 +312,8 @@ fn read_harness_flags(name: &hive_types::Ident) -> (bool, bool, bool) {
///
/// NB: a caller building `AgentMeta` for a *stopped* container must clear
/// the result — the on-disk status is a stale snapshot from before the
/// stop. [`read_agent_status_live`] applies that rule, and is what the
/// socket server and the swarm status reader actually call.
/// stop. [`read_agent_status_live`] and [`read_agent_status_bounded`] apply
/// that rule, for the socket server and the swarm status reader respectively.
fn read_agent_status(name: &hive_types::Ident) -> (Option<String>, Option<i64>) {
let path = Coordinator::agent_notes_dir(name).join("hyperhive-status");
let meta = std::fs::metadata(&path).ok();
@ -357,7 +357,24 @@ fn read_agent_status(name: &hive_types::Ident) -> (Option<String>, Option<i64>)
pub async fn read_agent_status_live(
name: &hive_types::Ident,
) -> (Option<String>, Option<i64>, bool) {
if !lifecycle::is_running(name.as_str()).await {
status_if_running(name, lifecycle::is_running(name.as_str()).await)
}
/// [`read_agent_status_live`] on the bounded [`lifecycle::running_state`],
/// for periodic workers; `None` when the unit state is unreadable.
pub async fn read_agent_status_bounded(
name: &hive_types::Ident,
) -> Option<(Option<String>, Option<i64>, bool)> {
lifecycle::running_state(name.as_str())
.await
.map(|running| status_if_running(name, running))
}
fn status_if_running(
name: &hive_types::Ident,
running: bool,
) -> (Option<String>, Option<i64>, bool) {
if !running {
return (None, None, false);
}
let (text, set_at) = read_agent_status(name);