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