Search in sources :

Example 6 with PipelineRun

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

the class PipelineRunManager method restartRun.

/**
 * Restarts spot run
 * @param run {@link PipelineRun} which will be restart
 * @return Restarted pipeline run
 */
@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun restartRun(final PipelineRun run) {
    final PipelineConfiguration configuration = configurationManager.getConfigurationFromRun(run);
    final PipelineRun restartedRun = createRestartRun(run);
    final Tool tool = getToolForRun(configuration);
    final List<String> endpoints = configuration.isEraseRunEndpoints() ? Collections.emptyList() : tool.getEndpoints();
    configuration.setSecretName(tool.getSecretName());
    final String launchedCommand = pipelineLauncher.launch(restartedRun, configuration, endpoints, restartedRun.getId().toString(), null);
    restartedRun.setActualCmd(launchedCommand);
    save(restartedRun);
    final RestartRun restartRun = new RestartRun();
    restartRun.setParentRunId(run.getId());
    restartRun.setRestartedRunId(restartedRun.getId());
    restartRun.setDate(DateUtils.now());
    restartRunManager.createRestartRun(restartRun);
    return run;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RestartRun(com.epam.pipeline.entity.pipeline.run.RestartRun) Tool(com.epam.pipeline.entity.pipeline.Tool) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with PipelineRun

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

the class PipelineRunManager method pauseRun.

/**
 * Pauses pipeline run for specified {@code runId}.
 * @param runId {@link PipelineRun} id for pipeline run to be paused
 * @param checkSize if true method will check if free disk space is enough for commit operation
 * @return paused {@link PipelineRun}
 */
public PipelineRun pauseRun(Long runId, boolean checkSize) {
    if (checkSize) {
        Assert.state(checkFreeSpaceAvailable(runId), MessageConstants.ERROR_INSTANCE_DISK_NOT_ENOUGH);
    }
    PipelineRun pipelineRun = pipelineRunDao.loadPipelineRun(runId);
    verifyPipelineRunForPauseResume(pipelineRun, runId);
    Assert.isTrue(pipelineRun.getInitialized(), messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_RUN_NOT_INITIALIZED, runId));
    Assert.notNull(pipelineRun.getDockerImage(), messageHelper.getMessage(MessageConstants.ERROR_DOCKER_IMAGE_NOT_FOUND, runId));
    Assert.state(pipelineRun.getStatus() == TaskStatus.RUNNING, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_RUN_FINISHED, runId));
    pipelineRun.setStatus(TaskStatus.PAUSING);
    updatePipelineStatus(pipelineRun);
    dockerContainerOperationManager.pauseRun(pipelineRun);
    return pipelineRun;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun)

Example 8 with PipelineRun

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

the class PipelineRunManager method updatePodStatus.

@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun updatePodStatus(Long id, String status) {
    PipelineRun pipelineRun = pipelineRunDao.loadPipelineRun(id);
    Assert.notNull(pipelineRun, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, id));
    pipelineRun.setPodStatus(status);
    pipelineRunDao.updatePodStatus(pipelineRun);
    return pipelineRun;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with PipelineRun

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

the class PipelineRunManager method setParentInstance.

private void setParentInstance(PipelineRun run, Long parentNodeId) {
    PipelineRun parentRun = loadPipelineRun(parentNodeId);
    run.setInstance(parentRun.getInstance());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun)

Example 10 with PipelineRun

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

the class PipelineRunManager method loadActiveServices.

/**
 * Method that will return all active runs for which current users is owner or is listed in run sids - a list of
 * identities (user names or groups) that have access to run
 * @param filter - filter containing a page and page size
 * @return list of active runs which available for current user
 */
@Transactional(propagation = Propagation.SUPPORTS)
public PagedResult<List<PipelineRun>> loadActiveServices(PagingRunFilterVO filter) {
    Assert.isTrue(filter.getPage() > 0, messageHelper.getMessage(MessageConstants.ERROR_PAGE_INDEX));
    Assert.isTrue(filter.getPageSize() > 0, messageHelper.getMessage(MessageConstants.ERROR_PAGE_SIZE));
    PipelineUser user = authManager.getCurrentUser();
    List<PipelineRun> runs = pipelineRunDao.loadActiveServices(filter, user);
    int count = pipelineRunDao.countActiveServices(user);
    return new PagedResult<>(runs, count);
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineUser(com.epam.pipeline.entity.user.PipelineUser) PagedResult(com.epam.pipeline.controller.PagedResult) 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