use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.
the class CoreImageProvider method getImage.
@Override
public Optional<ImageWrapper> getImage(ImageSettingsRequest imageSettings, String region, String platform) {
try {
ImageV4Response imageV4Response = imageCatalogV4Endpoint.getSingleImageByCatalogNameAndImageId(WORKSPACE_ID_DEFAULT, imageSettings.getCatalog(), imageSettings.getId());
Optional<Image> image = convert(imageV4Response);
return image.map(i -> new ImageWrapper(i, defaultCatalogUrl, imageSettings.getCatalog()));
} catch (Exception ex) {
LOGGER.warn("Image lookup failed: {}", ex.getMessage());
return Optional.empty();
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED 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.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.
the class CloudbreakPollerTest method testFlowFinishedClusterNotFailedNotAvailable.
@Test
public void testFlowFinishedClusterNotFailedNotAvailable() {
whenCheckFlowState().thenReturn(FlowState.FINISHED);
whenCheckStackStatus().thenReturn(statusResponse(Status.UPDATE_IN_PROGRESS, Status.UPDATE_IN_PROGRESS));
when(sdxStatusService.getShortStatusMessage(any(StackStatusV4Response.class))).thenReturn("testMessage");
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
UserBreakException exception = assertThrows(UserBreakException.class, () -> underTest.pollStartUntilAvailable(sdxCluster, pollingConfig));
assertEquals("Start failed on 'clusterName' cluster. Reason: testMessage", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.
the class SdxUpgradeService method changeImage.
public void changeImage(Long id, UpgradeOptionV4Response upgradeOption) {
SdxCluster cluster = sdxService.getById(id);
String targetImageId = upgradeOption.getUpgrade().getImageId();
StackImageChangeV4Request stackImageChangeRequest = new StackImageChangeV4Request();
stackImageChangeRequest.setImageId(targetImageId);
stackImageChangeRequest.setImageCatalogName(upgradeOption.getUpgrade().getImageCatalogName());
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.CHANGE_IMAGE_IN_PROGRESS, "Changing image", cluster);
try {
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.changeImageInternal(0L, cluster.getClusterName(), stackImageChangeRequest, initiatorUserCrn));
cloudbreakFlowService.saveLastCloudbreakFlowChainId(cluster, flowIdentifier);
} catch (WebApplicationException e) {
String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Stack change image failed on cluster: [%s]. Message: [%s]", cluster.getClusterName(), exceptionMessage);
throw new CloudbreakApiException(message, e);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.
the class SdxUpgradeRecoveryService method validateRecovery.
@Override
public SdxRecoverableResponse validateRecovery(SdxCluster sdxCluster, SdxRecoveryRequest request) {
MDCBuilder.buildMdcContext(sdxCluster);
try {
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
if (Objects.nonNull(request) && request.getType() == SdxRecoveryType.RECOVER_WITH_DATA) {
String clusterRuntime = sdxCluster.getRuntime();
datalakeDRProto.DatalakeBackupInfo lastSuccessfulBackup = datalakeDrClient.getLastSuccessfulBackup(sdxCluster.getClusterName(), initiatorUserCrn, Optional.of(clusterRuntime));
if (Objects.isNull(lastSuccessfulBackup)) {
return new SdxRecoverableResponse("There is no successful backup taken yet for data lake cluster with runtime " + clusterRuntime + ".", RecoveryStatus.NON_RECOVERABLE);
}
}
RecoveryValidationV4Response response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.getClusterRecoverableByNameInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn));
return new SdxRecoverableResponse(response.getReason(), response.getStatus());
} catch (WebApplicationException e) {
String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Stack recovery validation failed on cluster: [%s]. Message: [%s]", sdxCluster.getClusterName(), exceptionMessage);
throw new CloudbreakApiException(message, e);
}
}
Aggregations