deploy the closure the swarm declares, read no forge head, drop the update badge
This commit is contained in:
parent
279428a66f
commit
47c2acb640
1 changed files with 647 additions and 2001 deletions
|
|
@ -76,8 +76,8 @@ fn stop_chain(
|
|||
wanted.guid()
|
||||
}
|
||||
|
||||
/// One agent's **start** subgraph. `SetWanted(Up)` head; a down + stale-rev
|
||||
/// agent gets the rebuild subgraph (its tail `Reconcile` starts it on
|
||||
/// One agent's **start** subgraph. `SetWanted(Up)` head; a down agent whose
|
||||
/// declared closure is not applied gets the rebuild subgraph (its tail `Reconcile` starts it on
|
||||
/// current derivations), otherwise a plain `Reconcile` (which starts a down
|
||||
/// agent and noops an already-running one).
|
||||
///
|
||||
|
|
@ -277,8 +277,8 @@ pub async fn restart_many(
|
|||
}
|
||||
|
||||
/// Start `agents` in a **single** DAG. A down agent gets
|
||||
/// `SetWanted(Up) → Reconcile` (or, rev stale, a rebuild-then-start so it comes
|
||||
/// up on current derivations); an already-running agent gets the same shape
|
||||
/// `SetWanted(Up) → Reconcile` (or, when the swarm declares a closure it has not applied, a
|
||||
/// rebuild-then-start so it comes up on the declared one); an already-running agent gets the same shape
|
||||
/// with the reconcile noop'ing.
|
||||
///
|
||||
/// # Errors
|
||||
|
|
@ -287,14 +287,12 @@ pub async fn start_many(
|
|||
coord: &Arc<Coordinator>,
|
||||
agents: &[String],
|
||||
) -> anyhow::Result<Vec<NodeId>> {
|
||||
let current = crate::meta_rev::current_hyperhive_pin().await;
|
||||
let mut targets = Vec::with_capacity(agents.len());
|
||||
for agent in agents {
|
||||
let running = lifecycle::is_running(agent).await;
|
||||
let stored = read_rev_marker(&crate::paths::applied_rev_marker(agent));
|
||||
let stale = !crate::meta_rev::marker_is_fresh(current.as_deref(), stored.as_deref());
|
||||
let stale = crate::attic::closure::pending_path(agent).await.is_some();
|
||||
if !running && stale {
|
||||
tracing::info!(%agent, "start: rev stale + agent down — rebuild-then-start");
|
||||
tracing::info!(%agent, "start: closure declared + agent down — rebuild-then-start");
|
||||
}
|
||||
targets.push((agent.clone(), running, stale));
|
||||
}
|
||||
|
|
@ -303,20 +301,6 @@ pub async fn start_many(
|
|||
Ok(ids)
|
||||
}
|
||||
|
||||
/// The rev `marker` records, or `None` when there is none. A missing file is
|
||||
/// the normal never-applied case; any other read error is logged, and the
|
||||
/// caller still treats the rev as stale.
|
||||
fn read_rev_marker(marker: &std::path::Path) -> Option<String> {
|
||||
match std::fs::read_to_string(marker) {
|
||||
Ok(rev) => Some(rev),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => None,
|
||||
Err(e) => {
|
||||
tracing::warn!(path = %marker.display(), error = %e, "start: applied-rev marker unreadable; treating rev as stale");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop `agents` in a **single** DAG. A running agent gets
|
||||
/// `SetWanted(Off) → [Signal → Drain →](graceful) Reconcile`; a down agent
|
||||
/// skips the pointless quiesce but keeps the `Reconcile` as the race-up
|
||||
|
|
@ -366,19 +350,3 @@ pub fn pause_many(coord: &Arc<Coordinator>, agents: &[String]) -> anyhow::Result
|
|||
coord.emit_rebuild_queue_snapshot();
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::read_rev_marker;
|
||||
|
||||
#[test]
|
||||
fn a_rev_marker_reads_as_its_contents_and_none_when_absent_or_unreadable() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let marker = dir.path().join("rev");
|
||||
assert_eq!(read_rev_marker(&marker), None);
|
||||
std::fs::write(&marker, "abc").unwrap();
|
||||
assert_eq!(read_rev_marker(&marker).as_deref(), Some("abc"));
|
||||
// A directory where the file belongs fails with a non-NotFound error.
|
||||
assert_eq!(read_rev_marker(dir.path()), None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue