Skip to content

Commit

Permalink
fix(runjob): Only cancel runjob if one was started succfully (#3759)
Browse files Browse the repository at this point in the history
If there is no `jobStatus` object there was no job and we will NPE

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
marchello2000 and mergify[bot] committed Jun 25, 2020
1 parent 54a0ff8 commit e04508d
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,20 @@ public Result cancel(StageExecution stage) {
try {
RunJobStageContext context =
objectMapper.convertValue(stage.getContext(), RunJobStageContext.class);
destroyContext.put("jobName", context.getCloudProvider());
destroyContext.put("cloudProvider", context.getCloudProvider());
destroyContext.put("region", context.getJobStatus().getRegion());
destroyContext.put("credentials", context.getCredentials());

getCloudProviderDecorator(stage)
.ifPresent(it -> it.modifyDestroyJobContext(context, destroyContext));
if (context.getJobStatus() != null) {
destroyContext.put("jobName", context.getCloudProvider());
destroyContext.put("cloudProvider", context.getCloudProvider());
destroyContext.put("region", context.getJobStatus().getRegion());
destroyContext.put("credentials", context.getCredentials());

stage.setContext(destroyContext);
getCloudProviderDecorator(stage)
.ifPresent(it -> it.modifyDestroyJobContext(context, destroyContext));

destroyJobTask.execute(stage);
stage.setContext(destroyContext);

destroyJobTask.execute(stage);
}
} catch (Exception e) {
log.error(
String.format(
Expand Down

0 comments on commit e04508d

Please sign in to comment.