Watch
0
0
Fork
You've already forked hyperhive
0

hives report an agent being updated: its status shows updating from the update's stop until the container is back up

A hive marks an agent updating when StopForUpdate stops its running container and clears it when the tail Reconcile or Start settles it, success or failure. The flag rides in the agent status snapshot (absent when false, so older readers and documents are unchanged), the status publisher sends a change at once instead of at the next sweep, and the swarm UI card shows an updating badge.
This commit is contained in:
damocles 2026-11-11 15:41:19 +01:00 • committed by mara
commit 748ef2da08

View file

@ -89,6 +89,15 @@ pub struct AgentStatus {
/// before the container stopped — the same "stopped containers have
/// stale state" rule `read_agent_status_live` already enforces.
pub running: bool,
/// Whether the hive is updating the agent: from the moment an update stops
/// its container until the container is back up (or the update gave up and
/// the hive settled the agent's power state). The agent reads as stopped
/// across that window, and this says why. Left out of the document when
/// `false`, so a snapshot of an agent not being updated is byte for byte
/// what a hive without the field publishes, and a document without it
/// reads as `false`.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub updating: bool,
}
#[cfg(test)]
@ -136,12 +145,34 @@ mod tests {
status_text: Some("reviewing a pull request".to_owned()),
status_set_at: Some(1_725_000_000),
running: true,
updating: false,
};
let json = serde_json::to_string(&status).expect("serialises");
let decoded: AgentStatus = serde_json::from_str(&json).expect("decodes");
assert_eq!(decoded, status);
}
#[test]
fn an_updating_agent_says_so_and_a_document_without_the_field_does_not() {
let updating = AgentStatus {
running: false,
updating: true,
..AgentStatus::default()
};
let json = serde_json::to_string(&updating).expect("serialises");
assert_eq!(
json,
r#"{"status_text":null,"status_set_at":null,"running":false,"updating":true}"#
);
let decoded: AgentStatus = serde_json::from_str(&json).expect("decodes");
assert!(decoded.updating);
// A hive that predates the field publishes none.
let old: AgentStatus =
serde_json::from_str(r#"{"status_text":null,"status_set_at":null,"running":true}"#)
.expect("decodes");
assert!(!old.updating);
}
#[test]
fn a_stopped_agent_serialises_with_no_status() {
let status = AgentStatus::default();