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;
}
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;
}
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;
}
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());
}
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);
}
Aggregations