fix: restart-all only lists successfully restarted agents
This commit is contained in:
parent
26f2c1f59b
commit
b9b58554e8
1 changed files with 5 additions and 2 deletions
|
|
@ -148,20 +148,23 @@ async fn dispatch(req: &HostRequest, coord: Arc<Coordinator>) -> HostResponse {
|
||||||
HostRequest::RestartAll => {
|
HostRequest::RestartAll => {
|
||||||
tracing::info!("restart-all");
|
tracing::info!("restart-all");
|
||||||
let agents = lifecycle::list().await?;
|
let agents = lifecycle::list().await?;
|
||||||
|
let mut ok_agents: Vec<String> = Vec::new();
|
||||||
let mut errors: Vec<String> = Vec::new();
|
let mut errors: Vec<String> = Vec::new();
|
||||||
for agent in &agents {
|
for agent in &agents {
|
||||||
if let Err(e) = lifecycle::restart(agent).await {
|
if let Err(e) = lifecycle::restart(agent).await {
|
||||||
tracing::warn!(%agent, error = ?e, "restart-all: failed to restart agent");
|
tracing::warn!(%agent, error = ?e, "restart-all: failed to restart agent");
|
||||||
errors.push(format!("{agent}: {e:#}"));
|
errors.push(format!("{agent}: {e:#}"));
|
||||||
|
} else {
|
||||||
|
ok_agents.push(agent.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if errors.is_empty() {
|
if errors.is_empty() {
|
||||||
HostResponse::list(agents)
|
HostResponse::list(ok_agents)
|
||||||
} else {
|
} else {
|
||||||
HostResponse {
|
HostResponse {
|
||||||
ok: false,
|
ok: false,
|
||||||
error: Some(errors.join("; ")),
|
error: Some(errors.join("; ")),
|
||||||
agents: Some(agents),
|
agents: Some(ok_agents),
|
||||||
approvals: None,
|
approvals: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue