Search in sources :

Example 1 with CloudStorageConfigurationFailedException

use of com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerSetupService method installCluster.

@Override
public void installCluster(String template) {
    Cluster cluster = stack.getCluster();
    try {
        Optional<ApiCluster> cmCluster = getCmClusterByName(cluster.getName());
        boolean prewarmed = isPrewarmed(cluster.getId());
        Optional<ClusterCommand> importCommand = clusterCommandRepository.findTopByClusterIdAndClusterCommandType(cluster.getId(), ClusterCommandType.IMPORT_CLUSTER);
        if (cmCluster.isEmpty() || importCommand.isEmpty()) {
            ApiClusterTemplate apiClusterTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class);
            cluster.setExtendedBlueprintText(getExtendedBlueprintText(apiClusterTemplate));
            ClouderaManagerResourceApi clouderaManagerResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient);
            LOGGER.info("Generated Cloudera cluster template: {}", AnonymizerUtil.anonymize(template));
            // addRepositories - if true the parcels repositories in the cluster template
            // will be added.
            ApiCommand apiCommand = clouderaManagerResourceApi.importClusterTemplate(calculateAddRepositories(apiClusterTemplate, prewarmed), apiClusterTemplate);
            ClusterCommand clusterCommand = new ClusterCommand();
            clusterCommand.setClusterId(cluster.getId());
            clusterCommand.setCommandId(apiCommand.getId());
            clusterCommand.setClusterCommandType(ClusterCommandType.IMPORT_CLUSTER);
            importCommand = Optional.of(clusterCommandRepository.save(clusterCommand));
            LOGGER.debug("Cloudera cluster template has been submitted, cluster install is in progress");
        }
        importCommand.ifPresent(cmd -> clouderaManagerPollingServiceProvider.startPollingCmTemplateInstallation(stack, apiClient, cmd.getCommandId()));
    } catch (ApiException e) {
        String msg = "Installation of CDP with Cloudera Manager has failed: " + extractMessage(e);
        throw new ClouderaManagerOperationFailedException(msg, e);
    } catch (CloudStorageConfigurationFailedException e) {
        LOGGER.info("Error while configuring cloud storage. Message: {}", e.getMessage(), e);
        throw new ClouderaManagerOperationFailedException(mapStorageError(e, stack.getResourceCrn(), stack.cloudPlatform(), cluster), e);
    } catch (Exception e) {
        throw mapException(e);
    }
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiException(com.cloudera.api.swagger.client.ApiException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ClusterCommand(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterCommand) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) ApiException(com.cloudera.api.swagger.client.ApiException)

Example 2 with CloudStorageConfigurationFailedException

use of com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerStorageErrorMapperTest method mapTestWhenRaz.

@ParameterizedTest(name = "{0}")
@MethodSource("mapTestWhenRazDataProvider")
void mapTestWhenRaz(String testCaseName, String message, String expectedResult) {
    exception = new CloudStorageConfigurationFailedException(message);
    cluster.setRangerRazEnabled(true);
    String result = underTest.map(exception, CloudPlatform.AWS.name(), cluster);
    assertThat(result).isEqualTo(expectedResult);
}
Also used : CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with CloudStorageConfigurationFailedException

use of com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerStorageErrorMapperTest method setUp.

@BeforeEach
void setUp() {
    underTest = new ClouderaManagerStorageErrorMapper();
    exception = new CloudStorageConfigurationFailedException(EXCEPTION_MESSAGE);
    cluster = new Cluster();
    fileSystem = new FileSystem();
    cloudStorage = new CloudStorage();
    cloudIdentity = new CloudIdentity();
    cloudIdentity.setIdentityType(CloudIdentityType.ID_BROKER);
    cloudStorage.setCloudIdentities(List.of(cloudIdentity));
    accountMapping = new AccountMapping();
    accountMapping.setUserMappings(Map.ofEntries(entry("hive", "myDataAccessRole"), entry("solr", "myRangerAuditRole")));
    cloudStorage.setAccountMapping(accountMapping);
    StorageLocation locationRangerAudit = new StorageLocation();
    locationRangerAudit.setType(CloudStorageCdpService.RANGER_AUDIT);
    locationRangerAudit.setValue("myRangerAuditLocation");
    cloudStorage.setLocations(List.of(locationRangerAudit));
    fileSystem.setCloudStorage(cloudStorage);
    cluster.setFileSystem(fileSystem);
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) CloudIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) AccountMapping(com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with CloudStorageConfigurationFailedException

use of com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerTemplateInstallationCheckerTest method testCloudStorageFailure.

@Test
void testCloudStorageFailure() throws ApiException {
    ApiCommand auditDirCmd = auditDirCmd().success(Boolean.FALSE).resultMessage("Aborted");
    ApiCommand deployParcelsCmd = deployParcelsCmd().success(Boolean.FALSE).resultMessage("Host not found");
    ApiCommand firstRunCmd = firstRunCmd().success(Boolean.FALSE).resultMessage("Failed to perform First Run of services.");
    ApiCommand templateInstallCmd = templateInstallCmd(auditDirCmd, deployParcelsCmd, firstRunCmd).resultMessage("Failed to import cluster template");
    expectReadCommandForFailedCommands(templateInstallCmd);
    CloudStorageConfigurationFailedException ex = assertThrows(CloudStorageConfigurationFailedException.class, () -> underTest.checkStatus(pollerObject));
    String expected = expectMessageForCommands(auditDirCmd, deployParcelsCmd, firstRunCmd);
    assertEquals(expected, ex.getMessage());
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException) Test(org.junit.jupiter.api.Test)

Example 5 with CloudStorageConfigurationFailedException

use of com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException in project cloudbreak by hortonworks.

the class ClouderaManagerTemplateInstallationChecker method fail.

private void fail(String messagePrefix, ApiCommand apiCommand, CommandsResourceApi commandsResourceApi, StackType stackType) {
    List<CommandDetails> failedCommands = ClouderaManagerCommandUtil.getFailedOrActiveCommands(apiCommand, commandsResourceApi);
    String msg = messagePrefix + "Installation of CDP with Cloudera Manager has failed. " + CommandDetailsFormatter.formatFailedCommands(failedCommands);
    LOGGER.debug("Top level command {}. Failed or active commands: {}", CommandDetails.fromApiCommand(apiCommand), failedCommands);
    if (stackType == StackType.DATALAKE) {
        for (CommandDetails failedCommand : failedCommands) {
            // has no added value, therefore we are just checking whether AuditDir related commands are failing or not.
            if (CLOUD_STORAGE_RELATED_COMMANDS.contains(failedCommand.getName()) && CommandDetails.CommandStatus.FAILED == failedCommand.getCommandStatus()) {
                throw new CloudStorageConfigurationFailedException(msg);
            }
        }
    }
    throw new ClouderaManagerOperationFailedException(msg);
}
Also used : ClouderaManagerOperationFailedException(com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException) CommandDetails(com.sequenceiq.cloudbreak.cm.exception.CommandDetails) CloudStorageConfigurationFailedException(com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException)

Aggregations

CloudStorageConfigurationFailedException (com.sequenceiq.cloudbreak.cm.exception.CloudStorageConfigurationFailedException)5 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)1 ApiException (com.cloudera.api.swagger.client.ApiException)1 ApiCluster (com.cloudera.api.swagger.model.ApiCluster)1 ApiClusterTemplate (com.cloudera.api.swagger.model.ApiClusterTemplate)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)1 ClusterClientInitException (com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException)1 ClouderaManagerOperationFailedException (com.sequenceiq.cloudbreak.cm.ClouderaManagerOperationFailedException)1 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)1 CommandDetails (com.sequenceiq.cloudbreak.cm.exception.CommandDetails)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)1 AccountMapping (com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping)1 CloudIdentity (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity)1 CloudStorage (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage)1 StorageLocation (com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)1 ClusterCommand (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterCommand)1