diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-10 12:26:25 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-10 12:26:25 +0100 |
commit | 2694a181c73b6b6257b4d693db62d629968b2170 (patch) | |
tree | 5a18148b9e16572440371a66504ed9a795967f43 /src/orchestrator/orchestrator.rs | |
parent | c462504e1b0356ae8c4c48beb9c8f36c97ee56df (diff) |
Print errors in build subcommand implementation
This changes the Orchestrator interface to return a Vec of errors which
happened during the container run, rather than just reporting "something
errored".
This way, we can use the build subcommand implementation to do the
reporting instead of the Orchestrator implementation, which is way
cleaner (especially for future features).
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/orchestrator/orchestrator.rs')
-rw-r--r-- | src/orchestrator/orchestrator.rs | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/src/orchestrator/orchestrator.rs b/src/orchestrator/orchestrator.rs index 2ce3f62..21ac133 100644 --- a/src/orchestrator/orchestrator.rs +++ b/src/orchestrator/orchestrator.rs @@ -1,4 +1,3 @@ -use std::io::Write; use std::path::PathBuf; use std::sync::Arc; @@ -65,9 +64,9 @@ impl<'a> OrchestratorSetup<'a> { impl<'a> Orchestrator<'a> { - pub async fn run(self, output: &mut Vec<Artifact>) -> Result<()> { + pub async fn run(self, output: &mut Vec<Artifact>) -> Result<Vec<anyhow::Error>> { for jobset in self.jobsets.into_iter() { - let _ = Self::run_jobset(&self.scheduler, + let errs = Self::run_jobset(&self.scheduler, &self.merged_stores, &self.source_cache, &self.config, @@ -75,9 +74,13 @@ impl<'a> Orchestrator<'a> { jobset, output) .await?; + + if !errs.is_empty() { + return Ok(errs) + } } - Ok(()) + Ok(vec![]) } async fn run_jobset( @@ -88,7 +91,7 @@ impl<'a> Orchestrator<'a> { progress_generator: &ProgressBars, jobset: JobSet, output: &mut Vec<Artifact>) - -> Result<()> + -> Result<Vec<anyhow::Error>> { use tokio::stream::StreamExt; @@ -131,28 +134,9 @@ impl<'a> Orchestrator<'a> { } - let mut have_error = false; - { - trace!("Logging {} errors...", errors.len()); - let out = std::io::stderr(); - let mut lock = out.lock(); - for error in errors { - have_error = true; - if let Err(e) = error.map_err(Error::from) { - for cause in e.chain() { - writeln!(lock, "{}", cause)?; - } - } - } - } - let mut results = results; // rebind output.append(&mut results); - if have_error { - Err(anyhow!("Error during build")) - } else { - Ok(()) - } + Ok(errors.into_iter().filter_map(Result::err).collect()) } async fn run_runnable(runnable: RunnableJob, scheduler: &EndpointScheduler, bar: indicatif::ProgressBar) -> Result<Vec<Artifact>> { |