Search in sources :

Example 1 with StateRunner

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

the class SaltOrchestrator method callBackupRestore.

private void callBackupRestore(GatewayConfig primaryGateway, Set<String> target, Set<Node> allNodes, SaltConfig saltConfig, ExitCriteriaModel exitModel, String state) throws CloudbreakOrchestratorFailedException {
    try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
        for (Entry<String, SaltPillarProperties> propertiesEntry : saltConfig.getServicePillarConfig().entrySet()) {
            OrchestratorBootstrap pillarSave = PillarSave.createCustomPillar(sc, Sets.newHashSet(primaryGateway.getPrivateAddress()), propertiesEntry.getValue());
            Callable<Boolean> saltPillarRunner = saltRunner.runner(pillarSave, exitCriteria, exitModel, maxDatabaseDrRetry, maxDatabaseDrRetryOnError);
            saltPillarRunner.call();
        }
        StateRunner stateRunner = new StateRunner(target, allNodes, state);
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateRunner);
        Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitModel, maxDatabaseDrRetry, maxDatabaseDrRetryOnError);
        saltJobRunBootstrapRunner.call();
    } catch (Exception e) {
        LOGGER.error("Error occurred during database backup/restore", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) ParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner) ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) StateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner) 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)

Example 2 with StateRunner

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

the class SaltOrchestrator method restartClusterManagerOnMaster.

@Override
public void restartClusterManagerOnMaster(GatewayConfig gatewayConfig, Set<String> target, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
    try (SaltConnector sc = saltService.createSaltConnector(gatewayConfig)) {
        StateRunner stateRunner = new StateRunner(target, allNodes, CM_SERVER_RESTART);
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateRunner);
        Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitCriteriaModel);
        saltJobRunBootstrapRunner.call();
    } catch (Exception e) {
        LOGGER.error("Error occurred during CM Server restart", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) ParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner) ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) StateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner) 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)

Example 3 with StateRunner

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

the class SaltOrchestrator method executeRecipes.

@SuppressFBWarnings("REC_CATCH_EXCEPTION")
private void executeRecipes(GatewayConfig gatewayConfig, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel, RecipeExecutionPhase phase, boolean forced) throws CloudbreakOrchestratorFailedException, CloudbreakOrchestratorTimeoutException {
    int maxRetry = forced ? maxRetryRecipeForced : maxRetryRecipe;
    try (SaltConnector sc = saltService.createSaltConnector(gatewayConfig)) {
        // add 'recipe' grain to all nodes
        Set<String> targetHostnames = allNodes.stream().map(Node::getHostname).collect(Collectors.toSet());
        saltCommandRunner.runSaltCommand(sc, new GrainAddRunner(targetHostnames, allNodes, "recipes", phase.value()), exitCriteriaModel, maxRetry, exitCriteria);
        Set<String> allHostnames = allNodes.stream().map(Node::getHostname).collect(Collectors.toSet());
        runSyncAll(sc, allHostnames, allNodes, exitCriteriaModel);
        if (phase == PRE_CLOUDERA_MANAGER_START) {
            // Execute highstate before recipe. Otherwise ipa domain names will not be resolvable in recipe scripts.
            runNewService(sc, new HighStateAllRunner(allHostnames, allNodes), exitCriteriaModel, maxRetryRecipe, true);
        } else {
            // Skip highstate and just execute other recipes for performace.
            StateRunner stateAllRunner = new StateRunner(targetHostnames, allNodes, "recipes." + phase.value());
            OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateAllRunner);
            Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitCriteriaModel, maxRetry, false);
            saltJobRunBootstrapRunner.call();
        }
    } catch (CloudbreakOrchestratorTimeoutException e) {
        LOGGER.info("Recipe execution timeout. {}", phase, e);
        throw e;
    } catch (CloudbreakOrchestratorFailedException e) {
        LOGGER.info("Orchestration error occurred during execution of recipes.", e);
        throw e;
    } catch (Exception e) {
        LOGGER.info("Unknown error occurred during execution of recipes.", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    } finally {
        try (SaltConnector sc = saltService.createSaltConnector(gatewayConfig)) {
            // remove 'recipe' grain from all nodes
            Set<String> targetHostnames = allNodes.stream().map(Node::getHostname).collect(Collectors.toSet());
            saltCommandRunner.runSaltCommand(sc, new GrainRemoveRunner(targetHostnames, allNodes, "recipes", phase.value()), exitCriteriaModel, maxRetry, exitCriteria);
        } catch (Exception e) {
            LOGGER.info("Error occurred during removing recipe roles.", e);
            throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
        }
    }
}
Also used : CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) GrainAddRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner) HighStateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateAllRunner) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) ParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner) ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) StateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner) 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) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) GrainRemoveRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 4 with StateRunner

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

the class SaltOrchestrator method updateAgentCertDirectoryPermission.

@Override
public void updateAgentCertDirectoryPermission(GatewayConfig gatewayConfig, Set<String> target, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
    try (SaltConnector sc = saltService.createSaltConnector(gatewayConfig)) {
        StateRunner stateRunner = new StateRunner(target, allNodes, CM_AGENT_CERTDIR_PERMISSION);
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateRunner);
        Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitCriteriaModel);
        saltJobRunBootstrapRunner.call();
    } catch (Exception e) {
        LOGGER.error("Error occurred during CM Agent certdir permission update", e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) ParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner) ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) StateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner) 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)

Example 5 with StateRunner

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

the class SaltOrchestrator method runOrchestratorState.

@Override
public void runOrchestratorState(OrchestratorStateParams stateParams) throws CloudbreakOrchestratorFailedException {
    try (SaltConnector sc = saltService.createSaltConnector(stateParams.getPrimaryGatewayConfig())) {
        StateRunner stateRunner = createStateRunner(stateParams);
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateRunner);
        Optional<OrchestratorStateRetryParams> stateRetryParams = stateParams.getStateRetryParams();
        Callable<Boolean> saltJobRunBootstrapRunner = stateRetryParams.isPresent() ? saltRunner.runner(saltJobIdTracker, exitCriteria, stateParams.getExitCriteriaModel(), stateRetryParams.get()) : saltRunner.runner(saltJobIdTracker, exitCriteria, stateParams.getExitCriteriaModel());
        saltJobRunBootstrapRunner.call();
    } catch (Exception e) {
        LOGGER.error(stateParams.getErrorMessage(), e);
        throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
    }
}
Also used : OrchestratorStateRetryParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateRetryParams) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) ParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner) ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) StateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner) 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)

Aggregations

OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)6 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)6 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)6 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)6 SaltJobIdTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker)6 ConcurrentParameterizedStateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner)6 ParameterizedStateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner)6 StateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner)6 IOException (java.io.IOException)6 ExecutionException (java.util.concurrent.ExecutionException)6 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)5 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)5 CloudbreakOrchestratorTimeoutException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException)5 HighStateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner)5 OrchestratorStateRetryParams (com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateRetryParams)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)1 GrainAddRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner)1 GrainRemoveRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner)1 HighStateAllRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateAllRunner)1