Search in sources :

Example 1 with PipelineConfiguration

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);
}
Also used : ResolvedConfiguration(com.epam.pipeline.entity.pipeline.ResolvedConfiguration) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) HashMap(java.util.HashMap) AbstractRunConfigurationEntry(com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration)

Example 2 with PipelineConfiguration

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

Example 3 with PipelineConfiguration

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;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) ToolSecurityPolicyCheck(com.epam.pipeline.manager.docker.scan.ToolSecurityPolicyCheck)

Example 4 with PipelineConfiguration

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;
}
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 5 with PipelineConfiguration

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;
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry)

Aggregations

PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)43 Test (org.junit.Test)16 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)12 Tool (com.epam.pipeline.entity.pipeline.Tool)12 RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)10 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)9 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)9 PipelineStart (com.epam.pipeline.entity.pipeline.run.PipelineStart)8 List (java.util.List)7 ConfigurationEntry (com.epam.pipeline.entity.configuration.ConfigurationEntry)6 Before (org.junit.Before)6 PipeConfValueVO (com.epam.pipeline.entity.configuration.PipeConfValueVO)5 HashMap (java.util.HashMap)5 Collectors (java.util.stream.Collectors)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Transactional (org.springframework.transaction.annotation.Transactional)5 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)4 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)4 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)4 ArrayList (java.util.ArrayList)4