refactor(#2591): make NodeKind the queue payload — drop JobPayload, agent into variants
This commit is contained in:
parent
2294cd4516
commit
be2dfa8cd3
8 changed files with 233 additions and 177 deletions
|
|
@ -82,24 +82,24 @@ pub(super) async fn run_node(coord: &Arc<Coordinator>, claim: &Claim) -> Result<
|
|||
node_id: claim.node_id,
|
||||
};
|
||||
match &claim.kind {
|
||||
NodeKind::Prebuild { relock } => run_prebuild(coord, claim, &ctx, *relock).await,
|
||||
NodeKind::Swap => run_swap(coord, claim, &ctx).await,
|
||||
NodeKind::PostSwap => run_post_swap(coord, claim, &ctx).await,
|
||||
NodeKind::Provision => run_provision(coord, claim, &ctx).await,
|
||||
NodeKind::Create => run_create(claim, &ctx).await,
|
||||
NodeKind::Prebuild { relock, .. } => run_prebuild(coord, claim, &ctx, *relock).await,
|
||||
NodeKind::Swap { .. } => run_swap(coord, claim, &ctx).await,
|
||||
NodeKind::PostSwap { .. } => run_post_swap(coord, claim, &ctx).await,
|
||||
NodeKind::Provision { .. } => run_provision(coord, claim, &ctx).await,
|
||||
NodeKind::Create { .. } => run_create(claim, &ctx).await,
|
||||
NodeKind::MetaLock { sweep, fanout } => {
|
||||
run_meta_lock(coord, claim, &ctx, *sweep, fanout.clone()).await
|
||||
}
|
||||
NodeKind::Reconcile => run_reconcile(coord, claim).await,
|
||||
NodeKind::Start => run_start(coord, claim, &ctx).await,
|
||||
NodeKind::Stop => run_stop(coord, claim, &ctx).await,
|
||||
NodeKind::StopForUpdate => run_stop_for_update(coord, claim, &ctx).await,
|
||||
NodeKind::Signal => Ok(run_signal(coord, claim, &ctx)),
|
||||
NodeKind::Drain => run_drain(coord, claim, &ctx).await,
|
||||
NodeKind::WriteDropin => run_write_dropin(coord, claim).await,
|
||||
NodeKind::WritePermFile => run_write_perm_file(coord, claim, &ctx).await,
|
||||
NodeKind::ApprovalDeploy => run_approval_deploy(coord, claim).await,
|
||||
NodeKind::SetWanted { up } => run_set_wanted(coord, claim, *up),
|
||||
NodeKind::Reconcile { .. } => run_reconcile(coord, claim).await,
|
||||
NodeKind::Start { .. } => run_start(coord, claim, &ctx).await,
|
||||
NodeKind::Stop { .. } => run_stop(coord, claim, &ctx).await,
|
||||
NodeKind::StopForUpdate { .. } => run_stop_for_update(coord, claim, &ctx).await,
|
||||
NodeKind::Signal { .. } => Ok(run_signal(coord, claim, &ctx)),
|
||||
NodeKind::Drain { .. } => run_drain(coord, claim, &ctx).await,
|
||||
NodeKind::WriteDropin { .. } => run_write_dropin(coord, claim).await,
|
||||
NodeKind::WritePermFile { .. } => run_write_perm_file(coord, claim, &ctx).await,
|
||||
NodeKind::ApprovalDeploy { .. } => run_approval_deploy(coord, claim).await,
|
||||
NodeKind::SetWanted { up, .. } => run_set_wanted(coord, claim, *up),
|
||||
// Pure grouping container — no work; completing it lets it reach
|
||||
// `Finishing` so its child template nodes start. The DAG's terminal
|
||||
// hook fires (inline, via `run_terminal_hook`) when the container itself
|
||||
|
|
@ -398,14 +398,17 @@ async fn run_reconcile(coord: &Arc<Coordinator>, claim: &Claim) -> Result<NodeOu
|
|||
let name = &claim.agent;
|
||||
let running = crate::lifecycle::is_running(name).await;
|
||||
let wanted = coord.power.get_or_seed(name, running)?;
|
||||
// One node targeting this agent, rooted on this reconcile node. The old
|
||||
// `append_node` inherited the emitter's agent implicitly; `append_subgraph`
|
||||
// carries it on the `NodeSpec`, so stamp `claim.agent` explicitly (same
|
||||
// effect, one in-DAG-growth channel instead of two).
|
||||
let sub = |kind| vec![vec![super::templates::node(name, kind, Vec::new())]];
|
||||
// One node targeting this agent, rooted on this reconcile node. `NodeKind`
|
||||
// carries the agent it targets, so stamp `claim.agent` into the fanned-out
|
||||
// Start/Stop kind (one in-DAG-growth channel).
|
||||
let sub = |kind| vec![vec![super::templates::node(kind, Vec::new())]];
|
||||
let append_subgraph = match reconcile_action(wanted, running) {
|
||||
ReconcileAction::Start => sub(NodeKind::Start),
|
||||
ReconcileAction::Stop => sub(NodeKind::Stop),
|
||||
ReconcileAction::Start => sub(NodeKind::Start {
|
||||
agent: name.clone(),
|
||||
}),
|
||||
ReconcileAction::Stop => sub(NodeKind::Stop {
|
||||
agent: name.clone(),
|
||||
}),
|
||||
ReconcileAction::Noop => {
|
||||
tracing::debug!(%name, wanted = wanted.as_str(), running, "reconcile: noop");
|
||||
Vec::new()
|
||||
|
|
|
|||
Loading…
Reference in a new issue