summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/endpoint/scheduler.rs16
-rw-r--r--src/orchestrator/orchestrator.rs5
2 files changed, 14 insertions, 7 deletions
diff --git a/src/endpoint/scheduler.rs b/src/endpoint/scheduler.rs
index ce05e96..ecef98b 100644
--- a/src/endpoint/scheduler.rs
+++ b/src/endpoint/scheduler.rs
@@ -147,7 +147,7 @@ impl std::fmt::Debug for JobHandle {
}
impl JobHandle {
- pub async fn run(self) -> Result<Vec<ArtifactPath>> {
+ pub async fn run(self) -> Result<Result<Vec<ArtifactPath>>> {
let (log_sender, log_receiver) = tokio::sync::mpsc::unbounded_channel::<LogItem>();
let ep = self.endpoint.read().await;
let endpoint = dbmodels::Endpoint::create_or_fetch(&self.db, ep.name())?;
@@ -230,7 +230,7 @@ impl JobHandle {
trace!("Found result for job {}: {:?}", job_id, res);
let (paths, res) = res.unpack();
- let _ = res
+ let res = res
.with_context(|| anyhow!("Error during running job on '{}'", ep.name()))
.with_context(|| {
Self::create_job_run_error(
@@ -240,7 +240,15 @@ impl JobHandle {
ep.uri(),
&container_id,
)
- })?;
+ })
+ .map_err(Error::from);
+
+ if res.is_err() {
+ trace!("Error was returned from script");
+ return Ok({
+ res.map(|_| vec![]) // to have the proper type, will never be executed
+ })
+ }
// Have to do it the ugly way here because of borrowing semantics
let mut r = vec![];
@@ -257,7 +265,7 @@ impl JobHandle {
.clone()
});
}
- Ok(r)
+ Ok(Ok(r))
}
/// Helper to create an error object with a nice message.
diff --git a/src/orchestrator/orchestrator.rs b/src/orchestrator/orchestrator.rs
index 2860748..a9b1e19 100644
--- a/src/orchestrator/orchestrator.rs
+++ b/src/orchestrator/orchestrator.rs
@@ -595,9 +595,7 @@ impl<'a> JobTask<'a> {
let job_uuid = *self.jobdef.job.uuid();
// Schedule the job on the scheduler
- match self.scheduler.schedule_job(runnable, self.bar.clone()).await?.run().await {
- // if the scheduler run reports an error,
- // that is an error from the actual execution of the job ...
+ match self.scheduler.schedule_job(runnable, self.bar.clone()).await?.run().await? {
Err(e) => {
trace!("[{}]: Scheduler returned error = {:?}", self.jobdef.job.uuid(), e);
// ... and we send that to our parent
@@ -607,6 +605,7 @@ impl<'a> JobTask<'a> {
let mut errormap = HashMap::with_capacity(1);
errormap.insert(job_uuid, e);
self.sender[0].send(Err(errormap)).await?;
+ return Ok(())
},
// if the scheduler run reports success,