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

@ -191,9 +191,9 @@ pub fn spawn(
/// daemon pulls at startup regardless, and the webhook it replaced was lost
/// identically when a hive was down.
///
/// The deploy event's second path is [`crate::workers::wanted`], which reads
/// the whole declared set at boot and creates the agents this hive lacks — so
/// a missed **first** deploy repairs itself. A missed **rebuild** does not:
/// A missed **first** deploy repairs itself: [`crate::workers::wanted`] creates
/// a declared agent this hive lacks at boot, [`crate::workers::reconcile_tick`]
/// once its build is pushed. A missed **rebuild** does not:
/// the declaration names agents, not revisions, so that falls to the boot
/// reconcile noticing drift. Still not `JetStream`: durability on one subject
/// looks like a fix while the desired state lives only in a message.
@ -373,6 +373,18 @@ pub(crate) fn queue_first_deploy(
coord.job_queue.insert_first_deploy_once(agent)
}
/// [`queue_first_deploy`] for the reconcile tick, which acts on what it saw
/// before this call: `Ok(None)` when any queued or running node targets the
/// agent, not only a first deploy.
pub(crate) fn queue_first_deploy_if_idle(
power: &crate::power::PowerStore,
queue: &crate::job_queue::JobQueue,
agent: &str,
) -> Result<Option<Vec<hive_jobq::NodeId>>> {
power.set(agent, crate::power::Wanted::Up);
queue.insert_first_deploy_if_idle(agent)
}
/// The snapshot a hive offers: its readiness, and what it can do (`swarm_wire::hive_status`).
#[derive(serde::Serialize)]
struct Snapshot {