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); }
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(); }
private void checkRunnable(Execution execution) { if (execution.getType() == PIPELINE) { pipelineValidator.ifPresent(it -> it.checkRunnable(execution)); } }
protected String executionKey(Execution execution) { return format("%s:%s", execution.getType(), execution.getId()); }
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()); }
/** * Enriches stage context if it supports strategies */ @SuppressWarnings("unchecked") public void resolveStrategyParams() { if (execution.getType() == PIPELINE) { Map<String, Object> parameters = Optional.ofNullable(execution.getTrigger()).map(Trigger::getParameters).orElse(emptyMap()); boolean strategy = false; if (parameters.get("strategy") != null) { strategy = (boolean) parameters.get("strategy"); } if (strategy) { context.put("cloudProvider", parameters.get("cloudProvider")); context.put("cluster", parameters.get("cluster")); context.put("credentials", parameters.get("credentials")); if (parameters.get("region") != null) { context.put("regions", singletonList(parameters.get("region"))); } else if (parameters.get("zone") != null) { context.put("zones", singletonList(parameters.get("zone"))); } } } }
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); }
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(); }
private RedisClientDelegate getRedisDelegate(Execution execution) { return getRedisDelegate(execution.getType(), execution.getId()); }
public Map<String, Object> buildExecutionContext(Stage stage, boolean includeStageContext) { Map<String, Object> augmentedContext = new HashMap<>(); if (includeStageContext) { augmentedContext.putAll(stage.getContext()); } if (stage.getExecution().getType() == PIPELINE) { augmentedContext.put("trigger", mapper.convertValue( stage.getExecution().getTrigger(), new TypeReference<Map<String, Object>>() {}) ); augmentedContext.put("execution", stage.getExecution()); } return augmentedContext; }
private String executionKey(Stage stage) { return format("%s:%s", stage.getExecution().getType(), stage.getExecution().getId()); }
public StageStarted( @Nonnull Object source, @Nonnull Stage stage ) { this(source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName()); }
@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()); } }
private Execution checkForCorrelatedExecution(Execution execution) { if (execution.getTrigger().getCorrelationId() == null) { return null; } Trigger trigger = execution.getTrigger(); try { Execution o = executionRepository.retrieveByCorrelationId( execution.getType(), trigger.getCorrelationId() ); log.info("Found pre-existing " + execution.getType() + " by correlation id (id: " + o.getId() + ", correlationId: " + trigger.getCorrelationId() + ")"); return o; } catch (ExecutionNotFoundException e) { // Swallow } return null; }
public StageComplete( @Nonnull Object source, @Nonnull Stage stage ) { this(source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName(), stage.getStatus()); }
private RedisClientDelegate getRedisDelegate(Stage stage) { return getRedisDelegate(stage.getExecution().getType(), stage.getExecution().getId()); }
public TaskStarted( @Nonnull Object source, @Nonnull Stage stage, @Nonnull Task task ) { this( source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName(), task.getId(), task.getImplementingClass(), task.getName() ); }
@Override public void store(@Nonnull Execution execution) { RedisClientDelegate delegate = getRedisDelegate(execution); storeExecutionInternal(delegate, execution); if (execution.getType() == PIPELINE) { delegate.withCommandsClient(c -> { c.zadd(executionsByPipelineKey(execution.getPipelineConfigId()), execution.getBuildTime() != null ? execution.getBuildTime() : currentTimeMillis(), execution.getId() ); }); } }
public TaskComplete( @Nonnull Object source, @Nonnull Stage stage, @Nonnull Task task ) { this( source, stage.getExecution().getType(), stage.getExecution().getId(), stage.getId(), stage.getType(), stage.getName(), task.getId(), task.getImplementingClass(), task.getName(), task.getStatus() ); }
@Override public void afterExecution(Persister persister, Execution execution, ExecutionStatus executionStatus, boolean wasSuccessful) { if (execution.getType() != ORCHESTRATION) { // not concerned with pipelines right now (pipelines can have wait stages / manual judgments which skew execution time) return; } if (execution.getApplication() == null || execution.getStartTime() == null || execution.getEndTime() == null) { // should normally have all attributes but a guard just in case return; } Id id = registry .createId("executions.totalTime") .withTag("executionType", "orchestration") .withTag("successful", Boolean.valueOf(wasSuccessful).toString()) .withTag("application", execution.getApplication().toLowerCase()); registry.timer(id).record(execution.getEndTime() - execution.getStartTime(), TimeUnit.MILLISECONDS); } }