feat(#2102): skip startup rebuild for stopped/unchanged containers
This commit is contained in:
parent
e60986cb76
commit
672e77c849
4 changed files with 125 additions and 34 deletions
|
|
@ -1034,11 +1034,33 @@ async fn rebuild_for_entry(
|
|||
/// Uses the cold-start fallback (stop + kill + start retry) so the
|
||||
/// deferred start-after-rebuild keeps the same activation-error recovery
|
||||
/// it had when it ran inline on the build lane.
|
||||
///
|
||||
/// If the hyperhive flake rev has changed since the container was last built
|
||||
/// (i.e. the rev marker is stale or missing), the start is upgraded to a full
|
||||
/// rebuild so the container runs current nix derivations. This is the
|
||||
/// "deferred stopped container" path from `auto_update::run`.
|
||||
async fn run_start(
|
||||
coord: &std::sync::Arc<crate::coordinator::Coordinator>,
|
||||
entry: &QueueEntry,
|
||||
) -> anyhow::Result<()> {
|
||||
let name = &entry.agent;
|
||||
// Upgrade to rebuild+start if the rev marker is stale.
|
||||
let current_rev = crate::auto_update::current_flake_rev(&coord.hyperhive_flake);
|
||||
if let Some(ref rev) = current_rev {
|
||||
let stored = std::fs::read_to_string(crate::auto_update::rev_marker_path(name)).ok();
|
||||
if stored.as_deref() != Some(rev.as_str()) {
|
||||
tracing::info!(%name, "start: rev stale — upgrading to rebuild+start");
|
||||
return crate::auto_update::rebuild_agent(
|
||||
coord,
|
||||
name,
|
||||
rev,
|
||||
Some(entry.id),
|
||||
true,
|
||||
Some(entry.source),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
let _guard = coord.transient_guard(name, crate::coordinator::TransientKind::Starting);
|
||||
coord.set_queue_step(Some(entry.id), "nixos-container start");
|
||||
crate::lifecycle::start_with_fallback(name).await?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue