Merge pull request #191 from pkel/main

Set exit code > 0 when colmena exec fails
This commit is contained in:
Zhaofeng Li 2024-01-28 23:21:51 -07:00 committed by GitHub
commit c84ccd0a7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -110,9 +110,18 @@ pub async fn run(
}));
}
join_all(futures).await;
let results: Vec<Result<(), ColmenaError>> = join_all(futures).await;
Ok(())
let mut failed: usize = 0;
for x in results {
match x {
Err(_) => failed += 1,
Ok(_) => (),
}
}
Ok(failed)
});
let (meta, monitor, output) = tokio::join!(
@ -121,9 +130,13 @@ pub async fn run(
output.run_until_completion(),
);
meta?;
let failed = meta?;
monitor?;
output?;
Ok(())
if failed > 0 {
Err(ColmenaError::ExecError { n_hosts: failed })
} else {
Ok(())
}
}

View File

@ -75,6 +75,9 @@ pub enum ColmenaError {
#[snafu(display("Unknown error: {}", message))]
Unknown { message: String },
#[snafu(display("Exec failed on {} hosts", n_hosts))]
ExecError { n_hosts: usize },
}
impl From<std::io::Error> for ColmenaError {