use of com.sequenceiq.cloudbreak.util.NodesUnreachableException in project cloudbreak by hortonworks.
the class SaltCheckerConclusionStep method checkUnreachableNodes.
private Conclusion checkUnreachableNodes(Long resourceId) {
Stack stack = stackService.getByIdWithListsInTransaction(resourceId);
Set<String> allNodes = stackUtil.collectNodes(stack).stream().map(Node::getHostname).collect(Collectors.toSet());
try {
stackUtil.collectAndCheckReachableNodes(stack, allNodes);
} catch (NodesUnreachableException e) {
Set<String> unreachableNodes = e.getUnreachableNodes();
String conclusion = String.format("Unreachable nodes: %s. We detected that cluster members can’t communicate with each other. " + "Please validate if all cluster members are available and healthy through your cloud provider.", unreachableNodes);
String details = String.format("Unreachable salt minions: %s", unreachableNodes);
LOGGER.warn(details);
return failed(conclusion, details);
}
return succeeded();
}
use of com.sequenceiq.cloudbreak.util.NodesUnreachableException in project cloudbreak by hortonworks.
the class ClusterHostServiceRunnerTest method collectAndCheckReachableNodesThrowsException.
@Test
void collectAndCheckReachableNodesThrowsException() throws NodesUnreachableException {
Set<String> unreachableNodes = new HashSet<>();
unreachableNodes.add("node1.example.com");
when(stackUtil.collectAndCheckReachableNodes(eq(stack), any())).thenThrow(new NodesUnreachableException("error", unreachableNodes));
CloudbreakServiceException cloudbreakServiceException = Assertions.assertThrows(CloudbreakServiceException.class, () -> underTest.runClusterServices(stack, cluster, Map.of()));
assertEquals("Can not run cluster services on new nodes because the configuration management service is not responding on these nodes: " + "[node1.example.com]", cloudbreakServiceException.getMessage());
}
use of com.sequenceiq.cloudbreak.util.NodesUnreachableException in project cloudbreak by hortonworks.
the class SaltCheckerConclusionStepTest method checkShouldFallbackForOldImageVersionsAndReturnConclusionIfUnreachableNodeFound.
@Test
public void checkShouldFallbackForOldImageVersionsAndReturnConclusionIfUnreachableNodeFound() throws NodesUnreachableException {
RPCResponse<SaltHealthReport> response = new RPCResponse<>();
RPCMessage message = new RPCMessage();
message.setMessage("rpc response");
response.setMessages(List.of(message));
when(nodeStatusService.saltPing(eq(1L))).thenReturn(response);
when(stackService.getByIdWithListsInTransaction(eq(1L))).thenReturn(new Stack());
when(stackUtil.collectNodes(any())).thenReturn(Set.of(createNode("host1"), createNode("host2")));
when(stackUtil.collectAndCheckReachableNodes(any(), anyCollection())).thenThrow(new NodesUnreachableException("error", Set.of("host1")));
Conclusion stepResult = underTest.check(1L);
assertTrue(stepResult.isFailureFound());
assertEquals("Unreachable nodes: [host1]. We detected that cluster members can’t communicate with each other. " + "Please validate if all cluster members are available and healthy through your cloud provider.", stepResult.getConclusion());
assertEquals("Unreachable salt minions: [host1]", stepResult.getDetails());
assertEquals(SaltCheckerConclusionStep.class, stepResult.getConclusionStepClass());
verify(nodeStatusService, times(1)).saltPing(eq(1L));
verify(stackService, times(1)).getByIdWithListsInTransaction(eq(1L));
verify(stackUtil, times(1)).collectNodes(any());
verify(stackUtil, times(1)).collectAndCheckReachableNodes(any(), any());
}
use of com.sequenceiq.cloudbreak.util.NodesUnreachableException in project cloudbreak by hortonworks.
the class ClusterManagerUpgradeService method upgradeClusterManager.
private void upgradeClusterManager(Stack stack) throws CloudbreakOrchestratorException {
Cluster cluster = stack.getCluster();
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
GatewayConfig primaryGatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.getGateway() != null);
Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
SaltConfig pillar = createSaltConfig(stack, cluster.getId(), primaryGatewayConfig);
Set<String> allNode = stackUtil.collectNodes(stack).stream().map(Node::getHostname).collect(Collectors.toSet());
try {
Set<Node> reachableNodes = stackUtil.collectAndCheckReachableNodes(stack, allNode);
hostOrchestrator.upgradeClusterManager(primaryGatewayConfig, gatewayFQDN, reachableNodes, pillar, exitCriteriaModel);
} catch (NodesUnreachableException e) {
String errorMessage = "Can not upgrade cluster manager because the configuration management service is not responding on these nodes: " + e.getUnreachableNodes();
LOGGER.error(errorMessage);
throw new CloudbreakRuntimeException(errorMessage, e);
}
}
use of com.sequenceiq.cloudbreak.util.NodesUnreachableException in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method runClusterServices.
public NodeReachabilityResult runClusterServices(@Nonnull Stack stack, @Nonnull Cluster cluster, Map<String, String> candidateAddresses) {
try {
Set<Node> allNodes = stackUtil.collectNodes(stack);
Set<Node> reachableNodes = stackUtil.collectAndCheckReachableNodes(stack, candidateAddresses.keySet());
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
List<GrainProperties> grainsProperties = grainPropertiesService.createGrainProperties(gatewayConfigs, cluster, reachableNodes);
executeRunClusterServices(stack, cluster, candidateAddresses, allNodes, reachableNodes, gatewayConfigs, grainsProperties);
return new NodeReachabilityResult(reachableNodes, Set.of());
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException | CloudbreakException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
} catch (NodesUnreachableException e) {
String errorMessage = "Can not run cluster services on new nodes because the configuration management service is not responding on these nodes: " + e.getUnreachableNodes();
LOGGER.error(errorMessage);
throw new CloudbreakServiceException(errorMessage, e);
}
}
Aggregations