remove what no longer has a reader: build-log store, dashboard sent/delivered events, graph resource dep
This commit is contained in:
parent
32f5b74ba4
commit
49266e4410
6 changed files with 204 additions and 1054 deletions
|
|
@ -61,7 +61,6 @@ pub(super) trait Host: Sync {
|
|||
hive: &HiveEnv,
|
||||
paths: &AgentPaths,
|
||||
toplevel: &str,
|
||||
node_id: u64,
|
||||
) -> Result<()>;
|
||||
/// Write or remove the agent's pause marker.
|
||||
async fn set_paused(&self, agent: &hive_types::Ident, paused: bool) -> Result<()>;
|
||||
|
|
@ -139,9 +138,8 @@ impl Host for RealHost {
|
|||
hive: &HiveEnv,
|
||||
paths: &AgentPaths,
|
||||
toplevel: &str,
|
||||
node_id: u64,
|
||||
) -> Result<()> {
|
||||
crate::lifecycle::swap_update(name, hive, paths, toplevel, Some(node_id)).await
|
||||
crate::lifecycle::swap_update(name, hive, paths, toplevel).await
|
||||
}
|
||||
|
||||
async fn set_paused(&self, agent: &hive_types::Ident, paused: bool) -> Result<()> {
|
||||
|
|
@ -270,7 +268,7 @@ async fn dispatch(
|
|||
let result = match kind {
|
||||
NodeKind::MetaSync { .. } => run_meta_sync(host, agent).await,
|
||||
NodeKind::Prebuild { .. } => run_prebuild(host, agent).await,
|
||||
NodeKind::Swap { .. } => run_swap(host, coord, agent, id).await,
|
||||
NodeKind::Swap { .. } => run_swap(host, coord, agent).await,
|
||||
NodeKind::RebuildBookkeeping { .. } => run_rebuild_bookkeeping(coord).await,
|
||||
NodeKind::Provision { .. } => run_provision(host, agent).await,
|
||||
NodeKind::Create { .. } => run_create(host, agent).await,
|
||||
|
|
@ -736,12 +734,7 @@ fn without_closure(name: &str, step: &str, why: &NoClosure) -> anyhow::Error {
|
|||
/// kick, rescan) is the next node.
|
||||
/// The recovery-start on failure is NOT here — the DAG's tail
|
||||
/// `Reconcile` runs after this node terminal ok *or* fail.
|
||||
async fn run_swap(
|
||||
host: &impl Host,
|
||||
coord: &Arc<Coordinator>,
|
||||
name: &str,
|
||||
id: NodeId,
|
||||
) -> Result<()> {
|
||||
async fn run_swap(host: &impl Host, coord: &Arc<Coordinator>, name: &str) -> Result<()> {
|
||||
// Swap runs on an already-existing (stopped) container — runtime dir
|
||||
// and listener were created earlier. Pure path accessor suffices.
|
||||
let agent_dir = crate::paths::agent_runtime_dir(name);
|
||||
|
|
@ -749,9 +742,7 @@ async fn run_swap(
|
|||
let paths = Coordinator::agent_paths(name, agent_dir)?;
|
||||
let closure = realise_pinned(host, name, "swap").await?;
|
||||
tracing::info!(%name, "swap: applying {closure}");
|
||||
let result = host
|
||||
.swap_update(name, &hive, &paths, &closure, id.get())
|
||||
.await;
|
||||
let result = host.swap_update(name, &hive, &paths, &closure).await;
|
||||
// The marker names what was applied; a failed write is not a failed swap
|
||||
// (the container runs the closure), it only means the next comparison
|
||||
// sees the declaration as new.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use std::path::PathBuf;
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use hive_jobq::NodeId;
|
||||
use hive_jobq::scheduler::Scheduler;
|
||||
|
||||
use super::{
|
||||
|
|
@ -169,9 +168,8 @@ impl Host for FakeHost {
|
|||
_hive: &HiveEnv,
|
||||
_paths: &AgentPaths,
|
||||
toplevel: &str,
|
||||
node_id: u64,
|
||||
) -> anyhow::Result<()> {
|
||||
self.record(format!("swap_update {name} {toplevel} node={node_id}"));
|
||||
self.record(format!("swap_update {name} {toplevel}"));
|
||||
if self.fails("swap_update") {
|
||||
anyhow::bail!("nixos-container update failed");
|
||||
}
|
||||
|
|
@ -288,20 +286,6 @@ fn coordinator() -> (tempfile::TempDir, Arc<Coordinator>) {
|
|||
(dir, Arc::new(coord))
|
||||
}
|
||||
|
||||
/// A real node id, taken from a one-node job in a throwaway queue.
|
||||
fn node_id() -> NodeId {
|
||||
let q = crate::job_queue::JobQueue::new(1);
|
||||
q.insert_job(|b| {
|
||||
vec![
|
||||
b.node(NodeKind::AgentWindow {
|
||||
agent: "alice".to_owned(),
|
||||
})
|
||||
.guid(),
|
||||
]
|
||||
})
|
||||
.expect("valid shape")[0]
|
||||
}
|
||||
|
||||
// --- Prebuild ---------------------------------------------------------------
|
||||
|
||||
/// What a block logged, level and text: the message and each field.
|
||||
|
|
@ -456,13 +440,12 @@ async fn a_stopped_container_looks_up_nothing() {
|
|||
async fn swap_applies_the_swarms_closure() {
|
||||
let (_dir, coord) = coordinator();
|
||||
let host = FakeHost::down();
|
||||
let id = node_id();
|
||||
run_swap(&host, &coord, "alice", id).await.expect("swap ok");
|
||||
run_swap(&host, &coord, "alice").await.expect("swap ok");
|
||||
assert_eq!(
|
||||
host.calls(),
|
||||
[
|
||||
format!("realise alice {CLOSURE}"),
|
||||
format!("swap_update alice {CLOSURE} node={}", id.get()),
|
||||
format!("swap_update alice {CLOSURE}"),
|
||||
format!("mark_deployed alice {CLOSURE}"),
|
||||
"unpin_closure alice".to_owned(),
|
||||
]
|
||||
|
|
@ -475,7 +458,7 @@ async fn swap_applies_the_swarms_closure() {
|
|||
async fn a_swap_without_a_closure_never_updates_and_logs_an_error() {
|
||||
for (case, host, why) in without_a_pinned_closure() {
|
||||
let (_dir, coord) = coordinator();
|
||||
let (result, log) = logging(run_swap(&host, &coord, "alice", node_id())).await;
|
||||
let (result, log) = logging(run_swap(&host, &coord, "alice")).await;
|
||||
result.expect_err(case);
|
||||
let errors = log.at(tracing::Level::ERROR);
|
||||
assert_eq!(errors.len(), 1, "{case}: {errors:?}");
|
||||
|
|
@ -496,8 +479,7 @@ async fn a_swap_without_a_closure_never_updates_and_logs_an_error() {
|
|||
async fn swap_marks_the_applied_closure_deployed_only_after_the_apply() {
|
||||
let (_dir, coord) = coordinator();
|
||||
let host = FakeHost::down();
|
||||
let id = node_id();
|
||||
run_swap(&host, &coord, "alice", id).await.expect("swap ok");
|
||||
run_swap(&host, &coord, "alice").await.expect("swap ok");
|
||||
assert_eq!(
|
||||
host.calls()[2],
|
||||
format!("mark_deployed alice {CLOSURE}"),
|
||||
|
|
@ -506,7 +488,7 @@ async fn swap_marks_the_applied_closure_deployed_only_after_the_apply() {
|
|||
);
|
||||
|
||||
let host = FakeHost::down().failing("swap_update");
|
||||
run_swap(&host, &coord, "alice", node_id())
|
||||
run_swap(&host, &coord, "alice")
|
||||
.await
|
||||
.expect_err("apply fails");
|
||||
assert!(
|
||||
|
|
@ -522,7 +504,7 @@ async fn swap_marks_the_applied_closure_deployed_only_after_the_apply() {
|
|||
async fn a_marker_that_cannot_be_written_does_not_fail_the_swap() {
|
||||
let (_dir, coord) = coordinator();
|
||||
let host = FakeHost::down().failing("mark_deployed");
|
||||
let (result, log) = logging(run_swap(&host, &coord, "alice", node_id())).await;
|
||||
let (result, log) = logging(run_swap(&host, &coord, "alice")).await;
|
||||
result.expect("swap ok");
|
||||
assert_eq!(log.at(tracing::Level::WARN).len(), 1);
|
||||
}
|
||||
|
|
@ -533,7 +515,7 @@ async fn a_marker_that_cannot_be_written_does_not_fail_the_swap() {
|
|||
async fn a_failed_swap_reports_the_error_and_touches_no_container() {
|
||||
let (_dir, coord) = coordinator();
|
||||
let host = FakeHost::down().failing("swap_update");
|
||||
let err = run_swap(&host, &coord, "alice", node_id())
|
||||
let err = run_swap(&host, &coord, "alice")
|
||||
.await
|
||||
.expect_err("update failure propagates");
|
||||
assert!(format!("{err:#}").contains("update failed"), "{err:#}");
|
||||
|
|
@ -882,8 +864,7 @@ async fn a_record_that_changes_mid_rebuild_does_not_change_what_swap_applies() {
|
|||
run_meta_sync(&host, "alice").await.expect("pinned");
|
||||
run_prebuild(&host, "alice").await.expect("prebuilt");
|
||||
host.builder_records(NEWER);
|
||||
let id = node_id();
|
||||
run_swap(&host, &coord, "alice", id).await.expect("swapped");
|
||||
run_swap(&host, &coord, "alice").await.expect("swapped");
|
||||
let calls = host.calls();
|
||||
assert_eq!(
|
||||
calls
|
||||
|
|
@ -894,7 +875,7 @@ async fn a_record_that_changes_mid_rebuild_does_not_change_what_swap_applies() {
|
|||
"the record is read once: {calls:?}"
|
||||
);
|
||||
assert!(
|
||||
calls.contains(&format!("swap_update alice {CLOSURE} node={}", id.get())),
|
||||
calls.contains(&format!("swap_update alice {CLOSURE}")),
|
||||
"{calls:?}"
|
||||
);
|
||||
assert!(
|
||||
|
|
|
|||
|
|
@ -93,10 +93,8 @@ pub struct RunningTransient {
|
|||
/// [`Graph`] holds every job's nodes.
|
||||
///
|
||||
/// There is deliberately **no wrapper struct and no per-node side map**. The
|
||||
/// last map held the `build_logs` row id; that link now lives on the log row
|
||||
/// itself (`build_logs.node_id`). With nothing else to guard, the mutex holds
|
||||
/// the scheduler *directly* — which is what lets `hive_jobq` drive the run loop
|
||||
/// (it takes `&Arc<Mutex<Scheduler<..>>>`, a type a host-side wrapper could not
|
||||
/// mutex holds the scheduler *directly* — which is what lets `hive_jobq` drive
|
||||
/// the run loop (it takes `&Arc<Mutex<Scheduler<..>>>`, a type a host-side wrapper could not
|
||||
/// satisfy).
|
||||
type Sched = Scheduler<NodeKind, Resource>;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
//! no second, typed view of it any more.
|
||||
//!
|
||||
//! **One level, not two.** The node is the unit of everything: scheduling,
|
||||
//! execution, build-log, cancel, and the dashboard group (a group root's
|
||||
//! execution, cancel, and the dashboard group (a group root's
|
||||
//! subtree *is* the group). A DAG used to be a second level above it, with
|
||||
//! its own store and its own id; there is no container node any more, so a
|
||||
//! job is exactly the nodes it declared. See `docs/4-implementation/scheduler/coordinator.md::Job queue`
|
||||
|
|
@ -116,18 +116,12 @@ impl hive_jobq_wire::WireNode for NodeKind {
|
|||
<&str>::from(self).to_owned()
|
||||
}
|
||||
|
||||
fn data(&self, id: hive_jobq_wire::WireId) -> serde_json::Value {
|
||||
fn data(&self, _id: hive_jobq_wire::WireId) -> serde_json::Value {
|
||||
let mut data = serde_json::Map::new();
|
||||
let agent = self.agent();
|
||||
if !agent.is_empty() {
|
||||
data.insert("agent".to_owned(), agent.into());
|
||||
}
|
||||
|
||||
// Not in the payload at all — the build log is keyed on node identity
|
||||
// in a side table, which is why `data` is handed the id.
|
||||
if let Some(log) = crate::build_logs::global().and_then(|h| h.id_for_node(id)) {
|
||||
data.insert("build_log_id".to_owned(), log.into());
|
||||
}
|
||||
if data.is_empty() {
|
||||
serde_json::Value::Null
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -32,20 +32,3 @@ pub enum Resource {
|
|||
/// `.git/index.lock` and the remote-tracking ref lock.
|
||||
KnowledgeTree,
|
||||
}
|
||||
|
||||
/// This resource's name on the generic graph wire.
|
||||
///
|
||||
/// `hive_jobq` is generic over the resource type, so a viewer that can render
|
||||
/// any graph gets a string here rather than this enum. The `agent:` prefix
|
||||
/// keeps the per-agent leases from colliding with a hypothetical global
|
||||
/// resource that happens to share an agent's name.
|
||||
impl hive_jobq_wire::WireResource for Resource {
|
||||
fn name(&self) -> String {
|
||||
match self {
|
||||
Resource::BuildSlot => "build-slot".to_owned(),
|
||||
Resource::Agent(agent) => format!("agent:{agent}"),
|
||||
|
||||
Resource::KnowledgeTree => "knowledge-tree".to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1165,11 +1165,6 @@ fn cancelled_power_op_runs_no_compensating_node() {
|
|||
}
|
||||
|
||||
// ---- history ----
|
||||
//
|
||||
// The node → build-log link is no longer queue state: the log row carries
|
||||
// `node_id` and the lookup lives in `stores::build_logs` (see
|
||||
// `node_link_survives_completion_and_newest_wins` there). Nothing in the queue
|
||||
// needs testing for it any more, which is the point of that move.
|
||||
|
||||
/// History retention is a **flat** newest-first cap over all terminal DAGs
|
||||
/// (`MAX_HISTORY_DAGS`), not a per-template bucket behind a grace window.
|
||||
|
|
|
|||
Loading…
Reference in a new issue