Search in sources :

Example 81 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class UpgradeCcmOrchestratorServiceTest method setUp.

@BeforeEach
void setUp() {
    node1 = new Node("privateIP1", "publicIP1", "instance1", "instanceType1", "fqdn1", "hostgroup");
    node2 = new Node("privateIP2", "publicIP2", "instance2", "instanceType2", "fqdn2", "hostgroup");
    when(stack.getId()).thenReturn(STACK_ID);
    when(stack.getCluster()).thenReturn(cluster);
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
    when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
    when(stackUtil.collectGatewayNodes(any())).thenReturn(Set.of(node1, node2));
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 82 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class LoggingAgentAutoRestartPatchServiceTest method testDoApplyWithoutResponsiveNodes.

@Test
public void testDoApplyWithoutResponsiveNodes() throws ExistingStackPatchApplyException, IOException, CloudbreakOrchestratorFailedException {
    // GIVEN
    byte[] currentSaltState = "[current_state]".getBytes(StandardCharsets.UTF_8);
    byte[] fluentConfig = "[fluent_state]".getBytes(StandardCharsets.UTF_8);
    InstanceMetaData instanceMetaData = createInstanceMetaData();
    InstanceGroup instanceGroup = createInstanceGroup();
    instanceMetaData.setInstanceGroup(instanceGroup);
    Set<InstanceMetaData> instanceMetaDataSet = Set.of(instanceMetaData);
    given(instanceMetaDataService.findNotTerminatedAndNotZombieForStack(anyLong())).willReturn(instanceMetaDataSet);
    given(telemetryOrchestrator.collectUnresponsiveNodes(any(), any(), any())).willReturn(Set.of(new Node(null, null, null, null)));
    given(clusterComponentConfigProvider.getSaltStateComponent(anyLong())).willReturn(currentSaltState);
    given(compressUtil.generateCompressedOutputFromFolders(any(), any())).willReturn(fluentConfig);
    given(compressUtil.compareCompressedContent(any(), any(), any())).willReturn(false);
    // WHEN
    boolean result = underTest.doApply(createStack());
    // THEN
    assertFalse(result);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 83 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class MeteringAzureMetadataPatchServiceTest method testDoApplyWithoutResponsiveNodes.

@Test
public void testDoApplyWithoutResponsiveNodes() throws ExistingStackPatchApplyException, IOException, CloudbreakOrchestratorFailedException {
    // GIVEN
    byte[] currentSaltState = "[current_state]".getBytes(StandardCharsets.UTF_8);
    byte[] meteringConfig = "[metering_state]".getBytes(StandardCharsets.UTF_8);
    InstanceMetaData instanceMetaData = createInstanceMetaData();
    InstanceGroup instanceGroup = createInstanceGroup();
    instanceMetaData.setInstanceGroup(instanceGroup);
    Set<InstanceMetaData> instanceMetaDataSet = Set.of(instanceMetaData);
    given(instanceMetaDataService.findNotTerminatedAndNotZombieForStack(anyLong())).willReturn(instanceMetaDataSet);
    given(telemetryOrchestrator.collectUnresponsiveNodes(any(), any(), any())).willReturn(Set.of(new Node(null, null, null, null)));
    given(clusterComponentConfigProvider.getSaltStateComponent(anyLong())).willReturn(currentSaltState);
    given(compressUtil.generateCompressedOutputFromFolders(any(), any())).willReturn(meteringConfig);
    given(compressUtil.compareCompressedContent(any(), any(), any())).willReturn(false);
    // WHEN
    boolean result = underTest.doApply(createStack());
    // THEN
    assertFalse(result);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 84 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class HostAttributeDecorator method createHostAttributePillars.

public Map<String, SaltPillarProperties> createHostAttributePillars(Stack stack) {
    Set<Node> allNodes = stackUtil.collectNodes(stack);
    stack.getCluster().getBlueprint().getBlueprintText();
    BlueprintTextProcessor blueprintTextProcessor = cmTemplateProcessorFactory.get(stack.getCluster().getBlueprint().getBlueprintText());
    Versioned blueprintVersion = () -> blueprintTextProcessor.getVersion().get();
    Map<String, Map<String, ServiceAttributes>> serviceAttributes = blueprintTextProcessor.getHostGroupBasedServiceAttributes(blueprintVersion);
    Map<String, Map<String, Object>> attributes = new HashMap<>();
    for (Node node : allNodes) {
        Map<String, Map<String, String>> hgAttributes = getAttributesForHostGroup(node.getHostGroup(), serviceAttributes);
        Map<String, Object> hostAttributes = new HashMap<>();
        hostAttributes.put("attributes", hgAttributes);
        if (node.getHostGroup() != null) {
            hostAttributes.put("hostGroup", node.getHostGroup());
        }
        attributes.put(node.getHostname(), hostAttributes);
    }
    return Map.of("hostattrs", new SaltPillarProperties("/nodes/hostattrs.sls", singletonMap("hostattrs", attributes)));
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) HashMap(java.util.HashMap) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap)

Example 85 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node 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);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) CloudbreakRuntimeException(com.sequenceiq.cloudbreak.service.CloudbreakRuntimeException) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) NodesUnreachableException(com.sequenceiq.cloudbreak.util.NodesUnreachableException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

Node (com.sequenceiq.cloudbreak.common.orchestration.Node)126 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)57 HashSet (java.util.HashSet)42 Map (java.util.Map)32 JsonNode (com.fasterxml.jackson.databind.JsonNode)30 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)29 Test (org.junit.Test)29 HashMap (java.util.HashMap)28 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)27 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)26 ArrayList (java.util.ArrayList)26 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)25 ExitCriteriaModel (com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel)25 Set (java.util.Set)25 Test (org.junit.jupiter.api.Test)25 List (java.util.List)22 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)21 IOException (java.io.IOException)21 Collectors (java.util.stream.Collectors)21 BootstrapParams (com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams)19