summaryrefslogtreecommitdiffstats
path: root/src/endpoint/configured.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-02-08 10:49:08 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-02-08 10:49:12 +0100
commitc0caf996654768d736fc6a13c24942efdaeba38e (patch)
tree4b0e36022a75cfbfedcc2022e82a10e106be5c57 /src/endpoint/configured.rs
parent2d82860bbd867a328fa1ab21e77705439ba4636b (diff)
Fix: Do not try to fetch artifacts if container errored
This patch fixes an issue where we tried to fetch the artifacts from the container if the container script exited unsuccessfully. This resulted in an "cannot fetch artifacts from container" error message, which shouldn't happen, as we shouldn't even try if the script failed. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/endpoint/configured.rs')
-rw-r--r--src/endpoint/configured.rs47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index 83d51b4..822d533 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -617,28 +617,7 @@ impl<'a> ExecutedContainer<'a> {
}
pub async fn finalize(self, staging: Arc<RwLock<StagingStore>>) -> Result<FinalizedContainer> {
- trace!("Fetching /outputs from container {}", self.create_info.id);
- let container = self.endpoint.docker.containers().get(&self.create_info.id);
- let tar_stream = container
- .copy_from(&PathBuf::from("/outputs/"))
- .map(|item| {
- item.with_context(|| {
- anyhow!(
- "Copying item from container {} to host",
- self.create_info.id
- )
- })
- .map_err(Error::from)
- });
-
- let mut writelock = staging.write().await;
-
- let artifacts = writelock
- .write_files_from_tar_stream(tar_stream)
- .await
- .with_context(|| anyhow!("Copying the TAR stream to the staging store"))?;
-
- let exit_info = match self.exit_info {
+ let (exit_info, artifacts) = match self.exit_info {
Some((false, msg)) => {
let err = anyhow!("Error during container run:\n\tMessage: '{msg}'\n\tConnect using\n\n\t\t`docker --host {uri} exec -it {container_id} /bin/bash`\n\n\tto debug.",
container_id = self.create_info.id,
@@ -647,16 +626,36 @@ impl<'a> ExecutedContainer<'a> {
);
// error because the container errored
- Err(err)
+ (Err(err), vec![])
}
Some((true, _)) | None => {
let container = self.endpoint.docker.containers().get(&self.create_info.id);
+
+ trace!("Fetching /outputs from container {}", self.create_info.id);
+ let tar_stream = container
+ .copy_from(&PathBuf::from("/outputs/"))
+ .map(|item| {
+ item.with_context(|| {
+ anyhow!(
+ "Copying item from container {} to host",
+ self.create_info.id
+ )
+ })
+ .map_err(Error::from)
+ });
+
+ let mut writelock = staging.write().await;
+
+ let artifacts = writelock
+ .write_files_from_tar_stream(tar_stream)
+ .await
+ .with_context(|| anyhow!("Copying the TAR stream to the staging store"))?;
container
.stop(Some(std::time::Duration::new(1, 0)))
.await
.with_context(|| anyhow!("Stopping container {}", self.create_info.id))?;
- Ok(())
+ (Ok(()), artifacts)
}
};