use of com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteria in project cloudbreak by hortonworks.
the class SaltOrchestrator method bootstrapNewNodes.
@Override
public void bootstrapNewNodes(List<GatewayConfig> allGatewayConfigs, Set<Node> targets, Set<Node> allNodes, byte[] stateConfigZip, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorException {
GatewayConfig primaryGateway = getPrimaryGatewayConfig(allGatewayConfigs);
Set<String> gatewayTargets = allGatewayConfigs.stream().filter(gc -> targets.stream().anyMatch(n -> gc.getPrivateAddress().equals(n.getPrivateIp()))).map(GatewayConfig::getPrivateAddress).collect(Collectors.toSet());
try (SaltConnector sc = new SaltConnector(primaryGateway, restDebug)) {
if (!gatewayTargets.isEmpty()) {
uploadSaltConfig(sc, gatewayTargets, stateConfigZip, exitModel);
}
uploadSignKey(sc, primaryGateway, gatewayTargets, targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet()), exitModel);
// if there is a new salt master then re-bootstrap all nodes
Set<Node> nodes = gatewayTargets.isEmpty() ? targets : allNodes;
OrchestratorBootstrap saltBootstrap = new SaltBootstrap(sc, allGatewayConfigs, nodes);
Callable<Boolean> saltBootstrapRunner = runner(saltBootstrap, exitCriteria, exitModel);
Future<Boolean> saltBootstrapRunnerFuture = parallelOrchestratorComponentRunner.submit(saltBootstrapRunner);
saltBootstrapRunnerFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during salt upscale", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteria in project cloudbreak by hortonworks.
the class SaltOrchestratorTest method setUp.
@Before
public void setUp() throws Exception {
gatewayConfig = new GatewayConfig("1.1.1.1", "10.0.0.1", "172.16.252.43", "10-0-0-1", 9443, "servercert", "clientcert", "clientkey", "saltpasswd", "saltbootpassword", "signkey", false, true, null, null);
targets = new HashSet<>();
targets.add(new Node("10.0.0.1", "1.1.1.1", "10-0-0-1.example.com", "hg"));
targets.add(new Node("10.0.0.2", "1.1.1.2", "10-0-0-2.example.com", "hg"));
targets.add(new Node("10.0.0.3", "1.1.1.3", "10-0-0-3.example.com", "hg"));
saltConnector = mock(SaltConnector.class);
whenNew(SaltConnector.class).withAnyArguments().thenReturn(saltConnector);
parallelOrchestratorComponentRunner = mock(ParallelOrchestratorComponentRunner.class);
when(parallelOrchestratorComponentRunner.submit(any())).thenReturn(CompletableFuture.completedFuture(true));
when(hostDiscoveryService.determineDomain("test", "test", false)).thenReturn(".example.com");
exitCriteria = mock(ExitCriteria.class);
exitCriteriaModel = mock(ExitCriteriaModel.class);
}
use of com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteria 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);
}
Aggregations