use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method renameConfiguration.
public List<ConfigurationEntry> renameConfiguration(Long id, String oldName, String newName) throws GitClientException {
Assert.isTrue(StringUtils.hasText(oldName), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Assert.isTrue(StringUtils.hasText(newName), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
ConfigurationEntry oldConfig = findConfigByName(currentConfigurations, oldName);
Assert.notNull(oldConfig, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, oldName));
Assert.isTrue(findConfigByName(currentConfigurations, newName) == null, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_EXISTS, newName));
currentConfigurations.forEach(config -> {
if (oldName.equals(config.getName())) {
config.setName(newName);
}
});
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_RENAME, oldName, newName);
return saveUpdatedConfiguration(newName, pipeline, currentConfigurations, message);
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method getWorkflowGraph.
public TaskGraphVO getWorkflowGraph(Long id, String version) {
Pipeline pipeline = pipelineManager.load(id);
try {
gitManager.loadRevision(pipeline, version);
} catch (GitClientException e) {
LOGGER.error(e.getMessage(), e);
throw new IllegalArgumentException(e.getMessage());
}
File config = gitManager.getConfigFile(pipeline, version);
TaskGraphVO result = new GraphReader().readGraph(graphScript, config.getParentFile().getAbsolutePath(), CONFIG_FILE_NAME);
mergeToolsRequirements(result);
try {
FileUtils.deleteDirectory(config.getParentFile());
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
return result;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method deleteConfiguration.
public List<ConfigurationEntry> deleteConfiguration(Long id, String configName) throws GitClientException {
Assert.notNull(configName, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
List<ConfigurationEntry> updatedConf = removeConfig(configName, currentConfigurations);
Assert.isTrue(currentConfigurations.size() != updatedConf.size(), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, configName));
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_DELETE, configName);
return saveUpdatedConfiguration(configName, pipeline, updatedConf, message);
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class DtsRunner method runEntry.
private PipelineRun runEntry(DtsRunConfigurationEntry entry, Long configurationId, List<Long> entitiesIds, PipelineConfiguration configuration) {
Pipeline pipeline = entry.getPipelineId() == null ? null : pipelineManager.load(entry.getPipelineId());
PipelineRun run = pipelineRunManager.createPipelineRun(entry.getPipelineVersion(), configuration, pipeline, null, entitiesIds, configurationId);
run.setConfigName(entry.getConfigName());
run.setDockerImage(toolManager.getExternalToolName(run.getDockerImage()));
run.setExecutionPreferences(DtsExecutionPreferences.builder().dtsId(entry.getDtsId()).coresNumber(entry.getCoresNumber()).build());
Map<SystemParams, String> systemParams = pipelineLauncher.matchCommonParams(run, preferenceManager.getPreference(SystemPreferences.BASE_API_HOST_EXTERNAL), configuration.getGitCredentials());
systemParams.put(SystemParams.DISTRIBUTION_URL, preferenceManager.getPreference(SystemPreferences.DTS_DISTRIBUTION_URL));
GitCredentials gitCredentials = configuration.getGitCredentials();
String gitCloneUrl = gitCredentials == null ? run.getRepository() : gitCredentials.getUrl();
String pipelineCommand = commandBuilder.build(configuration, systemParams);
run.setActualCmd(pipelineCommand);
String launchCmd = preferenceManager.getPreference(SystemPreferences.DTS_LAUNCH_CMD_TEMPLATE);
String launchScriptUrl = preferenceManager.getPreference(SystemPreferences.DTS_LAUNCH_URL);
String fullCmd = String.format(launchCmd, launchScriptUrl, launchScriptUrl, gitCloneUrl, run.getRevisionName(), pipelineCommand);
pipelineRunManager.save(run);
DtsSubmission submission = buildSubmission(run, configuration, entry.getCoresNumber(), systemParams, fullCmd);
log.debug("Creating DTS submission");
try {
DtsSubmission scheduled = submissionManager.createSubmission(entry.getDtsId(), submission);
if (scheduled.getState().getStatus() != TaskStatus.RUNNING) {
return failRun(run, String.format("Submission failed to start: %s", scheduled.getState().getReason()));
}
log.debug("Successfully scheduled submission on DTS");
return run;
} catch (DtsRequestException e) {
return failRun(run, e.getMessage());
}
}
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;
}
Aggregations