Search in sources :

Example 11 with OrchestratorType

use of com.sequenceiq.cloudbreak.common.model.OrchestratorType in project cloudbreak by hortonworks.

the class ClusterCreationService method handleClusterCreationFailure.

public void handleClusterCreationFailure(StackView stackView, Exception exception) {
    if (stackView.getClusterView() != null) {
        Cluster cluster = clusterService.getById(stackView.getClusterView().getId());
        clusterService.cleanupKerberosCredential(cluster);
        String errorMessage = exception instanceof CloudbreakException && exception.getCause() != null ? exception.getCause().getMessage() : exception.getMessage();
        clusterService.updateClusterStatusByStackId(stackView.getId(), CREATE_FAILED, errorMessage);
        stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.AVAILABLE);
        flowMessageService.fireEventAndLog(stackView.getId(), Msg.AMBARI_CLUSTER_CREATE_FAILED, CREATE_FAILED.name(), errorMessage);
        try {
            OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stackView.getOrchestrator().getType());
            if (cluster != null && orchestratorType.containerOrchestrator()) {
                clusterTerminationService.deleteClusterContainers(cluster);
            }
        } catch (CloudbreakException | TerminationFailedException ex) {
            LOGGER.error("Cluster containers could not be deleted, preparation for reinstall failed: ", ex);
        }
        if (cluster != null && cluster.getEmailNeeded()) {
            emailSenderService.sendProvisioningFailureEmail(cluster.getOwner(), stackView.getClusterView().getEmailTo(), cluster.getName());
            flowMessageService.fireEventAndLog(stackView.getId(), Msg.AMBARI_CLUSTER_NOTIFICATION_EMAIL, AVAILABLE.name());
        }
    } else {
        LOGGER.error("Cluster was null. Flow action was not required.");
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) TerminationFailedException(com.sequenceiq.cloudbreak.service.stack.flow.TerminationFailedException) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType)

Aggregations

OrchestratorType (com.sequenceiq.cloudbreak.common.model.OrchestratorType)11 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)10 Stack (com.sequenceiq.cloudbreak.domain.Stack)8 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)7 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)5 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)4 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)4 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 HashMap (java.util.HashMap)3 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)2 ContainerOrchestratorResolver (com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerOrchestratorResolver)2 HostOrchestratorResolver (com.sequenceiq.cloudbreak.core.bootstrap.service.host.HostOrchestratorResolver)2 Container (com.sequenceiq.cloudbreak.domain.Container)2 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)2 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)2 ExitCriteriaModel (com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel)2 TerminationFailedException (com.sequenceiq.cloudbreak.service.stack.flow.TerminationFailedException)2 HashSet (java.util.HashSet)2