use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.
the class TargetedUpscaleSupportService method getActualDnsResolverType.
public DnsResolverType getActualDnsResolverType(Stack stack) {
LOGGER.debug("Original value of domainDnsResolver field for stack {} is {}", stack.getResourceCrn(), stack.getDomainDnsResolver());
if (!isUnboundEliminationSupported(stack.getResourceCrn())) {
LOGGER.debug("Since unbound elimination is not supported, then targeted upscale also won't be supported, " + "thus all 00-cluster.conf will be regenerated for all nodes of stack {}.", stack.getResourceCrn());
return DnsResolverType.LOCAL_UNBOUND;
} else {
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
Set<Node> reachableNodes = stackUtil.collectReachableNodes(stack);
Set<String> reachableHostnames = reachableNodes.stream().map(Node::getHostname).collect(Collectors.toSet());
boolean unboundClusterConfigPresentOnAnyNodes = hostOrchestrator.unboundClusterConfigPresentOnAnyNodes(primaryGatewayConfig, reachableHostnames);
LOGGER.debug("Result of check whether unbound config is present on nodes of stack [{}] is: {}", stack.getResourceCrn(), unboundClusterConfigPresentOnAnyNodes);
if (unboundClusterConfigPresentOnAnyNodes) {
LOGGER.debug("Although unbound elimination is enabled in account, 00-cluster.conf files still present on at least one node, " + "thus we will fall back to use local unbound service on all nodes of stack {}", stack.getResourceCrn());
return DnsResolverType.LOCAL_UNBOUND;
} else {
LOGGER.debug("Unbound elimination is enabled in account and 00-cluster.conf files were removed from all nodes, " + "thus we can use freeIPA of environment {} to resolve DNS within environment's domain for stack {}", stack.getEnvironmentCrn(), stack.getResourceCrn());
return DnsResolverType.FREEIPA_FOR_ENV;
}
}
}
use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.
the class MountDisks method mountDisks.
private void mountDisks(Stack stack, Set<Node> nodesWithDiskData, Set<Node> allNodes) throws CloudbreakException {
Cluster cluster = stack.getCluster();
try {
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
Map<String, Map<String, String>> mountInfo;
if (isCbVersionPostOptimisation(stack)) {
mountInfo = hostOrchestrator.formatAndMountDisksOnNodes(stack, gatewayConfigs, nodesWithDiskData, allNodes, exitCriteriaModel, stack.getPlatformVariant());
} else {
mountInfo = hostOrchestrator.formatAndMountDisksOnNodesLegacy(gatewayConfigs, nodesWithDiskData, allNodes, exitCriteriaModel, stack.getPlatformVariant());
}
mountInfo.forEach((hostname, value) -> {
Optional<String> instanceIdOptional = stack.getInstanceMetaDataAsList().stream().filter(instanceMetaData -> hostname.equals(instanceMetaData.getDiscoveryFQDN())).filter(instanceMetaData -> InstanceStatus.CREATED.equals(instanceMetaData.getInstanceStatus())).map(InstanceMetaData::getInstanceId).findFirst();
if (instanceIdOptional.isPresent()) {
String uuids = value.getOrDefault("uuids", "");
String fstab = value.getOrDefault("fstab", "");
if (!StringUtils.isEmpty(uuids) && !StringUtils.isEmpty(fstab)) {
persistUuidAndFstab(stack, instanceIdOptional.get(), hostname, uuids, fstab);
}
}
});
} catch (CloudbreakOrchestratorFailedException e) {
LOGGER.error("Failed to mount disks", e);
throw new CloudbreakSecuritySetupException(e);
}
}
use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.
the class LoggingAgentAutoRestartPatchService method doApply.
@Override
boolean doApply(Stack stack) throws ExistingStackPatchApplyException {
if (isPrimaryGatewayReachable(stack)) {
try {
byte[] currentSaltState = getCurrentSaltStateStack(stack);
List<String> saltStateDefinitions = Arrays.asList("salt-common", "salt");
List<String> loggingAgentSaltStateDef = List.of("/salt/fluent");
byte[] fluentSaltStateConfig = compressUtil.generateCompressedOutputFromFolders(saltStateDefinitions, loggingAgentSaltStateDef);
boolean loggingAgentContentMatches = compressUtil.compareCompressedContent(currentSaltState, fluentSaltStateConfig, loggingAgentSaltStateDef);
if (!loggingAgentContentMatches) {
Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stack.getId());
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
ClusterDeletionBasedExitCriteriaModel exitModel = ClusterDeletionBasedExitCriteriaModel.nonCancellableModel();
Set<Node> availableNodes = getAvailableNodes(instanceMetaDataSet, gatewayConfigs, exitModel);
if (CollectionUtils.isEmpty(availableNodes)) {
LOGGER.info("Not found any available nodes for patch, stack: " + stack.getName());
return false;
} else {
getTelemetryOrchestrator().executeLoggingAgentDiagnostics(fluentSaltStateConfig, gatewayConfigs, availableNodes, exitModel);
byte[] newFullSaltState = compressUtil.updateCompressedOutputFolders(saltStateDefinitions, loggingAgentSaltStateDef, currentSaltState);
clusterBootstrapper.updateSaltComponent(stack, newFullSaltState);
LOGGER.debug("Logging agent partial salt refresh and diagnostics successfully finished for stack {}", stack.getName());
return true;
}
} else {
LOGGER.debug("Logging agent partial salt refresh and diagnostics is not required for stack {}", stack.getName());
return true;
}
} catch (ExistingStackPatchApplyException e) {
throw e;
} catch (Exception e) {
throw new ExistingStackPatchApplyException(e.getMessage(), e);
}
} else {
LOGGER.info("Salt partial update cannot run, because primary gateway is unreachable of stack: " + stack.getResourceCrn());
return false;
}
}
use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.
the class MeteringAzureMetadataPatchService method upgradeMeteringOnNodes.
private boolean upgradeMeteringOnNodes(Stack stack) throws ExistingStackPatchApplyException, IOException, CloudbreakOrchestratorFailedException {
byte[] currentSaltState = getCurrentSaltStateStack(stack);
List<String> saltStateDefinitions = Arrays.asList("salt-common", "salt");
List<String> meteringSaltStateDef = List.of("/salt/metering");
byte[] meteringSaltStateConfig = compressUtil.generateCompressedOutputFromFolders(saltStateDefinitions, meteringSaltStateDef);
boolean meteringContentMatches = compressUtil.compareCompressedContent(currentSaltState, meteringSaltStateConfig, meteringSaltStateDef);
if (!meteringContentMatches) {
Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stack.getId());
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
ClusterDeletionBasedExitCriteriaModel exitModel = ClusterDeletionBasedExitCriteriaModel.nonCancellableModel();
getTelemetryOrchestrator().updateMeteringSaltDefinition(meteringSaltStateConfig, gatewayConfigs, exitModel);
Set<Node> availableNodes = getAvailableNodes(instanceMetaDataSet, gatewayConfigs, exitModel);
if (CollectionUtils.isEmpty(availableNodes)) {
LOGGER.info("Not found any available nodes for patch, stack: " + stack.getName());
return false;
} else {
getTelemetryOrchestrator().upgradeMetering(gatewayConfigs, availableNodes, exitModel, meteringAzureMetadataPatchConfig.getDateBefore(), meteringAzureMetadataPatchConfig.getCustomRpmUrl());
byte[] newFullSaltState = compressUtil.updateCompressedOutputFolders(saltStateDefinitions, meteringSaltStateDef, currentSaltState);
clusterBootstrapper.updateSaltComponent(stack, newFullSaltState);
LOGGER.debug("Metering partial salt refresh successfully finished for stack {}", stack.getName());
return true;
}
} else {
LOGGER.debug("Metering partial salt refresh is not required for stack {}", stack.getName());
return true;
}
}
use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.
the class SaltCheckerConclusionStepTest method checkShouldFallbackIfNodeStatusCheckFailsAndBeSuccessfulIfNoUnreachableNodeFound.
@Test
public void checkShouldFallbackIfNodeStatusCheckFailsAndBeSuccessfulIfNoUnreachableNodeFound() throws NodesUnreachableException {
when(nodeStatusService.saltPing(eq(1L))).thenThrow(new CloudbreakServiceException("error"));
when(stackService.getByIdWithListsInTransaction(eq(1L))).thenReturn(new Stack());
Set<Node> nodes = Set.of(createNode("host1"), createNode("host2"));
when(stackUtil.collectNodes(any())).thenReturn(nodes);
when(stackUtil.collectAndCheckReachableNodes(any(), anyCollection())).thenReturn(nodes);
Conclusion stepResult = underTest.check(1L);
assertFalse(stepResult.isFailureFound());
assertNull(stepResult.getConclusion());
assertNull(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());
}
Aggregations