summaryrefslogtreecommitdiffstats
path: root/src/endpoint/configured.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-10 11:50:27 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-10 11:50:27 +0100
commit26cee7066649348546599249a1c1a103d130081b (patch)
treed264fd24da9961a4120b2f91ae3787655d0b9bdf /src/endpoint/configured.rs
parent368d43485d6c888a23afe51743dd6026363238dc (diff)
Add printing of script error message
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/endpoint/configured.rs')
-rw-r--r--src/endpoint/configured.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index a478857..d9b293d 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -291,7 +291,7 @@ impl Endpoint {
.with_context(|| anyhow!("Copying artifacts to container {}", container_id))?;
}
- let exited_successfully: Option<bool> = container
+ let exited_successfully: Option<(bool, Option<String>)> = container
.copy_file_into(script_path, job.script().as_ref().as_bytes())
.inspect(|r| { trace!("Copying script to container {} -> {:?}", container_id, r); })
.map(|r| r.with_context(|| anyhow!("Copying the script into the container {} on '{}'", container_id, self.name)))
@@ -315,8 +315,8 @@ impl Endpoint {
let mut exited_successfully = None;
{
match item {
- LogItem::State(Ok(_)) => exited_successfully = Some(true),
- LogItem::State(Err(_)) => exited_successfully = Some(false),
+ LogItem::State(Ok(_)) => exited_successfully = Some((true, None)),
+ LogItem::State(Err(ref msg)) => exited_successfully = Some((false, Some(msg.clone()))),
_ => {
// Nothing
}
@@ -338,11 +338,11 @@ impl Endpoint {
.with_context(|| anyhow!("Copying script to container, running container and getting logs: {}", container_id))?
.into_iter()
.fold(None, |accu, elem| match (accu, elem) {
- (None , b) => b,
- (Some(false) , _) => Some(false),
- (_ , Some(false)) => Some(false),
- (a , None) => a,
- (Some(true) , Some(true)) => Some(true),
+ (None , b) => b,
+ (Some((false, msg)) , _) => Some((false, msg)),
+ (_ , Some((false, msg))) => Some((false, msg)),
+ (a , None) => a,
+ (Some((true, _)) , Some((true, _))) => Some((true, None)),
});
trace!("Fetching /outputs from container {}", container_id);
@@ -364,8 +364,11 @@ impl Endpoint {
let script: Script = job.script().clone();
match exited_successfully {
- Some(false) => Err(ContainerError::container_error(ContainerHash::from(container_id), self.uri().clone())).map_err(Error::from),
- Some(true) | None => {
+ Some((false, msg)) => Err({
+ ContainerError::container_error(ContainerHash::from(container_id), self.uri().clone(), msg.unwrap_or_else(|| String::new()))
+ }).map_err(Error::from),
+
+ Some((true, _)) | None => {
container.stop(Some(std::time::Duration::new(1, 0)))
.await
.with_context(|| anyhow!("Stopping container {}", container_id))?;