Search in sources :

Example 21 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.

the class AmbariClusterResetService method resetCluster.

public void resetCluster(Long stackId) throws CloudbreakOrchestratorException {
    Stack stack = stackRepository.findOneWithLists(stackId);
    try {
        InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
        GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, stack.getCluster().getGateway().getEnableGateway());
        OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
        if (orchestratorType.hostOrchestrator()) {
            HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
            Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
            ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId());
            hostOrchestrator.resetAmbari(gatewayConfig, gatewayFQDN, stackUtil.collectNodes(stack), exitCriteriaModel);
        } else {
            throw new UnsupportedOperationException("ambari reset cluster works only with host orchestrator");
        }
    } catch (CloudbreakException e) {
        throw new CloudbreakOrchestratorFailedException(e);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType) Stack(com.sequenceiq.cloudbreak.domain.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 22 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.

the class AmbariClusterUpgradeService method upgradeCluster.

public void upgradeCluster(Long stackId) throws CloudbreakOrchestratorException {
    Stack stack = stackRepository.findOneWithLists(stackId);
    Cluster cluster = stack.getCluster();
    try {
        OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
        if (orchestratorType.hostOrchestrator()) {
            HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
            InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
            GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.getGateway().getEnableGateway());
            Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
            ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
            AmbariRepo ambariRepo = componentConfigProvider.getAmbariRepo(cluster.getId());
            Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
            Map<String, Object> credentials = new HashMap<>();
            credentials.put("username", ambariSecurityConfigProvider.getAmbariUserName(cluster));
            credentials.put("password", ambariSecurityConfigProvider.getAmbariPassword(cluster));
            servicePillar.put("ambari-credentials", new SaltPillarProperties("/ambari/credentials.sls", singletonMap("ambari", credentials)));
            if (ambariRepo != null) {
                servicePillar.put("ambari-repo", new SaltPillarProperties("/ambari/repo.sls", singletonMap("ambari", singletonMap("repo", ambariRepo))));
            }
            SaltConfig pillar = new SaltConfig(servicePillar);
            hostOrchestrator.upgradeAmbari(gatewayConfig, gatewayFQDN, stackUtil.collectNodes(stack), pillar, exitCriteriaModel);
        } else {
            throw new UnsupportedOperationException("Ambari upgrade works only with host orchestrator");
        }
    } catch (CloudbreakException e) {
        throw new CloudbreakOrchestratorFailedException(e);
    }
}
Also used : ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) HashMap(java.util.HashMap) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 23 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.

the class ClusterBootstrapperErrorHandlerTest method clusterBootstrapErrorHandlerWhenNodeCountLessThanOneAfterTheRollbackThenClusterProvisionFailed.

@Test
public void clusterBootstrapErrorHandlerWhenNodeCountLessThanOneAfterTheRollbackThenClusterProvisionFailed() throws CloudbreakOrchestratorFailedException {
    Stack stack = TestUtil.stack();
    doNothing().when(eventService).fireCloudbreakEvent(anyLong(), anyString(), anyString());
    when(orchestrator.getAvailableNodes(any(GatewayConfig.class), anySet())).thenReturn(new ArrayList<>());
    when(instanceGroupRepository.save(any(InstanceGroup.class))).then(returnsFirstArg());
    when(instanceMetaDataRepository.save(any(InstanceMetaData.class))).then(returnsFirstArg());
    when(instanceMetaDataRepository.findNotTerminatedByPrivateAddress(anyLong(), anyString())).thenAnswer((Answer<InstanceMetaData>) invocation -> {
        Object[] args = invocation.getArguments();
        String ip = (String) args[1];
        for (InstanceMetaData instanceMetaData : stack.getRunningInstanceMetaData()) {
            if (instanceMetaData.getPrivateIp().equals(ip)) {
                return instanceMetaData;
            }
        }
        return null;
    });
    when(instanceGroupRepository.findOneByGroupNameInStack(anyLong(), anyString())).thenAnswer((Answer<InstanceGroup>) invocation -> {
        Object[] args = invocation.getArguments();
        String name = (String) args[1];
        for (InstanceMetaData instanceMetaData : stack.getRunningInstanceMetaData()) {
            if (instanceMetaData.getInstanceGroup().getGroupName().equals(name)) {
                return instanceMetaData.getInstanceGroup();
            }
        }
        return null;
    });
    when(cloudbreakMessagesService.getMessage(eq("bootstrapper.error.invalide.nodecount"), any())).thenReturn("invalide.nodecount");
    thrown.expect(CloudbreakOrchestratorFailedException.class);
    thrown.expectMessage("invalide.nodecount");
    underTest.terminateFailedNodes(null, orchestrator, TestUtil.stack(), new GatewayConfig("10.0.0.1", "198.0.0.1", "10.0.0.1", 8443, false), prepareNodes(stack));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Resource(com.sequenceiq.cloudbreak.domain.Resource) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) ResourceRepository(com.sequenceiq.cloudbreak.repository.ResourceRepository) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ServiceProviderConnectorAdapter(com.sequenceiq.cloudbreak.service.stack.connector.adapter.ServiceProviderConnectorAdapter) Matchers.anySet(org.mockito.Matchers.anySet) Matchers.anyString(org.mockito.Matchers.anyString) ArrayList(java.util.ArrayList) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) CloudbreakMessagesService(com.sequenceiq.cloudbreak.service.messages.CloudbreakMessagesService) HashSet(java.util.HashSet) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Matchers.eq(org.mockito.Matchers.eq) Matchers.anyLong(org.mockito.Matchers.anyLong) Stack(com.sequenceiq.cloudbreak.domain.Stack) ExpectedException(org.junit.rules.ExpectedException) InjectMocks(org.mockito.InjectMocks) HostMetadataRepository(com.sequenceiq.cloudbreak.repository.HostMetadataRepository) ServiceProviderMetadataAdapter(com.sequenceiq.cloudbreak.service.stack.connector.adapter.ServiceProviderMetadataAdapter) ResourceType(com.sequenceiq.cloudbreak.common.type.ResourceType) ContainerOrchestrator(com.sequenceiq.cloudbreak.orchestrator.container.ContainerOrchestrator) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) InstanceGroupRepository(com.sequenceiq.cloudbreak.repository.InstanceGroupRepository) Set(java.util.Set) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) AdditionalAnswers.returnsFirstArg(org.mockito.AdditionalAnswers.returnsFirstArg) Matchers.any(org.mockito.Matchers.any) Rule(org.junit.Rule) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) CloudbreakEventService(com.sequenceiq.cloudbreak.service.events.CloudbreakEventService) Matchers.anyString(org.mockito.Matchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 24 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method decoratePillarWithAmbariDatabase.

private void decoratePillarWithAmbariDatabase(Cluster cluster, Map<String, SaltPillarProperties> servicePillar) throws CloudbreakOrchestratorFailedException {
    RDSConfig ambariRdsConfig = rdsConfigService.findByClusterIdAndType(cluster.getOwner(), cluster.getAccount(), cluster.getId(), RdsType.AMBARI);
    if (ambariRdsConfig == null) {
        throw new CloudbreakOrchestratorFailedException("Ambari RDSConfig is missing for stack");
    }
    RdsView ambariRdsView = new RdsView(ambariRdsConfig);
    servicePillar.put("ambari-database", new SaltPillarProperties("/ambari/database.sls", singletonMap("ambari", singletonMap("database", ambariRdsView))));
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) RdsView(com.sequenceiq.cloudbreak.blueprint.template.views.RdsView) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 25 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.

the class OrchestratorRecipeExecutor method postInstall.

public void postInstall(Stack stack) throws CloudbreakException {
    HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
    GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
    try {
        hostOrchestrator.postInstallRecipes(gatewayConfig, collectNodes(stack), clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
    } catch (CloudbreakOrchestratorFailedException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)39 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)14 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)14 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)12 ExecutionException (java.util.concurrent.ExecutionException)12 IOException (java.io.IOException)11 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)10 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)9 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)9 HashSet (java.util.HashSet)9 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)7 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)6 GrainAddRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner)6 GrainRemoveRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner)6 HighStateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner)6 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)5 RecipeModel (com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel)5