use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class ProvisionerServiceTest method waitCloudbreakClusterDeletionClusterRetryFailedTest.
@Test
void waitCloudbreakClusterDeletionClusterRetryFailedTest() {
long clusterId = CLUSTER_ID.incrementAndGet();
SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
sdxCluster.setClusterName("sdxcluster1");
when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
StackV4Response firstStackV4Response = new StackV4Response();
firstStackV4Response.setStatus(Status.DELETE_IN_PROGRESS);
ClusterV4Response firstClusterResponse = new ClusterV4Response();
firstClusterResponse.setStatus(Status.DELETE_IN_PROGRESS);
firstClusterResponse.setStatusReason("delete failed");
firstStackV4Response.setCluster(firstClusterResponse);
StackV4Response secondStackV4Response = new StackV4Response();
secondStackV4Response.setStatus(Status.DELETE_FAILED);
ClusterV4Response secondClusterResponse = new ClusterV4Response();
secondClusterResponse.setStatus(Status.DELETE_IN_PROGRESS);
secondClusterResponse.setStatusReason("delete failed");
secondStackV4Response.setCluster(secondClusterResponse);
StackV4Response thirdStackV4Response = new StackV4Response();
thirdStackV4Response.setStatus(Status.DELETE_FAILED);
ClusterV4Response thirdClusterResponse = new ClusterV4Response();
thirdClusterResponse.setStatus(Status.DELETE_FAILED);
thirdClusterResponse.setStatusReason("delete failed");
thirdStackV4Response.setCluster(thirdClusterResponse);
when(stackV4Endpoint.get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString())).thenReturn(firstStackV4Response).thenReturn(secondStackV4Response).thenReturn(thirdStackV4Response);
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), "Data lake deletion failed 'sdxcluster1', delete failed");
verify(stackV4Endpoint, times(5)).get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxRecoveryService method getStackResponseAttemptResult.
private AttemptResult<StackV4Response> getStackResponseAttemptResult(SdxCluster sdxCluster, String pollingMessage, FlowState flowState) throws JsonProcessingException {
StackV4Response stackV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, sdxCluster.getClusterName(), Collections.emptySet(), sdxCluster.getAccountId()));
LOGGER.info("Response from cloudbreak: {}", JsonUtil.writeValueAsString(stackV4Response));
ClusterV4Response cluster = stackV4Response.getCluster();
if (availabilityChecker.stackAndClusterAvailable(stackV4Response, cluster)) {
return AttemptResults.finishWith(stackV4Response);
} else {
return getResponseAttemptResultUnavailableCase(sdxCluster, pollingMessage, flowState, stackV4Response);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxUpgradeService method updateRuntimeVersionFromCloudbreak.
public Optional<String> updateRuntimeVersionFromCloudbreak(Long sdxId) {
SdxCluster sdxCluster = sdxService.getById(sdxId);
String clusterName = sdxCluster.getClusterName();
LOGGER.info("Trying to update the runtime version from Cloudbreak for cluster: {}", clusterName);
StackV4Response stack = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, clusterName, Set.of(), sdxCluster.getAccountId()));
return sdxService.updateRuntimeVersionFromStackResponse(sdxCluster, stack);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxCcmUpgradeService method upgradeCcm.
public SdxCcmUpgradeResponse upgradeCcm(String environmentCrn) {
checkEnvironment(environmentCrn);
Optional<SdxCluster> sdxClusterOpt = getSdxCluster(environmentCrn);
if (sdxClusterOpt.isEmpty()) {
return noDatalakeAnswer(environmentCrn);
}
SdxCluster sdxCluster = sdxClusterOpt.get();
StackV4Response stack = sdxService.getDetail(sdxCluster.getClusterName(), null, sdxService.getAccountIdFromCrn(environmentCrn));
if (Tunnel.getUpgradables().contains(stack.getTunnel())) {
return checkPrerequisitesAndTrigger(sdxCluster, stack);
} else if (stack.getTunnel() == Tunnel.latestUpgradeTarget()) {
return alreadyOnLatestAnswer(stack);
} else {
return cannotUpgradeAnswer(stack);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DiagnosticsService method collectDiagnostics.
public FlowIdentifier collectDiagnostics(DiagnosticsCollectionRequest request) {
String userId = ThreadBasedUserCrnProvider.getUserCrn();
SdxCluster cluster = sdxService.getByCrn(userId, request.getStackCrn());
StackV4Response stackV4Response = sdxService.getDetail(cluster.getClusterName(), new HashSet<>(), cluster.getAccountId());
diagnosticsCollectionValidator.validate(request, stackV4Response);
Map<String, Object> properties = diagnosticsParamsConverter.convertFromRequest(request);
SdxDiagnosticsCollectionEvent event = new SdxDiagnosticsCollectionEvent(cluster.getId(), userId, properties, null);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDiagnosticsCollection(event, cluster.getClusterName());
LOGGER.debug("Start diagnostics collection with flow pollable identifier: {}", flowIdentifier.getPollableId());
return flowIdentifier;
}
Aggregations