@ApiOperation(value = "Retrieve a pipeline execution") @RequestMapping(value = "/{executionId}", method = RequestMethod.GET) Execution getPipeline(@PathVariable String executionId) { return executionRepository.retrieve(Execution.ExecutionType.PIPELINE, executionId); }
@ApiOperation(value = "Cancel a pipeline execution") @RequestMapping(value = "/{executionId}/cancel", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.ACCEPTED) void cancel(@PathVariable String executionId) { log.info("Cancelling pipeline execution {}...", executionId); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, executionId); if (pipeline.getStatus().isComplete()) { log.debug("Not changing status of pipeline execution {} to CANCELED since execution is already completed: {}", executionId, pipeline.getStatus()); return; } executionRepository.cancel(Execution.ExecutionType.PIPELINE, executionId); executionRepository.updateStatus(Execution.ExecutionType.PIPELINE, executionId, ExecutionStatus.CANCELED); }
private void handleStartupFailure(Execution execution, Throwable failure) { final String canceledBy = "system"; final String reason = "Failed on startup: " + failure.getMessage(); final ExecutionStatus status = ExecutionStatus.TERMINAL; log.error("Failed to start {} {}", execution.getType(), execution.getId(), failure); executionRepository.updateStatus(execution.getType(), execution.getId(), status); executionRepository.cancel(execution.getType(), execution.getId(), canceledBy, reason); }
.filter(s -> !StringUtils.isEmpty(s)) .collect(Collectors.toList()); ExecutionRepository.ExecutionCriteria executionCriteria = new ExecutionRepository.ExecutionCriteria() .setLimit(limit) .setStatuses(statusesList); List<Execution> executions = executionRepository.retrievePipelinesForPipelineConfigId(canaryPipelineConfigId, executionCriteria).toList().toBlocking().single();
@Override public void updateStatus(ExecutionType type, String executionId, ExecutionStatus executionStatus) { executionRepository.updateStatus(type, executionId, executionStatus); } }
.build(); executionRepository.store(pipeline);
@Override public void save(Stage stage) { executionRepository.storeStage(stage); }
@Override public boolean isCanceled(ExecutionType type, String executionId) { return executionRepository.isCanceled(type, executionId); }
log.info("Cancelling pipeline execution {}...", canaryPipelineExecutionId); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryPipelineExecutionId); executionRepository.cancel(Execution.ExecutionType.PIPELINE, canaryPipelineExecutionId); executionRepository.updateStatus(Execution.ExecutionType.PIPELINE, canaryPipelineExecutionId, ExecutionStatus.CANCELED); } catch (Exception e) { log.error("Failed to cancel stage (stageId: {}, executionId: {}), e: {}",
public CanaryAnalysisExecutionStatusResponse getCanaryAnalysisExecution(String canaryAnalysisExecutionId) { Execution execution = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryAnalysisExecutionId); return fromExecution(execution); }
private void handleStartupFailure(Execution execution, Throwable failure) { final String canceledBy = "system"; final String reason = "Failed on startup: " + failure.getMessage(); final ExecutionStatus status = ExecutionStatus.TERMINAL; log.error("Failed to start {} {}", execution.getType(), execution.getId(), failure); executionRepository.updateStatus(execution.getType(), execution.getId(), status); executionRepository.cancel(execution.getType(), execution.getId(), canceledBy, reason); registry.counter(failureId).increment(); }
/** * Initiates the canary analysis execution Orca pipeline. * * @param canaryAnalysisConfig The configuration for the canary analysis execution. * @return Wrapper object around the execution id. */ public CanaryAnalysisExecutionResponse initiateCanaryAnalysisExecution(CanaryAnalysisConfig canaryAnalysisConfig) { String application = canaryAnalysisConfig.getApplication(); PipelineBuilder pipelineBuilder = new PipelineBuilder(application) .withName(CANARY_ANALYSIS_PIPELINE_NAME) .withPipelineConfigId(application + "-canary-analysis-referee-pipeline") .withStage( SetupAndExecuteCanariesStage.STAGE_TYPE, SetupAndExecuteCanariesStage.STAGE_DESCRIPTION, Maps.newHashMap(ImmutableMap.of( CANARY_ANALYSIS_CONFIG_CONTEXT_KEY, canaryAnalysisConfig ))); Execution pipeline = pipelineBuilder.withLimitConcurrent(false).build(); executionRepository.store(pipeline); try { executionLauncher.start(pipeline); } catch (Throwable t) { log.error("Failed to start pipeline", t); handleStartupFailure(pipeline, t); throw new RuntimeException("Failed to start the canary analysis pipeline execution"); } return CanaryAnalysisExecutionResponse.builder().canaryAnalysisExecutionId(pipeline.getId()).build(); }
@ApiOperation(value = "Retrieve status and results for a canary run") @RequestMapping(value = "/{canaryExecutionId:.+}", method = RequestMethod.GET) public CanaryExecutionStatusResponse getCanaryResults(@RequestParam(required = false) final String storageAccountName, @PathVariable String canaryExecutionId) { String resolvedStorageAccountName = CredentialsHelper.resolveAccountByNameOrType(storageAccountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryExecutionId); return executionMapper.fromExecution(resolvedStorageAccountName, pipeline); }
.build(); executionRepository.store(pipeline);
@Override public void onApplicationEvent(ExecutionComplete event) { if (event.getExecutionType() != Execution.ExecutionType.PIPELINE) { return; } Execution execution = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, event.getExecutionId()); if (shouldProcessExecution(execution)) { processCompletedPipelineExecution(execution); } }
@ApiOperation(value = "Retrieve the results of a judge comparison") @RequestMapping(value = "/comparison/{executionId:.+}", method = RequestMethod.GET) public Map getJudgeComparisonResults(@PathVariable String executionId) { Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, executionId); String canaryExecutionId = pipeline.getId(); Stage compareJudgeResultsStage = pipeline.getStages().stream()
accountCredentialsRepository); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, context.getCanaryPipelineExecutionId());
public CanaryAnalysisExecutionStatusResponse getCanaryAnalysisExecution(String canaryAnalysisExecutionId) { Execution execution = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryAnalysisExecutionId); return fromExecution(execution); }
private Execution executionFor(ExecutionEvent event) { return repository.retrieve(event.getExecutionType(), event.getExecutionId()); } }
private Execution retrieve(ExecutionEvent event) { return repository.retrieve(event.getExecutionType(), event.getExecutionId()); } }