test the run_node dispatch and the reconcile, signal, drain and purge failure paths
This commit is contained in:
parent
b1a00a3222
commit
d241e64ab1
1 changed files with 423 additions and 29 deletions
|
|
@ -259,6 +259,17 @@ pub(super) async fn run_node(
|
|||
builder: super::JobBuilder,
|
||||
id: NodeId,
|
||||
kind: &NodeKind,
|
||||
) -> (super::JobBuilder, Result<()>) {
|
||||
dispatch(&RealHost, coord, builder, id, kind).await
|
||||
}
|
||||
|
||||
/// [`run_node`] over any [`Host`].
|
||||
async fn dispatch(
|
||||
host: &impl Host,
|
||||
coord: &Arc<Coordinator>,
|
||||
builder: super::JobBuilder,
|
||||
id: NodeId,
|
||||
kind: &NodeKind,
|
||||
) -> (super::JobBuilder, Result<()>) {
|
||||
// The agent this node targets rides the payload — empty for the agentless
|
||||
// kinds (the sweeps), which never read it.
|
||||
|
|
@ -268,45 +279,43 @@ pub(super) async fn run_node(
|
|||
// inside an `.await` would make this future non-`Send` (see above), so the
|
||||
// growth executors return what to grow rather than taking the builder.
|
||||
let result = match kind {
|
||||
NodeKind::MetaSync { .. } => run_meta_sync(&RealHost, agent).await,
|
||||
NodeKind::Prebuild { .. } => run_prebuild(&RealHost, agent, id).await,
|
||||
NodeKind::Swap { .. } => run_swap(&RealHost, coord, agent, id).await,
|
||||
NodeKind::RebuildBookkeeping { .. } => {
|
||||
run_rebuild_bookkeeping(&RealHost, coord, agent).await
|
||||
}
|
||||
NodeKind::Provision { .. } => run_provision(&RealHost, agent).await,
|
||||
NodeKind::Create { .. } => run_create(&RealHost, agent).await,
|
||||
NodeKind::DestroyContainer { .. } => run_destroy_container(&RealHost, coord, agent).await,
|
||||
NodeKind::MetaSync { .. } => run_meta_sync(host, agent).await,
|
||||
NodeKind::Prebuild { .. } => run_prebuild(host, agent, id).await,
|
||||
NodeKind::Swap { .. } => run_swap(host, coord, agent, id).await,
|
||||
NodeKind::RebuildBookkeeping { .. } => run_rebuild_bookkeeping(host, coord, agent).await,
|
||||
NodeKind::Provision { .. } => run_provision(host, agent).await,
|
||||
NodeKind::Create { .. } => run_create(host, agent).await,
|
||||
NodeKind::DestroyContainer { .. } => run_destroy_container(host, coord, agent).await,
|
||||
NodeKind::PurgeState { .. } => {
|
||||
run_purge_state(&RealHost, agent).await;
|
||||
run_purge_state(host, agent).await;
|
||||
Ok(())
|
||||
}
|
||||
NodeKind::DestroyBookkeeping { .. } => {
|
||||
run_destroy_bookkeeping(&RealHost, coord, agent).await;
|
||||
run_destroy_bookkeeping(host, coord, agent).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
NodeKind::Reconcile { .. } => run_reconcile(&RealHost, coord, agent).await.map(|sub| {
|
||||
NodeKind::Reconcile { .. } => run_reconcile(host, coord, agent).await.map(|sub| {
|
||||
if let Some(kind) = sub {
|
||||
super::templates::fanned_out_mechanical(&builder, kind);
|
||||
}
|
||||
}),
|
||||
NodeKind::Start { .. } => run_start(&RealHost, coord, agent).await,
|
||||
NodeKind::Stop { .. } => run_stop(&RealHost, coord, agent).await,
|
||||
NodeKind::StopForUpdate { .. } => run_stop_for_update(&RealHost, coord, agent).await,
|
||||
NodeKind::Start { .. } => run_start(host, coord, agent).await,
|
||||
NodeKind::Stop { .. } => run_stop(host, coord, agent).await,
|
||||
NodeKind::StopForUpdate { .. } => run_stop_for_update(host, coord, agent).await,
|
||||
NodeKind::Signal { .. } => {
|
||||
run_signal(coord, agent);
|
||||
Ok(())
|
||||
}
|
||||
NodeKind::Drain { .. } => run_drain(coord, agent, GRACEFUL_STOP_TIMEOUT).await,
|
||||
NodeKind::PauseSignal { .. } => run_pause_signal(&RealHost, coord, agent).await,
|
||||
NodeKind::PauseSignal { .. } => run_pause_signal(host, coord, agent).await,
|
||||
NodeKind::PauseDrain { .. } => run_pause_drain(coord, agent, PAUSE_ACK_TIMEOUT).await,
|
||||
NodeKind::WriteDropin { .. } => run_write_dropin(&RealHost, coord, agent).await,
|
||||
NodeKind::WriteDropin { .. } => run_write_dropin(host, coord, agent).await,
|
||||
// The payload rides the node and is destructured here, so the executor
|
||||
// takes it directly instead of re-matching the kind behind a `bail!`
|
||||
// that could never fire.
|
||||
NodeKind::EmitRebuilt { ok, .. } => {
|
||||
run_emit_rebuilt(&RealHost, coord, agent, coord.job_queue.root_of(id), *ok).await;
|
||||
run_emit_rebuilt(host, coord, agent, coord.job_queue.root_of(id), *ok).await;
|
||||
Ok(())
|
||||
}
|
||||
NodeKind::SetWanted { up, .. } => run_set_wanted(coord, agent, *up),
|
||||
|
|
@ -314,12 +323,10 @@ pub(super) async fn run_node(
|
|||
// `Finishing` so the nodes under it start. What they declare stays held
|
||||
// until their whole subtree settles.
|
||||
NodeKind::AgentWindow { .. } => Ok(()),
|
||||
NodeKind::ForgeSweep => run_forge_sweep(&RealHost).await,
|
||||
NodeKind::MatrixSweep => run_matrix_sweep(&RealHost, MATRIX_SWEEP_DEADLINE).await,
|
||||
NodeKind::KnowledgePull => {
|
||||
run_knowledge_pull(&RealHost, coord, KNOWLEDGE_PULL_DEADLINE).await
|
||||
}
|
||||
NodeKind::WantedPull => run_wanted_pull(&RealHost, coord).await,
|
||||
NodeKind::ForgeSweep => run_forge_sweep(host).await,
|
||||
NodeKind::MatrixSweep => run_matrix_sweep(host, MATRIX_SWEEP_DEADLINE).await,
|
||||
NodeKind::KnowledgePull => run_knowledge_pull(host, coord, KNOWLEDGE_PULL_DEADLINE).await,
|
||||
NodeKind::WantedPull => run_wanted_pull(host, coord).await,
|
||||
};
|
||||
(builder, result)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue