use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class NotificationAspect method notifyRunStatusChanged.
/**
* Generates system notifications for PipelineRun status changes
* @param joinPoint
* @param run
*/
@AfterReturning(pointcut = "execution(* com.epam.pipeline.manager.pipeline.PipelineRunManager.runPipeline(..)) || " + "execution(* com.epam.pipeline.manager.pipeline.PipelineRunManager.runCmd(..)) ||" + "execution(* com.epam.pipeline.manager.pipeline.PipelineRunManager.updatePipelineStatus(" + "com.epam.pipeline.entity.pipeline.PipelineRun)) || " + "execution(* com.epam.pipeline.manager.pipeline.PipelineRunManager.updatePipelineStatusIfNotFinal(..)) ||" + "execution(* com.epam.pipeline.manager.pipeline.PipelineRunManager" + ".updatePipelineStatusIfNotFinalExternal(..)))", returning = "run")
@Async("notificationsExecutor")
public void notifyRunStatusChanged(JoinPoint joinPoint, PipelineRun run) {
runStatusManager.saveStatus(RunStatus.builder().runId(run.getId()).status(run.getStatus()).timestamp(DateUtils.nowUTC()).build());
if (run.isTerminating()) {
LOGGER.debug("Won't send a notification [{} {}: {}] (filtered by status type)", run.getPipelineName(), run.getVersion(), run.getStatus());
return;
}
if (run.getPipelineName() == null) {
if (run.getPipelineId() != null) {
Pipeline pipeline = pipelineManager.load(run.getPipelineId());
run.setPipelineName(pipeline.getName());
} else {
run.setPipelineName("pipeline");
}
}
LOGGER.debug("Notify all about pipelineRun status changed {} {} {}: {}", run.getPodId(), run.getPipelineName(), run.getVersion(), run.getStatus());
notificationManager.notifyRunStatusChanged(run);
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineRunManager method runPipeline.
/**
* Runs specified pipeline version, uses Pipeline as ACL identity
*
* @param runVO
* @return
*/
@ToolSecurityPolicyCheck
public PipelineRun runPipeline(PipelineStart runVO) {
Long pipelineId = runVO.getPipelineId();
String version = runVO.getVersion();
int maxRunsNumber = preferenceManager.getPreference(SystemPreferences.LAUNCH_MAX_SCHEDULED_NUMBER);
LOGGER.debug("Allowed runs count - {}, actual - {}", maxRunsNumber, getNodeCount(runVO.getNodeCount(), 1));
Assert.isTrue(getNodeCount(runVO.getNodeCount(), 1) < maxRunsNumber, messageHelper.getMessage(MessageConstants.ERROR_EXCEED_MAX_RUNS_COUNT, maxRunsNumber, getNodeCount(runVO.getNodeCount(), 1)));
Pipeline pipeline = pipelineManager.load(pipelineId);
PipelineConfiguration configuration = configurationManager.getPipelineConfiguration(runVO);
boolean isClusterRun = configurationManager.initClusterConfiguration(configuration, true);
// check that tool execution is allowed
toolApiService.loadToolForExecution(configuration.getDockerImage());
PipelineRun run = launchPipeline(configuration, pipeline, version, runVO.getInstanceType(), runVO.getParentNodeId(), runVO.getConfigurationName(), null, runVO.getParentRunId(), null, null, runVO.getRunSids());
run.setParent(pipeline);
if (isClusterRun) {
runClusterWorkers(run, runVO, version, pipeline, configuration);
}
return run;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineRunManager method createRestartRun.
private PipelineRun createRestartRun(final PipelineRun run) {
PipelineRun restartedRun = new PipelineRun();
Long runId = pipelineRunDao.createRunId();
restartedRun.setId(runId);
restartedRun.setStartDate(DateUtils.now());
Optional<Pipeline> pipeline = Optional.ofNullable(run.getPipelineId()).map(pipelineId -> pipelineManager.load(pipelineId));
pipeline.ifPresent(p -> {
restartedRun.setPipelineName(p.getName());
restartedRun.setRepository(p.getRepository());
restartedRun.setPipelineId(p.getId());
restartedRun.setVersion(run.getVersion());
restartedRun.setRevisionName(gitManager.getRevisionName(run.getVersion()));
});
if (!pipeline.isPresent()) {
fillMissingPipelineFields(restartedRun);
}
restartedRun.setStatus(TaskStatus.RUNNING);
restartedRun.setCommitStatus(CommitStatus.NOT_COMMITTED);
restartedRun.setLastChangeCommitTime(DateUtils.now());
restartedRun.setPodId(getRootPodIDFromPipeline(restartedRun));
restartedRun.setParams(run.getParams());
restartedRun.parseParameters();
restartedRun.setTimeout(run.getTimeout());
restartedRun.setDockerImage(run.getDockerImage());
restartedRun.setCmdTemplate(run.getCmdTemplate());
restartedRun.setNodeCount(run.getNodeCount());
RunInstance instance = copyInstance(run.getInstance());
restartedRun.setInstance(instance);
setRunPrice(instance, restartedRun);
restartedRun.setSshPassword(PasswordGenerator.generatePassword());
restartedRun.setOwner(run.getOwner());
restartedRun.setEntitiesIds(run.getEntitiesIds());
restartedRun.setConfigurationId(run.getConfigurationId());
restartedRun.setExecutionPreferences(run.getExecutionPreferences());
restartedRun.setRunSids(run.getRunSids());
return restartedRun;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineDocumentTemplateManager method loadPipelineDocumentTemplateWithCurrentVersion.
public PipelineDocumentTemplate loadPipelineDocumentTemplateWithCurrentVersion(Long pipelineId) {
Pipeline pipeline = pipelineManager.load(pipelineId, true);
PipelineDocumentTemplate template = new PipelineDocumentTemplate(pipeline, pipeline.getCurrentVersion());
this.fillTemplate(template);
return template;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineDocumentTemplateManager method loadPipelineDocumentTemplateWithSpecificVersion.
public PipelineDocumentTemplate loadPipelineDocumentTemplateWithSpecificVersion(Long pipelineId, String version) throws GitClientException {
Pipeline pipeline = pipelineManager.load(pipelineId);
List<Revision> revisions = pipelineVersionManager.loadAllVersionFromGit(pipelineId, null);
Optional<Revision> oRevision = revisions.stream().filter(r -> r.getName().equals(version)).findAny();
PipelineDocumentTemplate template = oRevision.map(revision -> new PipelineDocumentTemplate(pipeline, revision)).orElseGet(() -> new PipelineDocumentTemplate(pipeline));
this.fillTemplate(template);
return template;
}
Aggregations