Skip to content

Commit

Permalink
Merge pull request #191 from pkel/main
Browse files Browse the repository at this point in the history
Set exit code > 0 when colmena exec fails
  • Loading branch information
zhaofengli committed Jan 29, 2024
2 parents 6656039 + bf69042 commit c84ccd0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/command/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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(())
}
}
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c84ccd0

Please sign in to comment.