use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method preTerminationRecipesOnNodes.
public void preTerminationRecipesOnNodes(Stack stack, Set<Node> nodes) throws CloudbreakException {
if (stack.getCluster() == null) {
throw new NotFoundException("Cluster does not found, pre-termination will not be run.");
}
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
try {
hostOrchestrator.preTerminationRecipes(gatewayConfig, nodes, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltCommandTrackerTest method callHasTargetNodesTest.
@Test
public void callHasTargetNodesTest() throws Exception {
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
SaltJobRunner saltJobRunner = Mockito.mock(SaltJobRunner.class);
Set<String> targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
when(saltJobRunner.getTarget()).thenReturn(targets);
SaltCommandTracker saltCommandTracker = new SaltCommandTracker(saltConnector, saltJobRunner);
try {
saltCommandTracker.call();
fail("shoud throw exception");
} catch (CloudbreakOrchestratorFailedException e) {
for (String target : targets) {
assertTrue(e.getMessage().contains(target));
}
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltJobIdTrackerTest method callWithFailed.
@Test
public void callWithFailed() throws Exception {
String jobId = "1";
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
PowerMockito.mockStatic(SaltStates.class);
PowerMockito.when(SaltStates.jobIsRunning(any(), any())).thenReturn(true);
SaltJobRunner saltJobRunner = Mockito.mock(BaseSaltJobRunner.class);
when(saltJobRunner.getJid()).thenReturn(JobId.jobId(jobId));
when(saltJobRunner.getJobState()).thenCallRealMethod();
doCallRealMethod().when(saltJobRunner).setJobState(any());
when(saltJobRunner.submit(any(SaltConnector.class))).thenReturn(jobId);
saltJobRunner.setJobState(JobState.FAILED);
SaltJobIdTracker saltJobIdTracker = new SaltJobIdTracker(saltConnector, saltJobRunner);
try {
saltJobIdTracker.call();
fail("should throw exception");
} catch (CloudbreakOrchestratorFailedException e) {
assertThat(e.getMessage(), both(containsString("jobId='" + jobId + '\'')).and(containsString("is running")));
}
PowerMockito.verifyStatic();
SaltStates.jobIsRunning(any(), eq(jobId));
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltOrchestrator method resetAmbari.
@Override
public void resetAmbari(GatewayConfig gatewayConfig, Set<String> target, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
try (SaltConnector saltConnector = new SaltConnector(gatewayConfig, restDebug)) {
BaseSaltJobRunner baseSaltJobRunner = new BaseSaltJobRunner(target, allNodes) {
@Override
public String submit(SaltConnector saltConnector) {
return SaltStates.ambariReset(saltConnector, new Compound(getTarget(), CompoundType.HOST));
}
};
OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(saltConnector, baseSaltJobRunner);
Callable<Boolean> saltJobRunBootstrapRunner = runner(saltJobIdTracker, exitCriteria, exitCriteriaModel);
Future<Boolean> saltJobRunBootstrapFuture = parallelOrchestratorComponentRunner.submit(saltJobRunBootstrapRunner);
saltJobRunBootstrapFuture.get();
} catch (Exception e) {
LOGGER.error("Error occurred during reset", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.
the class SaltOrchestrator method upgradeAmbari.
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
@Override
public void upgradeAmbari(GatewayConfig gatewayConfig, Set<String> target, Set<Node> allNodes, SaltConfig pillarConfig, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
try (SaltConnector sc = new SaltConnector(gatewayConfig, restDebug)) {
for (Entry<String, SaltPillarProperties> propertiesEntry : pillarConfig.getServicePillarConfig().entrySet()) {
OrchestratorBootstrap pillarSave = new PillarSave(sc, Sets.newHashSet(gatewayConfig.getPrivateAddress()), propertiesEntry.getValue());
Callable<Boolean> saltPillarRunner = runner(pillarSave, exitCriteria, exitCriteriaModel);
Future<Boolean> saltPillarRunnerFuture = parallelOrchestratorComponentRunner.submit(saltPillarRunner);
saltPillarRunnerFuture.get();
}
// add 'ambari_upgrade' role to all nodes
Set<String> targets = allNodes.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
runSaltCommand(sc, new GrainAddRunner(targets, allNodes, "roles", "ambari_upgrade", CompoundType.IP), exitCriteriaModel);
Set<String> all = allNodes.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
runSaltCommand(sc, new SyncGrainsRunner(all, allNodes), exitCriteriaModel);
runNewService(sc, new HighStateRunner(all, allNodes), exitCriteriaModel, maxRetryRecipe, true);
// remove 'ambari_upgrade' role from all nodes
targets = allNodes.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
runSaltCommand(sc, new GrainRemoveRunner(targets, allNodes, "roles", "ambari_upgrade", CompoundType.IP), exitCriteriaModel);
} catch (Exception e) {
LOGGER.error("Error occurred during ambari upgrade", e);
throw new CloudbreakOrchestratorFailedException(e);
}
}
Aggregations