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
|
|
@ -39,31 +39,21 @@ pub fn current_flake_rev(hyperhive_flake: &str) -> Option<String> {
|
|||
.map(|p| p.display().to_string())
|
||||
}
|
||||
|
||||
/// Returns true when the applied repo has commits that have not yet been
|
||||
/// deployed (i.e. the applied HEAD differs from the config commit the agent's
|
||||
/// last successful build pinned, `paths::applied_config_marker`). This is the
|
||||
/// semantic the dashboard `needs_update` chip conveys: "there is a config
|
||||
/// change ready to apply via rebuild."
|
||||
/// Returns true when the config commit `internal/meta` pins for the agent's
|
||||
/// next build (`meta_rev::recorded`) differs from the one its last successful
|
||||
/// build pinned (`deployed`, the `paths::applied_config_marker` content). This
|
||||
/// is the semantic the dashboard `needs_update` chip conveys: "there is a
|
||||
/// config change ready to apply via rebuild." An archetype agent pins no
|
||||
/// config commit and never has one pending.
|
||||
///
|
||||
/// Async on purpose: this runs per agent inside `container_view::build_all`,
|
||||
/// which fires on the ~10s dashboard sweep, every `AgentStatus` request, and
|
||||
/// every `rescan_containers_and_emit` after a lifecycle step. A synchronous
|
||||
/// `git` fork here blocks a tokio worker for the whole exec — under
|
||||
/// nix-build disk saturation that's long enough that concurrent sweeps
|
||||
/// starved the runtime and stalled the per-agent sockets.
|
||||
pub async fn agent_config_pending(name: &str, deployed_sha: Option<&str>) -> bool {
|
||||
let applied = crate::paths::applied_dir(name);
|
||||
let applied_head = crate::lifecycle::git_command()
|
||||
.args(["-C", &applied.to_string_lossy(), "rev-parse", "HEAD"])
|
||||
.output()
|
||||
.await
|
||||
.ok()
|
||||
.filter(|o| o.status.success())
|
||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
.map(|s| s.trim().to_owned());
|
||||
|
||||
match (applied_head.as_deref(), deployed_sha) {
|
||||
(Some(head), Some(sha)) => !head.starts_with(sha) && !sha.starts_with(head),
|
||||
/// Reads one small file and the marker the caller already holds, no `git`:
|
||||
/// this runs per agent inside `container_view::build_all`, on the ~10s
|
||||
/// dashboard sweep and every `AgentStatus` request.
|
||||
#[must_use]
|
||||
pub fn agent_config_pending(name: &str, deployed: Option<&str>) -> bool {
|
||||
let pinned = crate::meta_rev::recorded(name).and_then(|build| build.config);
|
||||
match (pinned.as_deref(), deployed) {
|
||||
(Some(pinned), Some(deployed)) => pinned != deployed.trim(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue