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);
}
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);
}
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");
}
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;
}
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;
}
Aggregations