Search in sources :

Example 1 with Pipeline

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);
}
Also used : Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Async(org.springframework.scheduling.annotation.Async) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

Example 2 with Pipeline

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;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) ToolSecurityPolicyCheck(com.epam.pipeline.manager.docker.scan.ToolSecurityPolicyCheck)

Example 3 with Pipeline

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;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) RunInstance(com.epam.pipeline.entity.pipeline.RunInstance) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 4 with Pipeline

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;
}
Also used : Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 5 with Pipeline

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;
}
Also used : PipelineManager(com.epam.pipeline.manager.pipeline.PipelineManager) GitClientException(com.epam.pipeline.exception.git.GitClientException) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) GitRepositoryEntry(com.epam.pipeline.entity.git.GitRepositoryEntry) DocumentGenerationPropertyManager(com.epam.pipeline.manager.pipeline.DocumentGenerationPropertyManager) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) PipelineVersionManager(com.epam.pipeline.manager.pipeline.PipelineVersionManager) ArrayList(java.util.ArrayList) Service(org.springframework.stereotype.Service) TaskNode(com.epam.pipeline.entity.graph.TaskNode) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) GitManager(com.epam.pipeline.manager.git.GitManager) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Tool(com.epam.pipeline.entity.pipeline.Tool) DataStorageRuleManager(com.epam.pipeline.manager.datastorage.DataStorageRuleManager) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) TaskGraphVO(com.epam.pipeline.controller.vo.TaskGraphVO) Revision(com.epam.pipeline.entity.pipeline.Revision) Optional(java.util.Optional) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) DataStorageRule(com.epam.pipeline.entity.datastorage.rules.DataStorageRule) Revision(com.epam.pipeline.entity.pipeline.Revision) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Aggregations

Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)88 Test (org.junit.Test)41 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)25 Transactional (org.springframework.transaction.annotation.Transactional)18 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)16 GitCommitEntry (com.epam.pipeline.entity.git.GitCommitEntry)14 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)13 Revision (com.epam.pipeline.entity.pipeline.Revision)12 Folder (com.epam.pipeline.entity.pipeline.Folder)10 Before (org.junit.Before)9 GitFile (com.epam.pipeline.entity.git.GitFile)8 GitRepositoryEntry (com.epam.pipeline.entity.git.GitRepositoryEntry)7 EnvVarsBuilderTest (com.epam.pipeline.manager.execution.EnvVarsBuilderTest)7 Date (java.util.Date)7 List (java.util.List)7 GitTagEntry (com.epam.pipeline.entity.git.GitTagEntry)6 PipelineUser (com.epam.pipeline.entity.user.PipelineUser)6 IsEmptyString.isEmptyString (org.hamcrest.text.IsEmptyString.isEmptyString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 EntityVO (com.epam.pipeline.controller.vo.EntityVO)5