summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-06-16 16:26:41 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-06-16 16:26:41 +0200
commite680a38fac648516c33562aee3fefbaee1f770a4 (patch)
tree89db454b36015819f97077577c7fc410eeca70d0
parent18f18b4afba7382b99fe3b9be450b3e1c2b21932 (diff)
Add some result inspect() calls for printing trace information
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r--src/endpoint/configured.rs22
-rw-r--r--src/orchestrator/orchestrator.rs1
2 files changed, 19 insertions, 4 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index fe45b4e..de60791 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -20,6 +20,7 @@ use anyhow::anyhow;
use futures::FutureExt;
use getset::{CopyGetters, Getters};
use log::trace;
+use result_inspect::ResultInspect;
use shiplift::Container;
use shiplift::Docker;
use shiplift::ExecContainerOptions;
@@ -522,12 +523,16 @@ impl<'a> PreparedContainer<'a> {
.with_context(|| anyhow!("Reading file {}", source_path.display()))?;
drop(entry);
- let _ = container.copy_file_into(destination, &buf).await?;
- Ok(())
+ container.copy_file_into(destination, &buf)
+ .await
+ .inspect(|_| trace!("Successfully copied source {} to container {}", source_path.display(), container.id()))
+ .with_context(|| anyhow!("Failed to copy source {} to container {}", source_path.display(), container.id()))
+ .map_err(Error::from)
})
.collect::<futures::stream::FuturesUnordered<_>>()
.collect::<Result<()>>()
.await
+ .inspect(|_| trace!("Successfully copied sources to container {}", container.id()))
.with_context(|| anyhow!("Copying sources to container {}", container.id()))
.map_err(Error::from)
}
@@ -560,12 +565,18 @@ impl<'a> PreparedContainer<'a> {
.await
.with_context(|| anyhow!("Reading file {}", patch.display()))?;
- let _ = container.copy_file_into(destination, &buf).await?;
- Ok(())
+ container.copy_file_into(destination, &buf)
+ .await
+ .map_err(Error::from)
+ .inspect(|_| trace!("Copying patch {} successfull", patch.display()))
+ .with_context(|| anyhow!("Copying patch {} to container {}", patch.display(), container.id()))
+ .map_err(Error::from)
})
.collect::<futures::stream::FuturesUnordered<_>>()
.collect::<Result<()>>()
.await
+ .map_err(Error::from)
+ .inspect(|_| trace!("Copied all patches"))
.with_context(|| anyhow!("Copying patches to container {}", container.id()))
.map_err(Error::from)
}
@@ -630,6 +641,7 @@ impl<'a> PreparedContainer<'a> {
let r = container
.copy_file_into(&destination, &buf)
.await
+ .inspect(|_| trace!("Successfully copied {} to container", art.display()))
.with_context(|| {
anyhow!(
"Copying artifact {} to container {} at {}",
@@ -645,6 +657,7 @@ impl<'a> PreparedContainer<'a> {
.collect::<futures::stream::FuturesUnordered<_>>()
.collect::<Result<Vec<_>>>()
.await
+ .inspect(|_| trace!("Successfully copied all artifacts to the container {}", container.id()))
.with_context(|| anyhow!("Copying artifacts to container {}", container.id()))
.map_err(Error::from)
.map(|_| ())
@@ -658,6 +671,7 @@ impl<'a> PreparedContainer<'a> {
container
.copy_file_into(script_path, script.as_ref().as_bytes())
.await
+ .inspect(|_| trace!("Successfully copied script to container {}", container.id()))
.with_context(|| anyhow!("Copying the script into container {}", container.id()))
.map_err(Error::from)
}
diff --git a/src/orchestrator/orchestrator.rs b/src/orchestrator/orchestrator.rs
index 0044fb1..113b756 100644
--- a/src/orchestrator/orchestrator.rs
+++ b/src/orchestrator/orchestrator.rs
@@ -375,6 +375,7 @@ impl<'a> Orchestrator<'a> {
let sender = prep.3.into_inner().unwrap_or_else(|| vec![root_sender.clone()]);
JobTask::new(prep.0, prep.1, sender)
})
+ .inspect(|task| trace!("Running: {}", task.jobdef.job.uuid()))
.map(|task| task.run())
.collect::<futures::stream::FuturesUnordered<_>>();
debug!("Built {} jobs", running_jobs.len());