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

@ -609,8 +609,68 @@ async fn stop_for_update_failure_fails_the_node_after_seeding() {
assert_eq!(coord.power.get("alice"), Some(Wanted::Up));
}
#[tokio::test]
async fn an_update_is_marked_from_the_stop_until_the_agent_is_settled() {
let (_dir, coord) = coordinator();
// A stopped container is no update: nothing was taken down.
run_stop_for_update(&FakeHost::down(), &coord, "alice")
.await
.expect("noop");
assert!(!coord.is_updating("alice"));
// Marked by the stop, and still marked when the kill fails: the tail
// Reconcile is what ends it.
run_stop_for_update(&FakeHost::up().failing("kill"), &coord, "alice")
.await
.expect_err("kill fails");
assert!(coord.is_updating("alice"));
coord.set_updating("alice", false);
run_stop_for_update(&FakeHost::up(), &coord, "alice")
.await
.expect("stop ok");
assert!(coord.is_updating("alice"));
assert!(!coord.is_updating("bob"), "per agent");
}
#[tokio::test]
async fn a_change_of_the_updating_set_wakes_the_status_publisher_once() {
let (_dir, coord) = coordinator();
coord.set_updating("alice", true);
tokio::time::timeout(std::time::Duration::from_secs(1), coord.updating_changed())
.await
.expect("woken by the change");
// The same state again is no change, so there is nothing to wake for.
coord.set_updating("alice", true);
assert!(
tokio::time::timeout(
std::time::Duration::from_millis(50),
coord.updating_changed()
)
.await
.is_err()
);
}
// --- Reconcile --------------------------------------------------------------
#[tokio::test]
async fn reconcile_ends_the_update_unless_it_plans_the_start_that_does() {
let (_dir, coord) = coordinator();
// Wanted up and down: the start node ends the update, not this.
coord.power.set("alice", Wanted::Up);
coord.set_updating("alice", true);
run_reconcile(&FakeHost::down(), &coord, "alice")
.await
.expect("ok");
assert!(coord.is_updating("alice"));
// Wanted offline (a deliberately stopped agent's rebuild): nothing comes
// back, so the update is over.
coord.power.set("alice", Wanted::Offline);
run_reconcile(&FakeHost::down(), &coord, "alice")
.await
.expect("ok");
assert!(!coord.is_updating("alice"));
}
#[tokio::test]
async fn reconcile_fans_out_start_for_wanted_up_and_down() {
let (_dir, coord) = coordinator();
@ -934,6 +994,21 @@ async fn start_starts_then_registers_the_listener() {
assert_eq!(host.calls(), ["start alice", "register_agent alice"]);
}
#[tokio::test]
async fn a_start_ends_the_update_whether_it_works_or_not() {
let (_dir, coord) = coordinator();
coord.set_updating("alice", true);
run_start(&FakeHost::down(), &coord, "alice")
.await
.expect("ok");
assert!(!coord.is_updating("alice"));
coord.set_updating("alice", true);
run_start(&FakeHost::down().failing("start"), &coord, "alice")
.await
.expect_err("start");
assert!(!coord.is_updating("alice"));
}
#[tokio::test]
async fn a_failed_start_registers_no_listener() {
let (_dir, coord) = coordinator();