Watch
0
0
Fork
You've already forked hyperhive
0

reconcile: start a stopped harness inside a running container

hive-priv gains AgentHarness { agent_name, action: probe | start }, which
runs systemctl -M h-<name> against the fixed unit hive-agent.service.
run_reconcile and the 1-min tick read the unit for a running wanted-up
agent and start it when it is inactive or failed. A hive-priv without the
op reads as unknown state and leaves reconcile container-only.
This commit is contained in:
atlas 2026-11-19 01:42:18 +01:00 • committed by mara
commit 36515c289d

View file

@ -445,3 +445,45 @@ fn stop_kind_survives_a_clean_stop_between_failures() {
guards.remove("stopkind-c");
assert!(std::ptr::eq(first, failed(&mut guards)));
}
#[test]
fn harness_state_reads_load_and_active_state() {
let probe = |load: &str, active: &str| {
parse_harness_state(&format!("LoadState={load}\nActiveState={active}\n"))
};
for active in ["inactive", "failed"] {
assert_eq!(probe("loaded", active), HarnessState::Stopped, "{active}");
}
for active in ["active", "activating", "deactivating", "reloading"] {
assert_eq!(probe("loaded", active), HarnessState::Present, "{active}");
}
// A unit that is not loaded, or output that is not a probe, is not
// evidence the harness is down.
assert_eq!(probe("not-found", "inactive"), HarnessState::Unknown);
assert_eq!(parse_harness_state(""), HarnessState::Unknown);
assert_eq!(parse_harness_state("garbage"), HarnessState::Unknown);
}
/// A hive-priv that predates the op answers an error; that reads as unknown
/// state, which leaves reconcile with its container-only behaviour.
#[test]
fn an_unreadable_harness_is_unknown_never_stopped() {
let old_priv = anyhow::anyhow!("parse request: unknown variant `agent_harness`");
assert_eq!(
harness_of_answer("alice", Err(old_priv)),
HarnessState::Unknown
);
assert_eq!(
harness_of_answer("alice", Err(anyhow::anyhow!("again"))),
HarnessState::Unknown,
"later errors read the same"
);
assert_eq!(
harness_of_answer(
"alice",
Ok("LoadState=loaded\nActiveState=inactive\n".to_owned())
),
HarnessState::Stopped,
"control: a real answer is read"
);
}