use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class ParameterMapper method resolveParameters.
/**
* Gets configuration for a list of {@link AbstractRunConfigurationEntry} resolving
* template parameters from
* @param entity to use for parameters template mapping
* @param entries to resolve
* @param projectData metadata of associated project {@link com.epam.pipeline.entity.pipeline.Folder}
* @return configuration for all input entries
*/
public ResolvedConfiguration resolveParameters(MetadataEntity entity, List<? extends AbstractRunConfigurationEntry> entries, Map<String, PipeConfValue> projectData) {
if (CollectionUtils.isEmpty(entries)) {
return new ResolvedConfiguration(entity, Collections.emptyMap());
}
if (entity == null) {
return new ResolvedConfiguration(null, entries.stream().collect(Collectors.toMap(AbstractRunConfigurationEntry::getName, this::getEntryConfiguration)));
}
Map<MetadataKey, MetadataEntity> entityReferences = loadReferences(entity);
Map<String, PipelineConfiguration> resolved = new HashMap<>();
entries.forEach(entry -> {
checkClassIdMatch(entity, entry.getRootEntityId());
PipelineConfiguration configuration = getEntryConfiguration(entry);
if (MapUtils.isNotEmpty(configuration.getParameters())) {
configuration.setParameters(mapParameters(entity, projectData, configuration.getParameters(), entityReferences));
}
resolved.put(entry.getName(), configuration);
});
return new ResolvedConfiguration(entity, resolved);
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class PipelineRunManager method runCmd.
/**
* Launches cmd command execution, uses Tool as ACL identity
* @param runVO
* @return
*/
@ToolSecurityPolicyCheck
public PipelineRun runCmd(PipelineStart runVO) {
Assert.notNull(runVO.getInstanceType(), messageHelper.getMessage(MessageConstants.SETTING_IS_NOT_PROVIDED, "instance_type"));
Assert.notNull(runVO.getHddSize(), messageHelper.getMessage(MessageConstants.SETTING_IS_NOT_PROVIDED, "instance_disk"));
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)));
Tool tool = toolManager.loadByNameOrId(runVO.getDockerImage());
PipelineConfiguration configuration = configurationManager.getPipelineConfiguration(runVO, tool);
boolean clusterRun = configurationManager.initClusterConfiguration(configuration, true);
PipelineRun run = launchPipeline(configuration, null, null, runVO.getInstanceType(), runVO.getParentNodeId(), runVO.getConfigurationName(), null, runVO.getParentRunId(), null, null, runVO.getRunSids());
run.setParent(tool);
run.setAclClass(AclClass.TOOL);
if (clusterRun) {
runClusterWorkers(run, runVO, null, null, configuration);
}
return run;
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration 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;
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration 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.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class PipelineConfigurationManager method getConfigurationForToolRunOrPipelineRun.
private PipelineConfiguration getConfigurationForToolRunOrPipelineRun(final PipelineStart runVO, final Tool tool, final boolean toolRun) {
PipelineConfiguration defaultConfiguration;
ConfigurationEntry entry;
if (toolRun) {
entry = getConfigurationForToolVersion(tool.getId(), runVO.getDockerImage(), runVO.getConfigurationName());
} else {
entry = initRegisteredPipelineConfiguration(runVO.getPipelineId(), runVO.getVersion(), runVO.getConfigurationName());
}
defaultConfiguration = entry == null ? new PipelineConfiguration() : entry.getConfiguration();
if (!StringUtils.hasText(runVO.getConfigurationName()) && entry != null) {
runVO.setConfigurationName(entry.getName());
}
return defaultConfiguration;
}
Aggregations