Search in sources :

Example 66 with PipelineRun

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

the class PipelineRunManager method prolongIdleRun.

@Transactional(propagation = Propagation.REQUIRED)
public void prolongIdleRun(Long runId) {
    PipelineRun run = loadPipelineRun(runId);
    run.setLastIdleNotificationTime(null);
    run.setProlongedAtTime(DateUtils.nowUTC());
    updateProlongIdleRunAndLastIdleNotificationTime(run);
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Transactional(org.springframework.transaction.annotation.Transactional)

Example 67 with PipelineRun

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

the class PipelineRunManager method runPod.

/**
 * Creates a new pod with a given run_id, doesn't create a new pipeline run
 * @param runVO
 * @return
 */
// TODO: refactoring
@ToolSecurityPolicyCheck
@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun runPod(PipelineStart runVO) {
    Assert.notNull(runVO.getCmdTemplate(), messageHelper.getMessage(MessageConstants.SETTING_IS_NOT_PROVIDED, "cmd_template"));
    PipelineRun parentRun = loadPipelineRun(runVO.getUseRunId());
    Assert.state(parentRun.getStatus() == TaskStatus.RUNNING, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_RUN_NOT_RUNNING, runVO.getUseRunId()));
    PipelineConfiguration configuration = configurationManager.getPipelineConfiguration(runVO);
    Tool tool = getToolForRun(configuration);
    configuration.setSecretName(tool.getSecretName());
    List<String> endpoints = tool.getEndpoints();
    PipelineRun run = new PipelineRun();
    run.setInstance(parentRun.getInstance());
    run.setId(runVO.getUseRunId());
    run.setStartDate(DateUtils.now());
    run.setStatus(TaskStatus.RUNNING);
    run.setPipelineName(DEFAULT_PIPELINE_NAME);
    run.setPodId(getRootPodIDFromTool(tool.getImage(), run.getId()));
    run.setDockerImage(configuration.getDockerImage());
    run.setCmdTemplate(determinateCmdTemplateForRun(configuration));
    run.setTimeout(runVO.getTimeout());
    run.setCommitStatus(CommitStatus.NOT_COMMITTED);
    run.setLastChangeCommitTime(DateUtils.now());
    run.setRunSids(runVO.getRunSids());
    run.setOwner(parentRun.getOwner());
    String launchedCommand = pipelineLauncher.launch(run, configuration, endpoints, runVO.getUseRunId().toString(), false, parentRun.getPodId(), null);
    run.setActualCmd(launchedCommand);
    return run;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Tool(com.epam.pipeline.entity.pipeline.Tool) ToolSecurityPolicyCheck(com.epam.pipeline.manager.docker.scan.ToolSecurityPolicyCheck) Transactional(org.springframework.transaction.annotation.Transactional)

Example 68 with PipelineRun

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

the class PipelineRunManager method updateRunInstance.

@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun updateRunInstance(Long id, RunInstance instance) {
    PipelineRun pipelineRun = pipelineRunDao.loadPipelineRun(id);
    if (!instance.isEmpty()) {
        pipelineRun.setInstance(instance);
        pipelineRunDao.updateRunInstance(pipelineRun);
    }
    return pipelineRun;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Transactional(org.springframework.transaction.annotation.Transactional)

Example 69 with PipelineRun

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

the class PipelineRunManager method updatePrettyUrl.

@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun updatePrettyUrl(Long runId, String url) {
    PipelineRun pipelineRun = pipelineRunDao.loadPipelineRun(runId);
    Assert.notNull(pipelineRun, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, runId));
    if (Objects.equals(pipelineRun.getPrettyUrl(), url)) {
        LOGGER.debug("Url '{}' is already assigned to run {}", url, runId);
        return pipelineRun;
    }
    validatePrettyUrlFree(url);
    pipelineRun.setPrettyUrl(url);
    pipelineRunDao.updateRun(pipelineRun);
    // TODO: check if we need it
    setParent(pipelineRun);
    return pipelineRun;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Transactional(org.springframework.transaction.annotation.Transactional)

Example 70 with PipelineRun

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

the class PipelineRunManager method updateRunSids.

/**
 * Updates pipeline run sids
 * @param runId {@link PipelineRun} id for pipeline run which run sids should be updated
 * @param runSids - a list of identities (user names or groups) that have access to run
 * @return updated pipeline {@link RunSid}
 */
@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun updateRunSids(Long runId, List<RunSid> runSids) {
    PipelineRun pipelineRun = pipelineRunDao.loadPipelineRun(runId);
    Assert.notNull(pipelineRun, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, runId));
    pipelineRunDao.deleteRunSids(runId);
    pipelineRunDao.createRunSids(runId, runSids);
    pipelineRun.setRunSids(runSids);
    return pipelineRun;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Transactional(org.springframework.transaction.annotation.Transactional)

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