drop the applied repo: the hive keeps no copy of an agent's config, only the deploy markers. Refs #5913
This commit is contained in:
parent
deeb5ecd86
commit
862495530c
1 changed files with 190 additions and 1634 deletions
|
|
@ -309,9 +309,9 @@ async fn handle_deploy_request(
|
|||
}
|
||||
};
|
||||
|
||||
// Only a rebuild applies `rev`. A first deploy ignores it and builds the
|
||||
// `applied` repo it seeds from the forge's `main`, or the one it finds.
|
||||
// An archetype agent has no `applied` repo, so its rebuild ignores it too.
|
||||
// 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) => {
|
||||
|
|
@ -322,8 +322,9 @@ async fn handle_deploy_request(
|
|||
if known
|
||||
&& archetype.is_none()
|
||||
&& let Some(rev) = rev.as_deref()
|
||||
&& !apply_rev(&agent, rev).await
|
||||
&& rev_already_deployed(&agent, rev)
|
||||
{
|
||||
tracing::info!(%agent, %rev, "swarm events: deploy requested for the deployed rev; nothing queued");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -351,31 +352,14 @@ async fn handle_deploy_request(
|
|||
}
|
||||
}
|
||||
|
||||
/// Move `agent`'s `applied/main` to `rev` ahead of its rebuild, and say
|
||||
/// whether that rebuild should be queued. A `rev` already applied is taken as
|
||||
/// deployed or deploying, since every path that moves `applied/main` queues a
|
||||
/// rebuild with it. The exception is `hivectl forge reconcile-config`, which
|
||||
/// does not deploy, so a rev it put in place is skipped too.
|
||||
///
|
||||
/// The refusal's message is matched verbatim by the `hh-config-rev-refused`
|
||||
/// alert rule in `nix/host-modules/swarm-grafana.nix`; change both together.
|
||||
/// A failed rebuild surfaces where every rebuild failure does, on this hive.
|
||||
async fn apply_rev(agent: &str, rev: &str) -> bool {
|
||||
match crate::actions::advance_applied_to_rev(agent, rev).await {
|
||||
Ok(crate::actions::RevAdvance::Advanced) => true,
|
||||
Ok(crate::actions::RevAdvance::AlreadyApplied) => {
|
||||
tracing::info!(%agent, %rev, "swarm events: deploy requested for the applied rev; nothing queued");
|
||||
false
|
||||
}
|
||||
Ok(crate::actions::RevAdvance::Superseded) => {
|
||||
tracing::info!(%agent, %rev, "swarm events: deploy requested for a rev applied/main already contains; nothing queued");
|
||||
false
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!(%agent, %rev, error = %format!("{e:#}"), "swarm events: rev not applied; nothing queued");
|
||||
false
|
||||
}
|
||||
}
|
||||
/// 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 {
|
||||
std::fs::read_to_string(crate::paths::applied_config_marker(agent))
|
||||
.is_ok_and(|deployed| deployed.trim() == rev)
|
||||
}
|
||||
|
||||
/// Queue the first deploy of an agent this hive does not have yet: seed its
|
||||
|
|
|
|||
Loading…
Reference in a new issue