Search in sources :

Example 1 with RecoveryStatus

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus 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 2 with RecoveryStatus

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus 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)

Aggregations

RecoveryStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus)2 RecoveryValidationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)1