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
|
|
@ -101,6 +101,17 @@ pub struct Coordinator {
|
|||
/// orchestrations that can be in flight for different agents
|
||||
/// simultaneously.
|
||||
pause_pending: Mutex<HashSet<String>>,
|
||||
/// Agents an update has taken down and not yet brought back: set when
|
||||
/// `StopForUpdate` stops a running container, cleared when the tail
|
||||
/// `Reconcile` / `Start` settles the agent. Published in the agent's
|
||||
/// status snapshot so the swarm reads the gap as an update and not as a
|
||||
/// stopped or lost agent. In memory only: a hive restart mid-update loses
|
||||
/// the flag, and the status sweep then reads the agent as stopped until it
|
||||
/// is back, as it did before the flag existed.
|
||||
updating: Mutex<HashSet<String>>,
|
||||
/// Woken when [`Self::set_updating`] changes the set, so the status
|
||||
/// publisher sends the change at once instead of at its next sweep.
|
||||
updating_changed: tokio::sync::Notify,
|
||||
/// Unified wire-facing event channel feeding the dashboard SSE
|
||||
/// stream. Carries broker messages (mirrored from `broker.subscribe`
|
||||
/// by the forwarder task in `main.rs`) and dashboard-only mutation
|
||||
|
|
@ -365,6 +376,8 @@ impl Coordinator {
|
|||
recent_transient: Mutex::new(HashMap::new()),
|
||||
graceful_stop_pending: Mutex::new(HashSet::new()),
|
||||
pause_pending: Mutex::new(HashSet::new()),
|
||||
updating: Mutex::new(HashSet::new()),
|
||||
updating_changed: tokio::sync::Notify::new(),
|
||||
dashboard_events,
|
||||
event_seq: AtomicU64::new(0),
|
||||
|
||||
|
|
@ -618,6 +631,34 @@ impl Coordinator {
|
|||
});
|
||||
}
|
||||
|
||||
/// Mark `name` as being updated (`true`) or settled (`false`), and wake the
|
||||
/// status publisher when that changed something.
|
||||
pub fn set_updating(&self, name: &str, updating: bool) {
|
||||
let changed = {
|
||||
let mut set = self.updating.lock().unwrap();
|
||||
if updating {
|
||||
set.insert(name.to_owned())
|
||||
} else {
|
||||
set.remove(name)
|
||||
}
|
||||
};
|
||||
if changed {
|
||||
self.updating_changed.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether an update has `name` down and not yet back up.
|
||||
#[must_use]
|
||||
pub fn is_updating(&self, name: &str) -> bool {
|
||||
self.updating.lock().unwrap().contains(name)
|
||||
}
|
||||
|
||||
/// Resolves when the set of updating agents changed since it was last
|
||||
/// awaited, for the status publisher.
|
||||
pub async fn updating_changed(&self) {
|
||||
self.updating_changed.notified().await;
|
||||
}
|
||||
|
||||
/// Mark `name` as having a graceful stop in progress. While set,
|
||||
/// `socket_server::handle_recv` returns `Response::GracefulStop` for
|
||||
/// this agent instead of polling the broker (the inbound fence).
|
||||
|
|
|
|||
Loading…
Reference in a new issue