Watch
0
0
Fork
You've already forked hyperhive
0

reconcile tick: create a placed agent whose deploy event was missed

The swarm's deploy event is core NATS. The wanted-state declaration lands
before the build, so its create fails on no record, and only the event
re-drives it; a hive that missed the event had nothing to retry.

wanted.rs now remembers which agents the last declaration places with a
container. Each tick, a placed agent with no container whose record says
the builder pushed its closure gets its first deploy through
JobQueue::insert_first_deploy_if_idle, which queues nothing while any node
targets the agent. Record reads and creates back off like restarts, in a
history of their own.
This commit is contained in:
atlas 2026-11-19 11:54:39 +01:00 • committed by mara
commit ad30b7ea31

View file

@ -1541,6 +1541,39 @@ fn a_first_deploy_is_not_queued_twice_for_one_agent() {
);
}
/// The reconcile tick's create: not behind any live work on the agent, a
/// rebuild included, and a finished node does not count.
#[test]
fn a_first_deploy_if_idle_waits_for_any_live_work_on_the_agent() {
let q = JobQueue::new(1);
insert(&q, |b| {
let _ = rebuild(b, "busy");
});
assert!(
q.insert_first_deploy_if_idle("busy")
.expect("insert")
.is_none(),
"a live rebuild blocks it"
);
let first = q
.insert_first_deploy_if_idle("newbie")
.expect("insert")
.expect("control: an idle agent gets its first deploy");
assert!(
q.insert_first_deploy_if_idle("newbie")
.expect("insert")
.is_none(),
"the live first deploy blocks another"
);
assert!(q.cancel(first[0].get()), "cancel the queued first deploy");
assert!(
q.insert_first_deploy_if_idle("newbie")
.expect("insert")
.is_some(),
"a terminal node does not count as busy"
);
}
/// The auto-update pass queues no second rebuild for an agent that has one in
/// flight; another agent's rebuild does not count.
#[test]