Skip to content

Commit

Permalink
fix(front50): Handle failures in pipeline config history lookup (spin…
Browse files Browse the repository at this point in the history
  • Loading branch information
ajordens authored Jun 20, 2019
1 parent 39c4dbe commit 6675281
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import retrofit.RetrofitError;

@Component
public class EnabledPipelineValidator implements PipelineValidator {
Expand Down Expand Up @@ -56,15 +57,22 @@ public void checkRunnable(Execution pipeline) {
front50Service.getPipelineHistory(pipeline.getPipelineConfigId(), 1);

if (!pipelineConfigHistory.isEmpty()) {
Map<String, Object> pipelineConfig = pipelineConfigHistory.get(0);
if ((boolean) pipelineConfig.getOrDefault("disabled", false)) {
throw new PipelineIsDisabled(
pipelineConfig.get("id").toString(),
pipelineConfig.get("application").toString(),
pipelineConfig.get("name").toString());
}
try {
Map<String, Object> pipelineConfig = pipelineConfigHistory.get(0);
if ((boolean) pipelineConfig.getOrDefault("disabled", false)) {
throw new PipelineIsDisabled(
pipelineConfig.get("id").toString(),
pipelineConfig.get("application").toString(),
pipelineConfig.get("name").toString());
}

return;
return;
} catch (RetrofitError ignored) {
// treat a failure to fetch pipeline config history as non-fatal and fallback to the
// previous behavior
// (handles the fast property case where the supplied pipeline config id does _not_
// actually exist)
}
}
}

Expand Down

0 comments on commit 6675281

Please sign in to comment.