Search in sources :

Example 1 with StateAllRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner in project cloudbreak by hortonworks.

the class SaltOrchestrator method validateCloudStorageBackup.

@SuppressFBWarnings("REC_CATCH_EXCEPTION")
@Override
public void validateCloudStorageBackup(GatewayConfig primaryGateway, List<GatewayConfig> allGatewayConfigs, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
    Set<String> targetHostnames = allNodes.stream().map(Node::getHostname).collect(Collectors.toSet());
    try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
        runValidation(sc, new StateAllRunner(targetHostnames, allNodes, "validation/cloud-storage-backup"), exitCriteriaModel);
        LOGGER.debug("Completed validating cloud storage");
    } catch (CloudbreakOrchestratorException e) {
        LOGGER.warn("CloudbreakOrchestratorException occurred during cloud storage validation", e);
        throw e;
    } catch (ExecutionException e) {
        LOGGER.warn("Error occurred during cloud storage validation", e);
        if (e.getCause() instanceof CloudbreakOrchestratorFailedException) {
            throw (CloudbreakOrchestratorFailedException) e.getCause();
        }
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    } catch (Exception e) {
        LOGGER.warn("Error occurred during cloud storage validation", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) HighStateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateAllRunner) StateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner) ExecutionException(java.util.concurrent.ExecutionException) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with StateAllRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner in project cloudbreak by hortonworks.

the class SaltOrchestrator method formatAndMountDisksOnNodes.

@Override
@Retryable(backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000), maxAttempts = 5)
public Map<String, Map<String, String>> formatAndMountDisksOnNodes(OrchestratorAware stack, List<GatewayConfig> allGateway, Set<Node> nodesWithDiskData, Set<Node> allNodes, ExitCriteriaModel exitModel, String platformVariant) throws CloudbreakOrchestratorFailedException {
    GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(allGateway);
    Set<String> gatewayTargetIpAddresses = getGatewayPrivateIps(allGateway);
    Target<String> allHosts = new HostList(nodesWithDiskData.stream().map(Node::getHostname).collect(Collectors.toSet()));
    try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
        saveHostsPillar(stack, exitModel, gatewayTargetIpAddresses, sc);
        Callable<Boolean> saltPillarRunner;
        Map<String, String> dataVolumeMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getDataVolumes()));
        Map<String, String> serialIdMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getSerialIds()));
        Map<String, String> fstabMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getFstab()));
        Map<String, String> temporaryStorageMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getTemporaryStorage().name()));
        Map<String, Integer> dataBaseVolumeIndexMap = nodesWithDiskData.stream().collect(Collectors.toMap(Node::getHostname, node -> node.getNodeVolumes().getDatabaseVolumeIndex()));
        Map<String, Object> hostnameDiskMountMap = nodesWithDiskData.stream().map(Node::getHostname).collect(Collectors.toMap(hn -> hn, hn -> Map.of("attached_volume_name_list", dataVolumeMap.getOrDefault(hn, ""), "attached_volume_serial_list", serialIdMap.getOrDefault(hn, ""), "cloud_platform", platformVariant, "previous_fstab", fstabMap.getOrDefault(hn, ""), "database_volume_index", dataBaseVolumeIndexMap.getOrDefault(hn, -1), "temporary_storage", temporaryStorageMap.getOrDefault(hn, TemporaryStorage.ATTACHED_VOLUMES.name()))));
        SaltPillarProperties mounDiskProperties = new SaltPillarProperties("/mount/disk.sls", Collections.singletonMap("mount_data", hostnameDiskMountMap));
        OrchestratorBootstrap pillarSave = PillarSave.createCustomPillar(sc, gatewayTargetIpAddresses, mounDiskProperties);
        saltPillarRunner = saltRunner.runner(pillarSave, exitCriteria, exitModel);
        saltPillarRunner.call();
        saltCommandRunner.runModifyGrainCommand(sc, new GrainAddRunner(hostnameDiskMountMap.keySet(), allNodes, "mount_disks"), exitModel, exitCriteria);
        StateAllRunner stateAllRunner = new StateAllRunner(gatewayTargetIpAddresses, allNodes, "disks.format-and-mount");
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateAllRunner);
        Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitModel);
        saltJobRunBootstrapRunner.call();
        Map<String, String> uuidResponse = SaltStates.getUuidList(sc);
        saltCommandRunner.runModifyGrainCommand(sc, new GrainRemoveRunner(hostnameDiskMountMap.keySet(), allNodes, "mount_disks"), exitModel, exitCriteria);
        Map<String, String> fstabResponse = SaltStates.runCommandOnHosts(retry, sc, allHosts, "cat /etc/fstab");
        return nodesWithDiskData.stream().map(node -> {
            String fstab = fstabResponse.getOrDefault(node.getHostname(), "");
            String uuidList = uuidResponse.getOrDefault(node.getHostname(), "");
            return new SimpleImmutableEntry<>(node.getHostname(), Map.of("uuids", uuidList, "fstab", fstab));
        }).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
    } catch (Exception e) {
        LOGGER.info("Error occurred during the salt bootstrap", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : GrainOperation(com.sequenceiq.cloudbreak.orchestrator.host.GrainOperation) FileReaderUtils.readFileFromClasspath(com.sequenceiq.cloudbreak.util.FileReaderUtils.readFileFromClasspath) SaltCommandRunner(com.sequenceiq.cloudbreak.orchestrator.salt.runner.SaltCommandRunner) Target(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Target) SaltBootstrap(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) SyncAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.SyncAllRunner) LoggerFactory(org.slf4j.LoggerFactory) HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) SaltUploadWithPermission(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltUploadWithPermission) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) HighStateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateAllRunner) StringUtils(org.apache.commons.lang3.StringUtils) PillarSave(com.sequenceiq.cloudbreak.orchestrator.salt.poller.PillarSave) BootstrapParams(com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) HostAndRoleTarget(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostAndRoleTarget) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) StateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) MineUpdateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.MineUpdateRunner) ModifyGrainBase(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ModifyGrainBase) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Collection(java.util.Collection) Set(java.util.Set) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Retry(com.sequenceiq.cloudbreak.service.Retry) RecipeExecutionPhase.convert(com.sequenceiq.cloudbreak.common.type.RecipeExecutionPhase.convert) Collectors(java.util.stream.Collectors) Backoff(org.springframework.retry.annotation.Backoff) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) GrainRemoveRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner) StandardCharsets(java.nio.charset.StandardCharsets) Sets(com.google.common.collect.Sets) ParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner) SALT(com.sequenceiq.cloudbreak.common.type.OrchestratorConstants.SALT) List(java.util.List) MinionStatusSaltResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.MinionStatusSaltResponse) SaltStates(com.sequenceiq.cloudbreak.orchestrator.salt.states.SaltStates) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CollectionUtils(org.springframework.util.CollectionUtils) Entry(java.util.Map.Entry) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) NodeVolumes(com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes) Predicate.not(java.util.function.Predicate.not) RecipeExecutionPhase(com.sequenceiq.cloudbreak.common.type.RecipeExecutionPhase) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Joiner(com.google.common.base.Joiner) SaltUpload(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltUpload) OrchestratorGrainRunnerParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorGrainRunnerParams) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) CompressUtil(com.sequenceiq.cloudbreak.util.CompressUtil) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) ArrayList(java.util.ArrayList) RecipeModel(com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) GrainAddRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner) OrchestratorStateRetryParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateRetryParams) CmAgentStopFlags(com.sequenceiq.cloudbreak.orchestrator.model.CmAgentStopFlags) KeytabModel(com.sequenceiq.cloudbreak.orchestrator.model.KeytabModel) OrchestratorStateParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateParams) Retryable(org.springframework.retry.annotation.Retryable) Glob(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Glob) ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) ExitCriteria(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteria) StateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner) Logger(org.slf4j.Logger) PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo) OrchestratorAware(com.sequenceiq.cloudbreak.common.orchestration.OrchestratorAware) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) GrainUploader(com.sequenceiq.cloudbreak.orchestrator.salt.grain.GrainUploader) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) IOException(java.io.IOException) PRE_CLOUDERA_MANAGER_START(com.sequenceiq.cloudbreak.common.type.RecipeExecutionPhase.PRE_CLOUDERA_MANAGER_START) ExecutionException(java.util.concurrent.ExecutionException) GrainsJsonPropertyUtil(com.sequenceiq.cloudbreak.orchestrator.salt.utils.GrainsJsonPropertyUtil) HttpStatus(org.springframework.http.HttpStatus) Component(org.springframework.stereotype.Component) BaseSaltJobRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.BaseSaltJobRunner) SaltRunner(com.sequenceiq.cloudbreak.orchestrator.salt.runner.SaltRunner) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Collections(java.util.Collections) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) HighStateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateAllRunner) StateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) JsonNode(com.fasterxml.jackson.databind.JsonNode) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) GrainAddRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner) HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GrainRemoveRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Retryable(org.springframework.retry.annotation.Retryable)

Example 3 with StateAllRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner in project cloudbreak by hortonworks.

the class SaltTelemetryOrchestrator method installAndStartMonitoring.

@Override
public void installAndStartMonitoring(List<GatewayConfig> allGateways, Set<Node> nodes, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorFailedException {
    GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(allGateways);
    Set<String> serverHostname = Sets.newHashSet(primaryGateway.getHostname());
    try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
        StateAllRunner stateAllJobRunner = new StateAllRunner(serverHostname, nodes, MONITORING_INIT);
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateAllJobRunner);
        Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitModel);
        saltJobRunBootstrapRunner.call();
    } catch (Exception e) {
        LOGGER.info("Error occurred during cluster monitoring start", e);
        throw new CloudbreakOrchestratorFailedException(e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) StateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) UncheckedIOException(java.io.UncheckedIOException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)3 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)3 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)3 StateAllRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner)3 IOException (java.io.IOException)3 ExecutionException (java.util.concurrent.ExecutionException)3 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)2 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)2 CloudbreakOrchestratorTimeoutException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException)2 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)2 SaltJobIdTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Joiner (com.google.common.base.Joiner)1 Sets (com.google.common.collect.Sets)1 PackageInfo (com.sequenceiq.cloudbreak.common.model.PackageInfo)1 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 NodeVolumes (com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes)1 OrchestratorAware (com.sequenceiq.cloudbreak.common.orchestration.OrchestratorAware)1 SALT (com.sequenceiq.cloudbreak.common.type.OrchestratorConstants.SALT)1