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
|
|
@ -290,7 +290,9 @@ async fn handle_deploy_request(
|
|||
return;
|
||||
}
|
||||
};
|
||||
let swarm_queue_client::DeployRequest { agent, rev } = request;
|
||||
// The request names a config commit for controllers that predate the closure
|
||||
// record; what a deploy applies is the record, so the field is not read.
|
||||
let swarm_queue_client::DeployRequest { agent, rev: _ } = request;
|
||||
|
||||
// Which of the two meanings this request has is decided here, and the
|
||||
// predicate is "does a container exist", not "is one running":
|
||||
|
|
@ -309,22 +311,8 @@ async fn handle_deploy_request(
|
|||
}
|
||||
};
|
||||
|
||||
// Only a rebuild looks at `rev`. A first deploy ignores it: the build takes
|
||||
// whatever commit `internal/meta` pins. An archetype agent has no config
|
||||
// repo, so its rebuild ignores it too.
|
||||
let archetype = match crate::archetypes::of(&agent) {
|
||||
Ok(archetype) => archetype,
|
||||
Err(e) => {
|
||||
tracing::warn!(%agent, error = ?e, "swarm events: cannot read the stored archetypes; deploy dropped");
|
||||
return;
|
||||
}
|
||||
};
|
||||
if known
|
||||
&& archetype.is_none()
|
||||
&& let Some(rev) = rev.as_deref()
|
||||
&& rev_already_deployed(&agent, rev)
|
||||
{
|
||||
tracing::info!(%agent, %rev, "swarm events: deploy requested for the deployed rev; nothing queued");
|
||||
if known && crate::attic::closure::is_up_to_date(&agent).await {
|
||||
tracing::info!(%agent, "swarm events: deploy requested for the closure already deployed; nothing queued");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -352,21 +340,6 @@ async fn handle_deploy_request(
|
|||
}
|
||||
}
|
||||
|
||||
/// Whether `rev` is the config commit `agent`'s last successful build pinned
|
||||
/// (`paths::applied_config_marker`), so a rebuild would deploy nothing new. A
|
||||
/// request for a rev that is still building, or whose build failed, is not
|
||||
/// deployed yet and queues again: the rebuild resolves its pins from
|
||||
/// `internal/meta` either way, so a second one is redundant but harmless.
|
||||
fn rev_already_deployed(agent: &str, rev: &str) -> bool {
|
||||
marker_holds(&crate::paths::applied_config_marker(agent), rev)
|
||||
}
|
||||
|
||||
/// Whether the marker file at `marker` holds exactly `rev`; an absent or
|
||||
/// unreadable marker holds nothing.
|
||||
fn marker_holds(marker: &std::path::Path, rev: &str) -> bool {
|
||||
std::fs::read_to_string(marker).is_ok_and(|deployed| deployed.trim() == rev)
|
||||
}
|
||||
|
||||
/// Queue the first deploy of an agent this hive does not have yet: seed its
|
||||
/// power intent, then insert the DAG.
|
||||
///
|
||||
|
|
@ -429,22 +402,6 @@ async fn publish(client: &async_nats::Client, hive: &str) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod rev_marker_tests {
|
||||
use super::marker_holds;
|
||||
|
||||
#[test]
|
||||
fn a_rev_is_deployed_only_when_the_marker_holds_it() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let marker = dir.path().join(".alice.config-rev");
|
||||
|
||||
assert!(!marker_holds(&marker, "aaa"), "no marker, nothing deployed");
|
||||
std::fs::write(&marker, "aaa").expect("write marker");
|
||||
assert!(marker_holds(&marker, "aaa"));
|
||||
assert!(!marker_holds(&marker, "bbb"), "another rev still deploys");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod snapshot_tests {
|
||||
use super::snapshot;
|
||||
|
|
|
|||
Loading…
Reference in a new issue