Search in sources :

Example 11 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class StackUtilTest method collectAndCheckReachableNodes.

@Test
void collectAndCheckReachableNodes() throws NodesUnreachableException {
    Stack stack = createStack();
    ArrayList<String> necessaryNodes = new ArrayList<>();
    necessaryNodes.add("node1.example.com");
    necessaryNodes.add("node3.example.com");
    Set<Node> nodes = new HashSet<>();
    nodes.add(new Node("1.1.1.1", "1.1.1.1", "1", "m5.xlarge", "node1.example.com", "worker"));
    nodes.add(new Node("1.1.1.3", "1.1.1.3", "3", "m5.xlarge", "node3.example.com", "worker"));
    when(hostOrchestrator.getResponsiveNodes(nodesCaptor.capture(), any())).thenReturn(new NodeReachabilityResult(nodes, Set.of()));
    stackUtil.collectAndCheckReachableNodes(stack, necessaryNodes);
    verify(hostOrchestrator).getResponsiveNodes(nodesCaptor.capture(), any());
    List<String> fqdns = nodesCaptor.getValue().stream().map(Node::getHostname).collect(Collectors.toList());
    assertTrue(fqdns.contains("node1.example.com"));
    assertFalse("Terminated node should be filtered out", fqdns.contains("node2.example.com"));
    assertTrue(fqdns.contains("node3.example.com"));
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 12 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class ClusterManagerUpscaleService method upscaleClusterManager.

public void upscaleClusterManager(Long stackId, Map<String, Integer> hostGroupWithAdjustment, boolean primaryGatewayChanged, boolean repair) throws ClusterClientInitException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    // we need to fetch the cluster with the details, to avoid the unnecessary DB querying later
    Long clusterId = stack.getCluster().getId();
    Cluster cluster = clusterService.findOneWithLists(clusterId).orElseThrow(NotFoundException.notFound("Cluster", clusterId));
    LOGGER.debug("Adding new nodes for host group {}", hostGroupWithAdjustment);
    NodeReachabilityResult nodeReachabilityResult = hostRunner.addClusterServices(stack, cluster, hostGroupWithAdjustment, repair);
    if (primaryGatewayChanged) {
        clusterServiceRunner.updateAmbariClientConfig(stack, cluster);
    }
    clusterService.updateInstancesToRunning(clusterId, nodeReachabilityResult.getReachableNodes());
    clusterService.updateInstancesToZombie(stackId, nodeReachabilityResult.getUnreachableNodes());
    ClusterApi connector = clusterApiConnectors.getConnector(stack);
    ExtendedPollingResult result;
    if (!repair && !primaryGatewayChanged && targetedUpscaleSupportService.targetedUpscaleOperationSupported(stack)) {
        Set<String> reachableHosts = nodeReachabilityResult.getReachableHosts();
        Set<InstanceMetaData> reachableInstances = stack.getNotDeletedAndNotZombieInstanceMetaDataSet().stream().filter(md -> reachableHosts.contains(md.getDiscoveryFQDN())).collect(Collectors.toSet());
        result = connector.waitForHosts(reachableInstances);
    } else {
        result = connector.waitForHosts(stackService.getByIdWithListsInTransaction(stackId).getRunningInstanceMetaDataSet());
    }
    if (result != null && result.isTimeout()) {
        LOGGER.info("Upscaling cluster manager were not successful for nodes: {}", result.getFailedInstanceIds());
        instanceMetaDataService.updateInstanceStatus(result.getFailedInstanceIds(), InstanceStatus.ZOMBIE, "Upscaling cluster manager were not successful.");
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Logger(org.slf4j.Logger) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) LoggerFactory(org.slf4j.LoggerFactory) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) Collectors(java.util.stream.Collectors) ClusterHostServiceRunner(com.sequenceiq.cloudbreak.core.bootstrap.service.host.ClusterHostServiceRunner) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) TargetedUpscaleSupportService(com.sequenceiq.cloudbreak.service.stack.TargetedUpscaleSupportService) Inject(javax.inject.Inject) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Service(org.springframework.stereotype.Service) Map(java.util.Map) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) ClusterServiceRunner(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterServiceRunner) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 13 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult 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);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) GrainProperties(com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties) IOException(java.io.IOException) NodesUnreachableException(com.sequenceiq.cloudbreak.util.NodesUnreachableException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 14 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method runTargetedClusterServices.

public NodeReachabilityResult runTargetedClusterServices(@Nonnull Stack stack, @Nonnull Cluster cluster, Map<String, String> candidateAddresses) {
    try {
        NodeReachabilityResult nodeReachabilityResult = stackUtil.collectReachableAndUnreachableCandidateNodes(stack, candidateAddresses.keySet());
        addGatewaysToCandidatesIfNeeded(stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata(), nodeReachabilityResult);
        Set<Node> reachableCandidates = nodeReachabilityResult.getReachableNodes();
        List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
        List<GrainProperties> grainsProperties = grainPropertiesService.createGrainPropertiesForTargetedUpscale(gatewayConfigs, cluster, reachableCandidates);
        Set<String> reachableCandidateHostNames = nodeReachabilityResult.getReachableHosts();
        LOGGER.debug("We are about to execute cluster services (salt highstate, pre cluster manager recipe execution, mount disks, etc.) " + "for reachable candidates (targeted operation): {}", Joiner.on(",").join(reachableCandidateHostNames));
        executeRunClusterServices(stack, cluster, candidateAddresses, reachableCandidates, reachableCandidates, gatewayConfigs, grainsProperties);
        return nodeReachabilityResult;
    } catch (CloudbreakOrchestratorCancelledException e) {
        throw new CancellationException(e.getMessage());
    } catch (CloudbreakOrchestratorException | IOException | CloudbreakException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) GrainProperties(com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties) IOException(java.io.IOException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

NodeReachabilityResult (com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)9 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)8 Test (org.junit.jupiter.api.Test)6 HashSet (java.util.HashSet)5 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)4 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)4 TemporaryStorage (com.sequenceiq.cloudbreak.common.type.TemporaryStorage)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)3 InstanceMetaDataService (com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService)3 IOException (java.io.IOException)3 Map (java.util.Map)3 Set (java.util.Set)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)2 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)2