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));
}
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);
}
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);
}
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)));
}
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);
}
}
Aggregations