@ApiOperation(value = "Retrieve a pipeline execution") @RequestMapping(value = "/{executionId}", method = RequestMethod.GET) Execution getPipeline(@PathVariable String executionId) { return executionRepository.retrieve(Execution.ExecutionType.PIPELINE, executionId); }
/** * If {@code executionId} is set, it will be retrieved. Otherwise, {@code pipelineConfigId} will be used to find the * newest pipeline execution for that configuration. * @param executionId An explicit pipeline execution id. * @param pipelineConfigId A pipeline configuration id. Ignored if {@code executionId} is set. * @return The pipeline * @throws IllegalArgumentException if neither executionId or pipelineConfigId are provided * @throws ExecutionNotFoundException if no execution could be found */ public Execution retrievePipelineOrNewestExecution(@Nullable String executionId, @Nullable String pipelineConfigId) throws ExecutionNotFoundException { if (executionId != null) { // Use an explicit execution return executionRepository.retrieve(PIPELINE, executionId); } else if (pipelineConfigId != null) { // No executionId set - use last execution ExecutionRepository.ExecutionCriteria criteria = new ExecutionRepository.ExecutionCriteria().setPageSize(1); try { return executionRepository.retrievePipelinesForPipelineConfigId(pipelineConfigId, criteria) .toSingle() .toBlocking() .value(); } catch (NoSuchElementException e) { throw new ExecutionNotFoundException("No pipeline execution could be found for config id " + pipelineConfigId + ": " + e.getMessage()); } } else { throw new IllegalArgumentException("Either executionId or pipelineConfigId have to be set."); } }
public CanaryAnalysisExecutionStatusResponse getCanaryAnalysisExecution(String canaryAnalysisExecutionId) { Execution execution = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryAnalysisExecutionId); return fromExecution(execution); }
@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); }
@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); }
@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()
@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); } }
accountCredentialsRepository); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, context.getCanaryPipelineExecutionId());
log.info("Cancelling pipeline execution {}...", canaryPipelineExecutionId); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryPipelineExecutionId);
@ApiOperation(value = "Retrieve a pipeline execution") @RequestMapping(value = "/{executionId}", method = RequestMethod.GET) Execution getPipeline(@PathVariable String executionId) { return executionRepository.retrieve(Execution.ExecutionType.PIPELINE, executionId); }
public CanaryAnalysisExecutionStatusResponse getCanaryAnalysisExecution(String canaryAnalysisExecutionId) { Execution execution = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryAnalysisExecutionId); return fromExecution(execution); }
@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 Execution retrieve(ExecutionEvent event) { return repository.retrieve(event.getExecutionType(), event.getExecutionId()); } }
private Execution executionFor(ExecutionEvent event) { return repository.retrieve(event.getExecutionType(), event.getExecutionId()); } }
boolean hasCompletedExecution(PinnedServerGroupTag pinnedServerGroupTag) { try { Execution execution = executionRepository.retrieve( pinnedServerGroupTag.executionType, pinnedServerGroupTag.executionId ); return execution.getStatus().isComplete(); } catch (ExecutionNotFoundException e) { return true; } catch (Exception e) { log.warn("Unable to determine status of execution (executionId: {})", pinnedServerGroupTag.executionId, e); errorsCounter.increment(); return false; } }
@Override public CancellableStage.Result cancel(Stage stage) { String readableStageDetails = format("(stageId: %s, executionId: %s, context: %s)", stage.getId(), stage.getExecution().getId(), stage.getContext()); log.info(format("Cancelling stage %s", readableStageDetails)); try { String executionId = (String) stage.getContext().get("executionId"); if (executionId != null) { if (executionRepository == null) { log.error(format("Stage %s could not be canceled w/o front50 enabled. Please set 'front50.enabled: true' in your orca config.", readableStageDetails)); } else { Execution childPipeline = executionRepository.retrieve(PIPELINE, executionId); if (!childPipeline.isCanceled()) { // flag the child pipeline as canceled (actual cancellation will happen asynchronously) executionRepository.cancel(stage.getExecution().getType(), executionId, "parent pipeline", null); } } } } catch (Exception e) { log.error(format("Failed to cancel stage %s, e: %s", readableStageDetails, e.getMessage()), e); } return new CancellableStage.Result(stage, emptyMap()); } }
@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); } }
private Execution 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); return executionRepository.retrieve(execution.getType(), execution.getId()); }
log.info("Cancelling pipeline execution {}...", canaryPipelineExecutionId); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryPipelineExecutionId);
@Override public void onApplicationEvent(ExecutionComplete event) { if (!lockingConfigurationProperties.isEnabled()) { return; } if (event.getStatus().isHalt()) { try { MDC.put(AGENT_MDC_KEY, this.getClass().getSimpleName()); Execution execution = executionRepository.retrieve(event.getExecutionType(), event.getExecutionId()); execution.getStages().forEach(s -> { if (AcquireLockStage.PIPELINE_TYPE.equals(s.getType())) { try { LockContext lc = s.mapTo("/lock", LockContext.LockContextBuilder.class).withStage(s).build(); lockManager.releaseLock(lc.getLockName(), lc.getLockValue(), lc.getLockHolder()); } catch (LockFailureException lfe) { logger.info("Failure releasing lock in ExecutionCompleteLockReleasingListener - ignoring", lfe); } } }); } finally { MDC.remove(AGENT_MDC_KEY); } } } }