Search in sources :

Example 71 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class PipelineRunManager method loadPipelineRunWithRestartedRuns.

@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun loadPipelineRunWithRestartedRuns(Long id) {
    PipelineRun run = loadPipelineRun(id);
    List<RestartRun> restartedRuns = restartRunManager.loadRestartedRunsForInitialRun(id);
    run.setRestartedRuns(restartedRuns);
    run.setRunStatuses(runStatusManager.loadRunStatus(id));
    return run;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) RestartRun(com.epam.pipeline.entity.pipeline.run.RestartRun) Transactional(org.springframework.transaction.annotation.Transactional)

Example 72 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class RunLogManager method loadTasksByRunId.

@Transactional(propagation = Propagation.SUPPORTS)
public List<PipelineTask> loadTasksByRunId(Long runId) {
    PipelineRun run = pipelineRunManager.loadPipelineRun(runId);
    List<PipelineTask> tasks = runLogDao.loadTasksForRun(runId);
    tasks.forEach(task -> {
        if (run.getStatus().isFinal() && !task.getStatus().isFinal()) {
            task.setStatus(run.getStatus());
            if (task.getFinished() == null) {
                task.setFinished(run.getEndDate());
            }
        }
        if ((StringUtils.isEmpty(task.getInstance()) || task.getInstance().equals(run.getPodId())) && !task.getStatus().isFinal()) {
            task.setStatus(run.getStatus());
        }
        if (task.getStarted() == null && (StringUtils.isEmpty(task.getInstance()) || task.getInstance().equals(run.getPodId()) || task.getStatus().isFinal())) {
            task.setStarted(task.getCreated());
        }
        if (!task.getStatus().isFinal()) {
            task.setFinished(null);
        }
        if (task.getName().equals(run.getPipelineName())) {
            task.setCreated(run.getStartDate());
            task.setStarted(tasks.get(0).getCreated());
        }
    });
    if (!run.getStatus().isFinal()) {
        // for running tasks we add dummy 'console' task to get online logs from Kubernetes
        PipelineTask consoleTask = new PipelineTask();
        consoleTask.setName(consoleLogTask);
        consoleTask.setStatus(TaskStatus.RUNNING);
        consoleTask.setStarted(run.getStartDate());
        tasks.add(consoleTask);
    }
    return tasks;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineTask(com.epam.pipeline.entity.pipeline.PipelineTask) Transactional(org.springframework.transaction.annotation.Transactional)

Example 73 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class CloudPlatformRunner method runConfigurationEntry.

private List<PipelineRun> runConfigurationEntry(RunConfigurationEntry entry, PipelineConfiguration configuration, int copies, String clusterId, boolean startNFS, List<Long> entityIds, Long configurationId) {
    PipelineStart startVO = entry.toPipelineStart();
    if (!StringUtils.hasText(clusterId)) {
        log.debug("Launching master entry {}", entry.getName());
        pipelineConfigurationManager.updateMasterConfiguration(configuration, startNFS);
    } else {
        log.debug("Launching worker entry {}", entry.getName());
        pipelineConfigurationManager.updateWorkerConfiguration(clusterId, startVO, configuration, startNFS, true);
    }
    Pipeline pipeline = entry.getPipelineId() != null ? pipelineManager.load(entry.getPipelineId()) : null;
    List<PipelineRun> result = new ArrayList<>();
    log.debug("Launching total {} copies of entry {}", copies, entry.getName());
    for (int i = 0; i < copies; i++) {
        // only first node may be a NFS server
        if (i != 0) {
            configuration.setCmdTemplate(WORKER_CMD_TEMPLATE);
            configuration.getParameters().remove(NFS_CLUSTER_ROLE);
            configuration.buildEnvVariables();
        }
        result.add(pipelineRunManager.launchPipeline(configuration, pipeline, entry.getPipelineVersion(), startVO.getInstanceType(), startVO.getParentNodeId(), startVO.getConfigurationName(), clusterId, null, entityIds, configurationId, startVO.getRunSids()));
    }
    return result;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) ArrayList(java.util.ArrayList) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 74 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class PipelineRunDaoTest method updatePodStatus.

@Test
public void updatePodStatus() {
    PipelineRun run = createRun(testPipeline.getId(), null, TaskStatus.SUCCESS, null);
    run.setPodStatus(POD_STATUS);
    pipelineRunDao.updatePodStatus(run);
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertEquals(POD_STATUS, loadedRun.getPodStatus());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 75 with PipelineRun

use of com.epam.pipeline.entity.pipeline.PipelineRun in project cloud-pipeline by epam.

the class PipelineRunDaoTest method testLoadActiveServicesByOwner.

@Test
public void testLoadActiveServicesByOwner() {
    PipelineRun run = createTestPipelineRun();
    PagingRunFilterVO filterVO = new PagingRunFilterVO();
    filterVO.setPage(1);
    filterVO.setPageSize(TEST_PAGE_SIZE);
    PipelineUser user = new PipelineUser();
    user.setUserName(USER);
    List<PipelineRun> runs = pipelineRunDao.loadActiveServices(filterVO, user);
    assertEquals(1, runs.size());
    assertEquals(run.getId(), runs.get(0).getId());
    assertEquals(1, runs.size());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineUser(com.epam.pipeline.entity.user.PipelineUser) PagingRunFilterVO(com.epam.pipeline.controller.vo.PagingRunFilterVO) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Aggregations

PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)88 Test (org.junit.Test)31 Transactional (org.springframework.transaction.annotation.Transactional)29 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)23 EnvVarsBuilderTest (com.epam.pipeline.manager.execution.EnvVarsBuilderTest)22 ArrayList (java.util.ArrayList)18 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)17 Date (java.util.Date)15 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)14 List (java.util.List)14 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)13 Map (java.util.Map)11 LocalDateTime (java.time.LocalDateTime)10 Arrays (java.util.Arrays)10 Collectors (java.util.stream.Collectors)10 PipelineUser (com.epam.pipeline.entity.user.PipelineUser)9 Collections (java.util.Collections)9 HashMap (java.util.HashMap)9 MessageHelper (com.epam.pipeline.common.MessageHelper)8 RunSid (com.epam.pipeline.entity.pipeline.run.parameter.RunSid)8