Search in sources :

Example 16 with FAILED

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();
    }
}
Also used : ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 17 with FAILED

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());
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test)

Example 18 with FAILED

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());
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response) Test(org.junit.jupiter.api.Test)

Example 19 with FAILED

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);
    }
}
Also used : StackImageChangeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackImageChangeV4Request) WebApplicationException(javax.ws.rs.WebApplicationException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Example 20 with FAILED

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);
    }
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) WebApplicationException(javax.ws.rs.WebApplicationException) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) com.cloudera.thunderhead.service.datalakedr.datalakeDRProto(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)20 List (java.util.List)19 Set (java.util.Set)18 Inject (javax.inject.Inject)18 Optional (java.util.Optional)17 Logger (org.slf4j.Logger)17 LoggerFactory (org.slf4j.LoggerFactory)17 Map (java.util.Map)16 Collectors (java.util.stream.Collectors)15 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)14 HashSet (java.util.HashSet)13 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)11 Collection (java.util.Collection)11 Collections (java.util.Collections)11 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)9 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)9 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)8 VolumeSetAttributes (com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes)8 ResourceAttributeUtil (com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil)8 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)8