use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class ProvisionerServiceTest method waitCloudbreakClusterDeletionButFailed.
@Test
void waitCloudbreakClusterDeletionButFailed() {
long clusterId = CLUSTER_ID.incrementAndGet();
SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
StackV4Response firstStackV4Response = new StackV4Response();
firstStackV4Response.setStatus(Status.AVAILABLE);
StackV4Response secondStackV4Response = new StackV4Response();
secondStackV4Response.setStatus(Status.DELETE_FAILED);
when(stackV4Endpoint.get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString())).thenReturn(firstStackV4Response).thenReturn(secondStackV4Response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
PollingConfig pollingConfig = new PollingConfig(10, TimeUnit.MILLISECONDS, 500, TimeUnit.MILLISECONDS);
Assertions.assertThrows(UserBreakException.class, () -> underTest.waitCloudbreakClusterDeletion(clusterId, pollingConfig));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class ProvisionerServiceTest method startStackDeletionButClientError.
@Test
void startStackDeletionButClientError() {
long clusterId = CLUSTER_ID.incrementAndGet();
SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setStatus(Status.CREATE_FAILED);
WebApplicationException webApplicationException = new WebApplicationException();
doThrow(webApplicationException).when(stackV4Endpoint).deleteInternal(anyLong(), eq(sdxCluster.getClusterName()), eq(Boolean.FALSE), nullable(String.class));
when(webApplicationExceptionMessageExtractor.getErrorMessage(webApplicationException)).thenReturn("web-error");
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
RuntimeException actual = Assertions.assertThrows(RuntimeException.class, () -> underTest.startStackDeletion(clusterId, false));
Assertions.assertEquals("Cannot delete cluster, error happened during the operation: web-error", actual.getMessage());
verify(stackV4Endpoint).deleteInternal(eq(0L), eq(null), eq(false), nullable(String.class));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackIdViewToStackResponseConverter method convert.
public StackV4Response convert(StackIdView source) {
StackV4Response stackJson = new StackV4Response();
stackJson.setId(source.getId());
stackJson.setName(source.getName());
stackJson.setCrn(source.getCrn());
return stackJson;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxService method getCdpVersion.
private Optional<String> getCdpVersion(StackV4Response stack) {
String stackName = stack.getName();
ClusterV4Response cluster = stack.getCluster();
if (cluster != null) {
ClouderaManagerV4Response cm = cluster.getCm();
if (cm != null) {
LOGGER.info("Repository details are available for cluster: {}: {}", stackName, cm);
List<ClouderaManagerProductV4Response> products = cm.getProducts();
if (products != null && !products.isEmpty()) {
Optional<ClouderaManagerProductV4Response> cdpOpt = products.stream().filter(p -> "CDH".equals(p.getName())).findFirst();
if (cdpOpt.isPresent()) {
return getRuntimeVersionFromCdpVersion(cdpOpt.get().getVersion());
}
}
}
}
return Optional.empty();
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxService method resizeSdx.
public Pair<SdxCluster, FlowIdentifier> resizeSdx(final String userCrn, final String clusterName, final SdxClusterResizeRequest sdxClusterResizeRequest) {
LOGGER.info("Re-sizing SDX cluster with name {}", clusterName);
String accountIdFromCrn = getAccountIdFromCrn(userCrn);
String environmentName = sdxClusterResizeRequest.getEnvironment();
SdxClusterShape shape = sdxClusterResizeRequest.getClusterShape();
final SdxCluster sdxCluster = sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(accountIdFromCrn, clusterName).orElseThrow(() -> notFound("SDX cluster", clusterName).get());
MDCBuilder.buildMdcContext(sdxCluster);
validateSdxResizeRequest(sdxCluster, accountIdFromCrn, shape);
StackV4Response stackV4Response = getDetail(clusterName, Set.of(StackResponseEntries.HARDWARE_INFO.getEntryName(), StackResponseEntries.EVENTS.getEntryName()), accountIdFromCrn);
DetailedEnvironmentResponse environment = validateAndGetEnvironment(environmentName);
SdxCluster newSdxCluster = validateAndCreateNewSdxCluster(userCrn, clusterName, sdxCluster.getRuntime(), shape, sdxCluster.isRangerRazEnabled(), sdxCluster.isEnableMultiAz(), environment);
newSdxCluster.setTags(sdxCluster.getTags());
newSdxCluster.setCrn(sdxCluster.getCrn());
CloudPlatform cloudPlatform = CloudPlatform.valueOf(environment.getCloudPlatform());
if (!StringUtils.isBlank(sdxCluster.getCloudStorageBaseLocation())) {
newSdxCluster.setCloudStorageBaseLocation(sdxCluster.getCloudStorageBaseLocation());
newSdxCluster.setCloudStorageFileSystemType(sdxCluster.getCloudStorageFileSystemType());
} else if (!CloudPlatform.YARN.equalsIgnoreCase(cloudPlatform.name()) && !CloudPlatform.GCP.equalsIgnoreCase(cloudPlatform.name()) && !CloudPlatform.MOCK.equalsIgnoreCase(cloudPlatform.name())) {
throw new BadRequestException("Cloud storage parameter is required.");
}
newSdxCluster.setDatabaseAvailabilityType(sdxCluster.getDatabaseAvailabilityType());
newSdxCluster.setDatabaseEngineVersion(sdxCluster.getDatabaseEngineVersion());
StackV4Request stackRequest = getStackRequest(shape, sdxCluster.isRangerRazEnabled(), null, cloudPlatform, sdxCluster.getRuntime(), null);
if (shape == SdxClusterShape.MEDIUM_DUTY_HA) {
// This is added to make sure the host name used by Light and Medium duty are not the same.
CustomDomainSettingsV4Request customDomainSettingsV4Request = new CustomDomainSettingsV4Request();
customDomainSettingsV4Request.setHostname(sdxCluster.getClusterName() + SDX_RESIZE_NAME_SUFFIX);
stackRequest.setCustomDomain(customDomainSettingsV4Request);
}
prepareCloudStorageForStack(stackRequest, stackV4Response, newSdxCluster, environment);
prepareDefaultSecurityConfigs(null, stackRequest, cloudPlatform);
try {
if (!StringUtils.isBlank(sdxCluster.getStackRequestToCloudbreak())) {
StackV4Request stackV4RequestOrig = JsonUtil.readValue(sdxCluster.getStackRequestToCloudbreak(), StackV4Request.class);
stackRequest.setImage(stackV4RequestOrig.getImage());
}
} catch (IOException ioException) {
LOGGER.error("Failed to re-use the image catalog. Will use default catalog", ioException);
}
stackRequest.setResourceCrn(newSdxCluster.getCrn());
newSdxCluster.setStackRequest(stackRequest);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerSdxResize(sdxCluster.getId(), newSdxCluster);
return Pair.of(sdxCluster, flowIdentifier);
}
Aggregations