use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException 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);
}
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException in project cloudbreak by hortonworks.
the class OrchestratorBootstrapRunner method doCall.
private Boolean doCall() throws CloudbreakOrchestratorCancelledException, CloudbreakOrchestratorFailedException, CloudbreakOrchestratorTimeoutException {
Boolean success = null;
int retryCount = 1;
int errorCount = 1;
Exception actualException = null;
String type = orchestratorBootstrap.getClass().getSimpleName().replace("Bootstrap", "");
long initialStartTime = System.currentTimeMillis();
while (success == null && belowAttemptThreshold(retryCount, errorCount)) {
if (isExitNeeded()) {
LOGGER.debug(exitCriteria.exitMessage());
throw new CloudbreakOrchestratorCancelledException(exitCriteria.exitMessage());
}
long startTime = System.currentTimeMillis();
try {
LOGGER.debug("Calling orchestrator bootstrap: {}, additional info: {}", type, orchestratorBootstrap);
orchestratorBootstrap.call();
success = Boolean.TRUE;
String elapsedTimeLog = createElapseTimeLog(initialStartTime, startTime);
LOGGER.debug("Orchestrator component {} successfully started! {}, " + "additional info: {}", type, elapsedTimeLog, orchestratorBootstrap);
} catch (CloudbreakOrchestratorTerminateException te) {
actualException = te;
success = Boolean.FALSE;
String elapsedTimeLog = createElapseTimeLog(initialStartTime, startTime);
LOGGER.info("Failed to execute orchestrator component {}! {}, " + "additional info: {}", type, elapsedTimeLog, orchestratorBootstrap);
} catch (CloudbreakOrchestratorInProgressException ex) {
actualException = ex;
String elapsedTimeLog = createElapseTimeLog(initialStartTime, startTime);
LOGGER.debug("Orchestrator component {} start in progress, retrying [{}/{}] {}, Reason: {}, additional info: {}", type, retryCount, maxRetryCount, elapsedTimeLog, actualException, orchestratorBootstrap);
retryCount++;
if (retryCount <= maxRetryCount) {
trySleeping();
} else {
success = Boolean.FALSE;
}
} catch (Exception ex) {
actualException = ex;
String elapsedTimeLog = createElapseTimeLog(initialStartTime, startTime);
LOGGER.debug("Orchestrator component {} failed to start, retrying [{}/{}], error count [{}/{}]. {}, Reason: {}, additional info: {}", type, retryCount, maxRetryCount, errorCount, maxRetryOnError, elapsedTimeLog, actualException, orchestratorBootstrap, actualException);
retryCount++;
errorCount++;
if (belowAttemptThreshold(retryCount, errorCount)) {
trySleeping();
} else {
success = Boolean.FALSE;
}
}
}
return checkResult(success, retryCount, actualException);
}
Aggregations