job_queue: the reconcile fan-out declares from templates
exec.rs's Reconcile arm was the one construction site declaring a resource inline in an executor rather than in templates.rs. It now calls templates::fanned_out_mechanical, which is where every other declaration lives -- construction sites state their own holdings. That also fixes a test which could not fail. The old one claimed a Reconcile and then re-declared the fan-out itself, commented "same two calls the scheduler makes, in the same order" -- a copy of production inside the test. Had exec.rs stopped declaring the lease, it would have kept passing. The replacement calls the real function and asserts the declaration, with no DAG run at all. The other half of the old test -- that a descendant re-enters its ancestor's grant instead of taking a second unit of a cap-1 lease -- is hive-jobq's, tested there by child_borrows_ancestor_grant_released_when_subtree_done and nested_borrowers_never_deadlock.
This commit is contained in:
parent
eab6bce813
commit
53cd010a12
3 changed files with 61 additions and 73 deletions
|
|
@ -13,7 +13,6 @@ use anyhow::{Context as _, Result};
|
|||
use hive_jobq::{NodeId, TerminalState};
|
||||
|
||||
use super::model::NodeKind;
|
||||
use super::resource::Resource;
|
||||
use crate::coordinator::Coordinator;
|
||||
use crate::power::{ReconcileAction, reconcile_action};
|
||||
|
||||
|
|
@ -80,13 +79,7 @@ pub(super) async fn run_node(
|
|||
}),
|
||||
NodeKind::Reconcile { .. } => run_reconcile(coord, agent).await.map(|sub| {
|
||||
if let Some(kind) = sub {
|
||||
// `Start` / `Stop` declare the lease they run under. This node
|
||||
// is their parent and holds it, so the declaration is a
|
||||
// re-entrant borrow — no second unit, no deadlock. It exists so
|
||||
// the requirement belongs to the node rather than to the fact
|
||||
// that a `Reconcile` happens to fan it out.
|
||||
let lease = Resource::Agent(kind.agent().to_owned());
|
||||
let _ = job.node(kind).needs(lease);
|
||||
super::templates::fanned_out_mechanical(&job, kind);
|
||||
}
|
||||
}),
|
||||
NodeKind::Start { .. } => run_start(coord, agent).await,
|
||||
|
|
|
|||
Loading…
Reference in a new issue