Fail before storing run, to not mask errors
@@ -396,15 +396,13 @@ public class JobController {
});
logs.flush(id);
metric.jobFinished(run.id().job(), finishedRun.status());
- return finishedRun;
- });
DeploymentId deploymentId = new DeploymentId(unlockedRun.id().application(), unlockedRun.id().job().type().zone(controller.system()));
(unlockedRun.versions().targetApplication().isDeployedDirectly() ?
Stream.of(unlockedRun.id().type()) :
JobType.allIn(controller.system()).stream().filter(jobType -> !jobType.environment().isManuallyDeployed()))
.flatMap(jobType -> controller.jobController().runs(unlockedRun.id().application(), jobType).values().stream())
- .mapToLong(run -> run.versions().targetApplication().buildNumber().orElse(Integer.MAX_VALUE))
+ .mapToLong(r -> r.versions().targetApplication().buildNumber().orElse(Integer.MAX_VALUE))
.min()
.ifPresent(oldestBuild -> {
if (unlockedRun.versions().targetApplication().isDeployedDirectly())
@@ -412,6 +410,9 @@ public class JobController {
else
controller.applications().applicationStore().pruneDiffs(deploymentId.applicationId().tenant(), deploymentId.applicationId().application(), oldestBuild);
});
+
+ return finishedRun;
+ });
}
finally {
for (Lock lock : locks)
