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