Skip to content

Commit

Permalink
fix(pipelines): Don't swallow exceptions when parsing pipeline templa…
Browse files Browse the repository at this point in the history
…tes (#546)

If the pipeline planning in Orca fails because of an error in the template, the error is just logged in Echo and the execution disappears. This makes it very hard to debug failing templates. I don't know if this happens to MPT v2 as well, but it is a problem for v1 at least.
This fix will let the pipeline triggering continue even if the planning fails, so that Orca later can register the failed execution.
  • Loading branch information
jervi authored and cfieber committed May 10, 2019
1 parent 1f23754 commit 243b8a0
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import retrofit.RetrofitError;
import retrofit.RetrofitError.Kind;
import retrofit.client.Response;
import retrofit.mime.TypedByteArray;
import rx.Observable;
import rx.functions.Func1;

Expand Down Expand Up @@ -116,9 +117,21 @@ public void startPipeline(Pipeline pipeline) {
pipeline.getTrigger() != null && pipeline.getTrigger().isPropagateAuth();
log.debug("Planning templated pipeline {} before triggering", pipeline.getId());
pipeline = pipeline.withPlan(true);
Map resolvedPipelineMap =
orca.plan(objectMapper.convertValue(pipeline, Map.class), true);
pipeline = objectMapper.convertValue(resolvedPipelineMap, Pipeline.class);

try {
Map resolvedPipelineMap =
orca.plan(objectMapper.convertValue(pipeline, Map.class), true);
pipeline = objectMapper.convertValue(resolvedPipelineMap, Pipeline.class);
} catch (RetrofitError e) {
log.warn(
"Pipeline planning failed: \n{}",
new String(((TypedByteArray) e.getResponse().getBody()).getBytes()));
// Continue anyway, so that the execution will appear in Deck
pipeline = pipeline.withPlan(false);
if (pipeline.getStages() == null) {
pipeline = pipeline.withStages(Collections.emptyList());
}
}
if (propagateAuth) {
pipeline = pipeline.withTrigger(pipeline.getTrigger().atPropagateAuth(true));
}
Expand Down Expand Up @@ -162,7 +175,7 @@ private void triggerPipeline(Pipeline pipeline) throws Exception {
}
korkUser.setAllowedAccounts(getAllowedAccountsForUser(korkUser.getEmail()));
}
AuthenticatedRequest.propagate(() -> orcaResponse.subscribe(), korkUser).call();
AuthenticatedRequest.propagate(orcaResponse::subscribe, korkUser).call();
}
}

Expand Down

0 comments on commit 243b8a0

Please sign in to comment.