use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltOrchestrator method runService.
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
@Override
public void runService(List<GatewayConfig> allGateway, Set<Node> allNodes, SaltConfig saltConfig, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorException {
LOGGER.info("Run Services on nodes: {}", allNodes);
GatewayConfig primaryGateway = getPrimaryGatewayConfig(allGateway);
Set<String> gatewayTargets = getGatewayPrivateIps(allGateway);
String ambariServerAddress = primaryGateway.getPrivateAddress();
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
OrchestratorBootstrap hostSave = new PillarSave(sc, gatewayTargets, allNodes);
Callable<Boolean> saltPillarRunner = runner(hostSave, exitCriteria, exitModel);
Future<Boolean> saltPillarRunnerFuture = parallelOrchestratorComponentRunner.submit(saltPillarRunner);
saltPillarRunnerFuture.get();
for (Entry<String, SaltPillarProperties> propertiesEntry : saltConfig.getServicePillarConfig().entrySet()) {
OrchestratorBootstrap pillarSave = new PillarSave(sc, gatewayTargets, propertiesEntry.getValue());
saltPillarRunner = runner(pillarSave, exitCriteria, exitModel);
saltPillarRunnerFuture = parallelOrchestratorComponentRunner.submit(saltPillarRunner);
saltPillarRunnerFuture.get();
}
Set<String> server = Sets.newHashSet(ambariServerAddress);
Set<String> all = allNodes.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
// knox
if (primaryGateway.getKnoxGatewayEnabled()) {
runSaltCommand(sc, new GrainAddRunner(gatewayTargets, allNodes, "gateway"), exitModel);
}
setPostgreRoleIfNeeded(allNodes, saltConfig, exitModel, sc, server);
// ambari server
runSaltCommand(sc, new GrainAddRunner(server, allNodes, "ambari_server_install"), exitModel);
runSaltCommand(sc, new GrainAddRunner(server, allNodes, "ambari_server"), exitModel);
// ambari server standby
Set<String> standbyServers = gatewayTargets.stream().filter(ip -> !server.contains(ip)).collect(Collectors.toSet());
if (!standbyServers.isEmpty()) {
runSaltCommand(sc, new GrainAddRunner(standbyServers, allNodes, "ambari_server_install"), exitModel);
runSaltCommand(sc, new GrainAddRunner(standbyServers, allNodes, "ambari_server_standby"), exitModel);
}
// ambari agent
runSaltCommand(sc, new GrainAddRunner(all, allNodes, "ambari_agent_install"), exitModel);
runSaltCommand(sc, new GrainAddRunner(all, allNodes, "ambari_agent"), exitModel);
// kerberos
if (saltConfig.getServicePillarConfig().containsKey("kerberos")) {
runSaltCommand(sc, new GrainAddRunner(server, allNodes, "kerberos_server_master"), exitModel);
if (!standbyServers.isEmpty()) {
runSaltCommand(sc, new GrainAddRunner(standbyServers, allNodes, "kerberos_server_slave"), exitModel);
}
}
// smartsense
if (configureSmartSense) {
runSaltCommand(sc, new GrainAddRunner(gatewayTargets, allNodes, "smartsense"), exitModel);
runSaltCommand(sc, new GrainAddRunner(all, allNodes, "smartsense_agent_update"), exitModel);
}
uploadGrains(allNodes, saltConfig.getGrainsProperties(), exitModel, sc);
runSaltCommand(sc, new SyncGrainsRunner(all, allNodes), exitModel);
runSaltCommand(sc, new MineUpdateRunner(gatewayTargets, allNodes), exitModel);
runNewService(sc, new HighStateRunner(all, allNodes), exitModel);
} catch (Exception e) {
LOGGER.error("Error occurred during ambari bootstrap", e);
if (e instanceof ExecutionException && e.getCause() instanceof CloudbreakOrchestratorFailedException) {
throw (CloudbreakOrchestratorFailedException) e.getCause();
}
throw new CloudbreakOrchestratorFailedException(e);
}
LOGGER.info("Run services on nodes finished: {}", allNodes);
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltOrchestrator method changePrimaryGateway.
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
@Override
public void changePrimaryGateway(GatewayConfig formerGateway, GatewayConfig newPrimaryGateway, List<GatewayConfig> allGatewayConfigs, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
LOGGER.info("Change primary gateway: {}", formerGateway);
String ambariServerAddress = newPrimaryGateway.getPrivateAddress();
try (SaltConnector sc = new SaltConnector(newPrimaryGateway, restDebug)) {
SaltStates.stopMinions(sc, Collections.singletonMap(formerGateway.getHostname(), formerGateway.getPrivateAddress()));
// change ambari_server_standby role to ambari_server
Set<String> server = Collections.singleton(ambariServerAddress);
runSaltCommand(sc, new GrainAddRunner(server, allNodes, "ambari_server"), exitCriteriaModel);
runSaltCommand(sc, new GrainRemoveRunner(server, allNodes, "roles", "ambari_server_standby", CompoundType.IP), exitCriteriaModel);
// add ambari_server_standby role to the standby servers and remove ambari_server role from them.
Set<String> standByServers = allGatewayConfigs.stream().filter(gwc -> !gwc.getHostname().equals(newPrimaryGateway.getHostname()) && !gwc.getHostname().equals(formerGateway.getHostname())).map(GatewayConfig::getPrivateAddress).collect(Collectors.toSet());
runSaltCommand(sc, new GrainAddRunner(standByServers, allNodes, "ambari_server_standby"), exitCriteriaModel);
runSaltCommand(sc, new GrainRemoveRunner(standByServers, allNodes, "roles", "ambari_server", CompoundType.IP), exitCriteriaModel);
// remove minion key from all remaining gateway nodes
for (GatewayConfig gatewayConfig : allGatewayConfigs) {
if (!gatewayConfig.getHostname().equals(formerGateway.getHostname())) {
try (SaltConnector sc1 = new SaltConnector(gatewayConfig, restDebug)) {
LOGGER.info("Removing minion key '{}' from gateway '{}'", formerGateway.getHostname(), gatewayConfig.getHostname());
sc1.wheel("key.delete", Collections.singleton(formerGateway.getHostname()), Object.class);
} catch (Exception ex) {
LOGGER.error("Unsuccessful key removal from gateway: " + gatewayConfig.getHostname(), ex);
}
}
}
// salt '*' state.highstate
runNewService(sc, new HighStateRunner(server, allNodes), exitCriteriaModel);
} catch (Exception e) {
LOGGER.error("Error occurred during primary gateway change", e);
if (e instanceof ExecutionException && e.getCause() instanceof CloudbreakOrchestratorFailedException) {
throw (CloudbreakOrchestratorFailedException) e.getCause();
}
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltOrchestrator method uploadFileToGateways.
private void uploadFileToGateways(SaltConnector saltConnector, Set<String> targets, ExitCriteriaModel exitCriteriaModel, String path, String fileName, byte[] content) throws CloudbreakOrchestratorFailedException {
try {
OrchestratorBootstrap saltUpload = new SaltUpload(saltConnector, targets, path, fileName, content);
Callable<Boolean> saltUploadRunner = runner(saltUpload, exitCriteria, exitCriteriaModel);
Future<Boolean> saltUploadRunnerFuture = parallelOrchestratorComponentRunner.submit(saltUploadRunner);
saltUploadRunnerFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during file distribute to gateway nodes", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltOrchestrator method uploadRecipes.
@Override
public void uploadRecipes(List<GatewayConfig> allGatewayConfigs, Map<String, List<RecipeModel>> recipes, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorFailedException {
GatewayConfig primaryGateway = allGatewayConfigs.stream().filter(GatewayConfig::isPrimary).findFirst().get();
Set<String> gatewayTargets = getGatewayPrivateIps(allGatewayConfigs);
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
OrchestratorBootstrap scriptPillarSave = new PillarSave(sc, gatewayTargets, recipes);
Callable<Boolean> saltPillarRunner = runner(scriptPillarSave, exitCriteria, exitModel);
Future<Boolean> saltPillarRunnerFuture = parallelOrchestratorComponentRunner.submit(saltPillarRunner);
saltPillarRunnerFuture.get();
for (List<RecipeModel> recipeList : recipes.values()) {
for (RecipeModel model : recipeList) {
uploadRecipe(sc, gatewayTargets, exitModel, model.getName(), model.getScript(), RecipeExecutionPhase.convert(model.getRecipeType()));
}
}
} catch (Exception e) {
LOGGER.error("Error occurred during recipe upload", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class PillarSave method call.
@Override
public Boolean call() throws Exception {
LOGGER.info("Distribute pillar configs to: {}", targets);
if (!targets.isEmpty()) {
GenericResponses responses = sc.pillar(targets, pillar);
Set<String> failedTargets = new HashSet<>();
LOGGER.info("Salt pillar save responses: {}", responses);
for (GenericResponse genericResponse : responses.getResponses()) {
if (genericResponse.getStatusCode() != HttpStatus.OK.value()) {
LOGGER.info("Failed pillar save attempt to: " + genericResponse.getAddress());
String address = genericResponse.getAddress().split(":")[0];
failedTargets.addAll(originalTargets.stream().filter(a -> a.equals(address)).collect(Collectors.toList()));
}
}
targets = failedTargets;
if (!targets.isEmpty()) {
LOGGER.info("Missing nodes for pillar save: {}", targets);
throw new CloudbreakOrchestratorFailedException("There are missing nodes for pillar save: " + targets);
}
}
LOGGER.info("Pillar save has been completed on nodes: {}", originalTargets);
return true;
}
Aggregations