feat(#791): add request_init_config + request_apply_commit to AgentServer (topology-scoped)
This commit is contained in:
parent
dacd83f278
commit
3fa31a414f
4 changed files with 161 additions and 30 deletions
|
|
@ -425,6 +425,60 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
coord.emit_rebuild_queue_snapshot();
|
||||
AgentResponse::Ok
|
||||
}
|
||||
AgentRequest::RequestInitConfig { name, description } => {
|
||||
if !crate::topology::children_of(agent)
|
||||
.iter()
|
||||
.any(|c| c == name)
|
||||
{
|
||||
return AgentResponse::Err {
|
||||
message: format!(
|
||||
"agent `{agent}` cannot request_init_config for `{name}`: \
|
||||
not a direct child in the topology tree"
|
||||
),
|
||||
};
|
||||
}
|
||||
tracing::info!(%agent, %name, "agent: request_init_config for child");
|
||||
match crate::manager_server::submit_init_config(coord, name, description.clone()).await {
|
||||
Ok(_id) => AgentResponse::Ok,
|
||||
Err(e) => AgentResponse::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
AgentRequest::RequestApplyCommit {
|
||||
agent: target_agent,
|
||||
commit_ref,
|
||||
description,
|
||||
} => {
|
||||
if !crate::topology::children_of(agent)
|
||||
.iter()
|
||||
.any(|c| c == target_agent)
|
||||
{
|
||||
return AgentResponse::Err {
|
||||
message: format!(
|
||||
"agent `{agent}` cannot request_apply_commit for `{target_agent}`: \
|
||||
not a direct child in the topology tree"
|
||||
),
|
||||
};
|
||||
}
|
||||
tracing::info!(%agent, %target_agent, %commit_ref, "agent: request_apply_commit for child");
|
||||
match crate::manager_server::submit_apply_commit(
|
||||
coord,
|
||||
target_agent,
|
||||
commit_ref,
|
||||
description.as_deref(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok((id, sha)) => {
|
||||
tracing::info!(%id, %target_agent, %sha, "agent: apply_commit approval queued");
|
||||
AgentResponse::Ok
|
||||
}
|
||||
Err(e) => AgentResponse::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
// Manager-only variants are not valid on the agent socket.
|
||||
_ => AgentResponse::Err {
|
||||
message: "request not supported on agent socket".to_owned(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue