Search in sources :

Example 41 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class ClusterRecoveryService method validateStackStatus.

private RecoveryValidationV4Response validateStackStatus(Stack stack) {
    List<StackStatus> statusList = stackStatusService.findAllStackStatusesById(stack.getId());
    List<DetailedStackStatus> detailedStackStatusList = statusList.stream().map(StackStatus::getDetailedStackStatus).collect(Collectors.toList());
    int lastRecoverySuccess = getLastRecoverySuccess(detailedStackStatusList);
    int lastRecoveryFailure = getLastRecoveryFailure(detailedStackStatusList);
    int lastUpgradeSuccess = getLastUpgradeSuccess(detailedStackStatusList);
    int lastUpgradeFailure = getLastUpgradeFailure(detailedStackStatusList);
    String logMessage = Stream.of(createLogEntry(lastUpgradeSuccess, DetailedStackStatus.CLUSTER_UPGRADE_FINISHED), createLogEntry(lastUpgradeFailure, DetailedStackStatus.CLUSTER_UPGRADE_FAILED), createLogEntry(lastRecoverySuccess, DetailedStackStatus.CLUSTER_RECOVERY_FINISHED), createLogEntry(lastRecoveryFailure, DetailedStackStatus.CLUSTER_RECOVERY_FAILED)).flatMap(Optional::stream).collect(Collectors.joining(". "));
    LOGGER.debug(logMessage);
    int maximumInt = IntStream.of(lastUpgradeFailure, lastRecoveryFailure, lastRecoverySuccess, lastUpgradeSuccess).max().getAsInt();
    String reason;
    RecoveryStatus status;
    if (maximumInt == -1) {
        reason = "There has been no failed upgrades for this cluster hence recovery is not permitted.";
        status = NON_RECOVERABLE;
    } else if (maximumInt == lastRecoveryFailure) {
        reason = "Last cluster recovery has failed, recovery can be retried.";
        status = RECOVERABLE;
    } else if (maximumInt == lastUpgradeFailure) {
        reason = "Last cluster upgrade has failed, recovery can be launched to restore the cluster to its pre-upgrade state.";
        status = RECOVERABLE;
    } else {
        reason = "Cluster is not in a recoverable state now, neither uncorrected upgrade or recovery failures are present.";
        status = NON_RECOVERABLE;
    }
    LOGGER.info(reason);
    return new RecoveryValidationV4Response(reason, status);
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) RecoveryStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus)

Example 42 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class ClusterRecoveryService method validateFreeIpaStatus.

private RecoveryValidationV4Response validateFreeIpaStatus(String envCrn) {
    boolean freeIpaAvailable = freeipaService.checkFreeipaRunning(envCrn);
    String reason = "";
    RecoveryStatus status;
    if (!freeIpaAvailable) {
        reason = "Recovery cannot be performed because the FreeIPA isn't available. Please check the FreeIPA state and try again.";
        status = NON_RECOVERABLE;
        LOGGER.info(reason);
    } else {
        status = RECOVERABLE;
        LOGGER.debug("Recovery can be performed because the FreeIPA is available.");
    }
    return new RecoveryValidationV4Response(reason, status);
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) RecoveryStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus)

Example 43 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class StackStatusFinalizerTest method shouldUpdateWhenIsInProgressStatus.

@Test
public void shouldUpdateWhenIsInProgressStatus() {
    when(stackStatusService.findFirstByStackIdOrderByCreatedDesc(RESOURCE_ID)).thenReturn(Optional.of(new StackStatus(new Stack(), Status.UPDATE_IN_PROGRESS, "", DetailedStackStatus.UNKNOWN)));
    underTest.onFinalize(RESOURCE_ID);
    verify(stackUpdater).updateStackStatusAndSetDetailedStatusToUnknown(RESOURCE_ID, Status.UPDATE_FAILED, "Flow completed with stack is in progress status");
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 44 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class StartExternalDatabaseHandlerTest method buildStack.

private Stack buildStack(DatabaseAvailabilityType databaseAvailabilityType) {
    StackStatus status = new StackStatus();
    status.setStatus(Status.AVAILABLE);
    Cluster cluster = new Cluster();
    Stack stack = new Stack();
    stack.setStackStatus(status);
    stack.setId(STACK_ID);
    stack.setName(STACK_NAME);
    stack.setExternalDatabaseCreationType(databaseAvailabilityType);
    stack.setEnvironmentCrn("envCrn");
    stack.setCluster(cluster);
    return stack;
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 45 with Status

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.

the class CreateExternalDatabaseHandlerTest method buildStack.

private Stack buildStack(DatabaseAvailabilityType databaseAvailabilityType) {
    StackStatus status = new StackStatus();
    status.setStatus(Status.REQUESTED);
    Cluster cluster = new Cluster();
    Stack stack = new Stack();
    stack.setStackStatus(status);
    stack.setId(STACK_ID);
    stack.setName(STACK_NAME);
    stack.setExternalDatabaseCreationType(databaseAvailabilityType);
    stack.setEnvironmentCrn("envCrn");
    stack.setCluster(cluster);
    return stack;
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)23 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)22 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)18 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)12 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)9 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)6 Collection (java.util.Collection)6 List (java.util.List)6 Set (java.util.Set)6 Inject (javax.inject.Inject)6 PollerStoppedException (com.dyngr.exception.PollerStoppedException)5 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)5 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)5