Search in sources :

Example 6 with NodeReachabilityResult

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

the class SaltOrchestrator method stopClusterManagerAgent.

@Override
public void stopClusterManagerAgent(OrchestratorAware stack, GatewayConfig gatewayConfig, Set<Node> allNodes, Set<Node> nodesUnderStopping, ExitCriteriaModel exitCriteriaModel, CmAgentStopFlags flags) throws CloudbreakOrchestratorFailedException {
    try (SaltConnector sc = saltService.createSaltConnector(gatewayConfig)) {
        NodeReachabilityResult nodeReachabilityResult = getResponsiveNodes(allNodes, sc);
        Set<Node> responsiveNodes = nodeReachabilityResult.getReachableNodes();
        Set<String> nodesUnderStoppingIPs = nodesUnderStopping.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
        Set<Node> responsiveNodesUnderStopping = responsiveNodes.stream().filter(responsiveNode -> nodesUnderStoppingIPs.contains(responsiveNode.getPrivateIp())).collect(Collectors.toSet());
        if (!responsiveNodesUnderStopping.isEmpty()) {
            LOGGER.debug("Applying role 'cloudera_manager_agent_stop' on nodes: [{}]", responsiveNodesUnderStopping);
            Set<String> targetHostnames = responsiveNodesUnderStopping.stream().map(Node::getHostname).collect(Collectors.toSet());
            saltCommandRunner.runModifyGrainCommand(sc, new GrainAddRunner(targetHostnames, responsiveNodesUnderStopping, "roles", "cloudera_manager_agent_stop"), exitCriteriaModel, exitCriteria);
            if (flags.isAdJoinable() || flags.isIpaJoinable()) {
                String identityRole = flags.isAdJoinable() ? "ad_leave" : "ipa_leave";
                LOGGER.debug("Applying role '{}' on nodes: [{}]", identityRole, responsiveNodesUnderStopping);
                saltCommandRunner.runModifyGrainCommand(sc, new GrainAddRunner(targetHostnames, responsiveNodesUnderStopping, "roles", identityRole), exitCriteriaModel, exitCriteria);
                String removeIdentityRole = flags.isAdJoinable() ? "ad_member" : "ipa_member";
                LOGGER.debug("Removing role '{}' on nodes: [{}]", removeIdentityRole, responsiveNodesUnderStopping);
                saltCommandRunner.runModifyGrainCommand(sc, new GrainRemoveRunner(targetHostnames, responsiveNodesUnderStopping, "roles", removeIdentityRole), exitCriteriaModel, exitCriteria);
            }
            Set<String> allHostnames = responsiveNodesUnderStopping.stream().map(Node::getHostname).collect(Collectors.toSet());
            runSyncAll(sc, allHostnames, responsiveNodesUnderStopping, exitCriteriaModel);
            saveHostsPillar(stack, exitCriteriaModel, getGatewayPrivateIps(Collections.singleton(gatewayConfig)), sc);
            runNewService(sc, new HighStateRunner(allHostnames, responsiveNodesUnderStopping), exitCriteriaModel, maxRetry, true);
            saltCommandRunner.runModifyGrainCommand(sc, new GrainRemoveRunner(targetHostnames, responsiveNodesUnderStopping, "roles", "cloudera_manager_agent_stop"), exitCriteriaModel, exitCriteria);
            if (flags.isAdJoinable() || flags.isIpaJoinable()) {
                String identityRole = flags.isAdJoinable() ? "ad_leave" : "ipa_leave";
                saltCommandRunner.runModifyGrainCommand(sc, new GrainRemoveRunner(targetHostnames, responsiveNodesUnderStopping, "roles", identityRole), exitCriteriaModel, exitCriteria);
            }
        }
    } catch (Exception e) {
        LOGGER.info("Error occurred during executing highstate (for cluster manager agent stop).", e);
        throwExceptionIfNotForced(flags.isForced(), e);
    }
}
Also used : GrainOperation(com.sequenceiq.cloudbreak.orchestrator.host.GrainOperation) FileReaderUtils.readFileFromClasspath(com.sequenceiq.cloudbreak.util.FileReaderUtils.readFileFromClasspath) SaltCommandRunner(com.sequenceiq.cloudbreak.orchestrator.salt.runner.SaltCommandRunner) Target(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Target) SaltBootstrap(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) SyncAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.SyncAllRunner) LoggerFactory(org.slf4j.LoggerFactory) HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) SaltUploadWithPermission(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltUploadWithPermission) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) HighStateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateAllRunner) StringUtils(org.apache.commons.lang3.StringUtils) PillarSave(com.sequenceiq.cloudbreak.orchestrator.salt.poller.PillarSave) BootstrapParams(com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) HostAndRoleTarget(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostAndRoleTarget) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) StateAllRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateAllRunner) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) MineUpdateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.MineUpdateRunner) ModifyGrainBase(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ModifyGrainBase) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Collection(java.util.Collection) Set(java.util.Set) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Retry(com.sequenceiq.cloudbreak.service.Retry) RecipeExecutionPhase.convert(com.sequenceiq.cloudbreak.common.type.RecipeExecutionPhase.convert) Collectors(java.util.stream.Collectors) Backoff(org.springframework.retry.annotation.Backoff) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) GrainRemoveRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner) StandardCharsets(java.nio.charset.StandardCharsets) Sets(com.google.common.collect.Sets) ParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ParameterizedStateRunner) SALT(com.sequenceiq.cloudbreak.common.type.OrchestratorConstants.SALT) List(java.util.List) MinionStatusSaltResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.MinionStatusSaltResponse) SaltStates(com.sequenceiq.cloudbreak.orchestrator.salt.states.SaltStates) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CollectionUtils(org.springframework.util.CollectionUtils) Entry(java.util.Map.Entry) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) NodeVolumes(com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes) Predicate.not(java.util.function.Predicate.not) RecipeExecutionPhase(com.sequenceiq.cloudbreak.common.type.RecipeExecutionPhase) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Joiner(com.google.common.base.Joiner) SaltUpload(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltUpload) OrchestratorGrainRunnerParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorGrainRunnerParams) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) CompressUtil(com.sequenceiq.cloudbreak.util.CompressUtil) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) ArrayList(java.util.ArrayList) RecipeModel(com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) GrainAddRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner) OrchestratorStateRetryParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateRetryParams) CmAgentStopFlags(com.sequenceiq.cloudbreak.orchestrator.model.CmAgentStopFlags) KeytabModel(com.sequenceiq.cloudbreak.orchestrator.model.KeytabModel) OrchestratorStateParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateParams) Retryable(org.springframework.retry.annotation.Retryable) Glob(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Glob) ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) ExitCriteria(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteria) StateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.StateRunner) Logger(org.slf4j.Logger) PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo) OrchestratorAware(com.sequenceiq.cloudbreak.common.orchestration.OrchestratorAware) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) GrainUploader(com.sequenceiq.cloudbreak.orchestrator.salt.grain.GrainUploader) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) IOException(java.io.IOException) PRE_CLOUDERA_MANAGER_START(com.sequenceiq.cloudbreak.common.type.RecipeExecutionPhase.PRE_CLOUDERA_MANAGER_START) ExecutionException(java.util.concurrent.ExecutionException) GrainsJsonPropertyUtil(com.sequenceiq.cloudbreak.orchestrator.salt.utils.GrainsJsonPropertyUtil) HttpStatus(org.springframework.http.HttpStatus) Component(org.springframework.stereotype.Component) BaseSaltJobRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.BaseSaltJobRunner) SaltRunner(com.sequenceiq.cloudbreak.orchestrator.salt.runner.SaltRunner) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Collections(java.util.Collections) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) GrainRemoveRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner) HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) JsonNode(com.fasterxml.jackson.databind.JsonNode) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) GrainAddRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 7 with NodeReachabilityResult

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

the class StackUtil method collectReachableAndUnreachableCandidateNodes.

public NodeReachabilityResult collectReachableAndUnreachableCandidateNodes(Stack stack, Collection<String> necessaryNodes) {
    NodeReachabilityResult nodeReachabilityResult = collectReachableAndUnreachableNodes(stack);
    Set<Node> reachableCandidateNodes = nodeReachabilityResult.getReachableNodes().stream().filter(node -> necessaryNodes.contains(node.getHostname())).collect(Collectors.toSet());
    Set<Node> unreachableCandidateNodes = nodeReachabilityResult.getUnreachableNodes().stream().filter(node -> necessaryNodes.contains(node.getHostname())).collect(Collectors.toSet());
    NodeReachabilityResult nodeReachabilityResultWithCandidates = new NodeReachabilityResult(reachableCandidateNodes, unreachableCandidateNodes);
    if (!unreachableCandidateNodes.isEmpty()) {
        LOGGER.warn("Some candidate nodes are unreachable: {}", nodeReachabilityResultWithCandidates.getUnreachableHosts());
    }
    LOGGER.debug("Candidate node reachability result: {}", nodeReachabilityResultWithCandidates);
    return nodeReachabilityResultWithCandidates;
}
Also used : IntStream(java.util.stream.IntStream) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) LoadBalancerConfigService(com.sequenceiq.cloudbreak.service.LoadBalancerConfigService) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) Resource(com.sequenceiq.cloudbreak.domain.Resource) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) StringUtils(org.apache.commons.lang3.StringUtils) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) Duration(java.time.Duration) Map(java.util.Map) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) CredentialClientService(com.sequenceiq.cloudbreak.service.environment.credential.CredentialClientService) CredentialToCloudCredentialConverter(com.sequenceiq.cloudbreak.converter.spi.CredentialToCloudCredentialConverter) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) AbstractImmutableEntry(com.gs.collections.impl.tuple.AbstractImmutableEntry) ImmutableEntry(com.gs.collections.impl.tuple.ImmutableEntry) CloudVolumeUsageType(com.sequenceiq.cloudbreak.cloud.model.CloudVolumeUsageType) Logger(org.slf4j.Logger) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) ResourceAttributeUtil(com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil) Collection(java.util.Collection) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Collectors(java.util.stream.Collectors) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) List(java.util.List) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) NodeVolumes(com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Volume(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes.Volume) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult)

Example 8 with NodeReachabilityResult

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

the class ClusterHostServiceRunnerTest method testDecoratePillarWithMountInfoAndTargetedSaltCall.

@Test
void testDecoratePillarWithMountInfoAndTargetedSaltCall() throws CloudbreakOrchestratorException {
    setupMocksForRunClusterServices();
    Set<Node> nodes = Sets.newHashSet(node("fqdn3"), node("gateway1"), node("gateway3"));
    when(stackUtil.collectReachableAndUnreachableCandidateNodes(any(), any())).thenReturn(new NodeReachabilityResult(nodes, Set.of()));
    underTest.runTargetedClusterServices(stack, cluster, Map.of("fqdn3", "1.1.1.1"));
    ArgumentCaptor<Set<Node>> reachableCandidates = ArgumentCaptor.forClass(Set.class);
    ArgumentCaptor<SaltConfig> saltConfig = ArgumentCaptor.forClass(SaltConfig.class);
    verify(hostOrchestrator).runService(any(), reachableCandidates.capture(), saltConfig.capture(), any());
    Set<Node> reachableNodes = reachableCandidates.getValue();
    assertTrue(reachableNodes.stream().anyMatch(node -> StringUtils.equals("gateway1", node.getHostname())));
    assertTrue(reachableNodes.stream().anyMatch(node -> StringUtils.equals("gateway2", node.getHostname())));
    assertTrue(reachableNodes.stream().anyMatch(node -> StringUtils.equals("gateway3", node.getHostname())));
    assertTrue(reachableNodes.stream().anyMatch(node -> StringUtils.equals("fqdn3", node.getHostname())));
    assertFalse(reachableNodes.stream().anyMatch(node -> StringUtils.equals("fqdn1", node.getHostname())));
    assertFalse(reachableNodes.stream().anyMatch(node -> StringUtils.equals("fqdn2", node.getHostname())));
    assertTrue(saltConfig.getValue().getServicePillarConfig().keySet().stream().allMatch(Objects::nonNull));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) LoadBalancerSANProvider(com.sequenceiq.cloudbreak.san.LoadBalancerSANProvider) DatalakeService(com.sequenceiq.cloudbreak.service.sharedservice.DatalakeService) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) InstanceGroupService(com.sequenceiq.cloudbreak.service.stack.InstanceGroupService) StringUtils(org.apache.commons.lang3.StringUtils) ClusterPreCreationApi(com.sequenceiq.cloudbreak.cluster.api.ClusterPreCreationApi) KerberosConfigService(com.sequenceiq.cloudbreak.kerberos.KerberosConfigService) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ServiceLocation(com.sequenceiq.cloudbreak.cluster.model.ServiceLocation) Map(java.util.Map) Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) ExposedServiceCollector(com.sequenceiq.cloudbreak.api.service.ExposedServiceCollector) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostAttributeDecorator(com.sequenceiq.cloudbreak.core.bootstrap.service.host.decorator.HostAttributeDecorator) RecipeEngine(com.sequenceiq.cloudbreak.service.cluster.flow.recipe.RecipeEngine) Tunnel(com.sequenceiq.common.api.type.Tunnel) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) DefaultClouderaManagerRepoService(com.sequenceiq.cloudbreak.service.DefaultClouderaManagerRepoService) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Set(java.util.Set) ExposedService(com.sequenceiq.cloudbreak.api.service.ExposedService) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) IdBrokerService(com.sequenceiq.cloudbreak.service.idbroker.IdBrokerService) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) ProxyConfigProvider(com.sequenceiq.cloudbreak.service.proxy.ProxyConfigProvider) List(java.util.List) VirtualGroupService(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupService) RdsConfigWithoutClusterService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigWithoutClusterService) StackUtil(com.sequenceiq.cloudbreak.util.StackUtil) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) Mockito.mock(org.mockito.Mockito.mock) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Strictness(org.mockito.quality.Strictness) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CMLicenseParser(com.sequenceiq.cloudbreak.auth.CMLicenseParser) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) LoadBalancerConfigService(com.sequenceiq.cloudbreak.service.LoadBalancerConfigService) Mock(org.mockito.Mock) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) LdapConfigService(com.sequenceiq.cloudbreak.ldap.LdapConfigService) HashMap(java.util.HashMap) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) Mockito.lenient(org.mockito.Mockito.lenient) Captor(org.mockito.Captor) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) HashSet(java.util.HashSet) CsdParcelDecorator(com.sequenceiq.cloudbreak.core.bootstrap.service.host.decorator.CsdParcelDecorator) KerberosDetailService(com.sequenceiq.cloudbreak.template.kerberos.KerberosDetailService) ArgumentCaptor(org.mockito.ArgumentCaptor) Lists(com.google.common.collect.Lists) UserManagementProto(com.cloudera.thunderhead.service.usermanagement.UserManagementProto) FileReaderUtils(com.sequenceiq.cloudbreak.util.FileReaderUtils) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) RdsConfigWithoutCluster(com.sequenceiq.cloudbreak.domain.view.RdsConfigWithoutCluster) TelemetryDecorator(com.sequenceiq.cloudbreak.core.bootstrap.service.host.decorator.TelemetryDecorator) InjectMocks(org.mockito.InjectMocks) DatabaseType(com.sequenceiq.cloudbreak.api.endpoint.v4.database.base.DatabaseType) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) EnvironmentConfigProvider(com.sequenceiq.cloudbreak.service.environment.EnvironmentConfigProvider) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) IOException(java.io.IOException) PostgresConfigService(com.sequenceiq.cloudbreak.core.bootstrap.service.container.postgres.PostgresConfigService) Mockito.when(org.mockito.Mockito.when) ServiceLocationMap(com.sequenceiq.cloudbreak.cluster.model.ServiceLocationMap) GrpcUmsClient(com.sequenceiq.cloudbreak.auth.altus.GrpcUmsClient) Mockito.verify(org.mockito.Mockito.verify) Template(com.sequenceiq.cloudbreak.domain.Template) MountDisks(com.sequenceiq.cloudbreak.service.stack.flow.MountDisks) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) Assertions(org.junit.jupiter.api.Assertions) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) NodesUnreachableException(com.sequenceiq.cloudbreak.util.NodesUnreachableException) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) Set(java.util.Set) HashSet(java.util.HashSet) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) Test(org.junit.jupiter.api.Test)

Example 9 with NodeReachabilityResult

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

the class StackUtilTest method collectReachableNodesTest.

@Test
void collectReachableNodesTest() {
    Stack stack = createStack();
    Set<Node> nodes = new HashSet<>();
    nodes.add(new Node("1.1.1.1", "1.1.1.1", "1", "m5.xlarge", "node1.example.com", "worker"));
    when(hostOrchestrator.getResponsiveNodes(nodesCaptor.capture(), any())).thenReturn(new NodeReachabilityResult(nodes, Set.of()));
    stackUtil.collectReachableNodes(stack);
    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) 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 10 with NodeReachabilityResult

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

the class StackUtilTest method collectAndCheckReachableNodesButSomeNodeMissing.

@Test
void collectAndCheckReachableNodesButSomeNodeMissing() {
    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"));
    when(hostOrchestrator.getResponsiveNodes(nodesCaptor.capture(), any())).thenReturn(new NodeReachabilityResult(nodes, Set.of()));
    NodesUnreachableException nodesUnreachableException = Assertions.assertThrows(NodesUnreachableException.class, () -> stackUtil.collectAndCheckReachableNodes(stack, necessaryNodes));
    assertEquals(1, nodesUnreachableException.getUnreachableNodes().size());
    assertEquals("node3.example.com", nodesUnreachableException.getUnreachableNodes().iterator().next());
}
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)

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