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:
parent
ca1e25b21e
commit
748ef2da08
1 changed files with 227 additions and 12 deletions
|
|
@ -841,7 +841,13 @@ async fn run_reconcile(
|
|||
) -> Result<Option<NodeKind>> {
|
||||
let running = host.is_running(name).await;
|
||||
let wanted = coord.power.get_or_seed(name, running);
|
||||
Ok(match reconcile_action(wanted, running) {
|
||||
let action = reconcile_action(wanted, running);
|
||||
// The update ends here unless this plans the start that brings the agent
|
||||
// back; `run_start` ends it then, once the container is up or has failed.
|
||||
if !matches!(action, ReconcileAction::Start) {
|
||||
coord.set_updating(name, false);
|
||||
}
|
||||
Ok(match action {
|
||||
ReconcileAction::Start => Some(NodeKind::Start {
|
||||
agent: name.to_owned(),
|
||||
}),
|
||||
|
|
@ -870,7 +876,12 @@ async fn run_start(host: &impl Host, coord: &Arc<Coordinator>, name: &str) -> Re
|
|||
let agent_dir = crate::paths::agent_runtime_dir(name);
|
||||
let hive = coord.hive_env();
|
||||
let paths = Coordinator::agent_paths(name, agent_dir)?;
|
||||
host.start(name, &hive, &paths).await?;
|
||||
// Whatever the outcome, the update this start belongs to is over: the
|
||||
// container is back up, or the node fails and the agent is as stopped as
|
||||
// it looks.
|
||||
let started = host.start(name, &hive, &paths).await;
|
||||
coord.set_updating(name, false);
|
||||
started?;
|
||||
// Bind the MCP listener immediately after starting the container.
|
||||
// The preamble created the runtime dir; the container is now coming
|
||||
// up and will connect to this socket on its first turn. Event-driven
|
||||
|
|
@ -906,6 +917,11 @@ async fn run_stop_for_update(host: &impl Host, coord: &Arc<Coordinator>, name: &
|
|||
// stopped state and would otherwise seed a running-but-unknown
|
||||
// agent as `Offline`, stranding it down after its own rebuild.
|
||||
coord.power.get_or_seed(name, true);
|
||||
// The agent is down for the update from here until the tail
|
||||
// `Reconcile` / `Start` settles it. Set before the kill so the status
|
||||
// never reads as plain stopped, and so a failed kill still gets cleared
|
||||
// by that tail.
|
||||
coord.set_updating(name, true);
|
||||
host.kill(name).await?;
|
||||
coord.rescan_containers_and_emit().await;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue