feat(#343): route container restart through rebuild queue

This commit is contained in:
damocles 2026-06-02 12:59:49 +02:00
commit dce2bd0686
4 changed files with 35 additions and 21 deletions

View file

@ -32,6 +32,10 @@ pub enum QueueKind {
/// after the lock bump; children run as independent queue entries
/// grouped under this parent's `id`. `agent` = `"hyperhive"`.
StartupSweep,
/// Stop + start a container without touching config. Fast op (~5-10s).
/// Queued so it serialises against in-flight rebuilds for the same
/// agent — prevents a restart racing a rebuild mid-flight.
Restart,
}
impl QueueKind {
@ -42,6 +46,7 @@ impl QueueKind {
QueueKind::Spawn => "spawn",
QueueKind::Destroy => "destroy",
QueueKind::StartupSweep => "startup_sweep",
QueueKind::Restart => "restart",
}
}
}
@ -591,6 +596,15 @@ async fn dispatch(
// `finish` clears the step label; no explicit clear needed here.
Ok(())
}
(QueueKind::Restart, _) => {
let name = &entry.agent;
let _guard = coord.transient_guard(name, crate::coordinator::TransientKind::Restarting);
coord.set_queue_step(Some(entry.id), "nixos-container restart");
crate::lifecycle::restart(name).await?;
coord.kick_agent(name, "container restarted");
coord.rescan_containers_and_emit().await;
Ok(())
}
}
}