Search in sources :

Example 11 with DetailedStackStatus

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

the class StackUpdaterTest method skipStackStatusUpdateWhenStatusIsDeleteCompleted.

@Test
public void skipStackStatusUpdateWhenStatusIsDeleteCompleted() {
    Stack stack = TestUtil.stack(Status.DELETE_COMPLETED);
    DetailedStackStatus newStatus = DetailedStackStatus.AVAILABLE;
    when(stackService.getByIdWithTransaction(anyLong())).thenReturn(stack);
    Stack modifiedStack = underTest.updateStackStatus(1L, newStatus, "newReason");
    assertEquals(Status.DELETE_COMPLETED, modifiedStack.getStatus());
    verify(stackService, never()).save(any());
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 12 with DetailedStackStatus

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

the class StackStartStopService method handleError.

private void handleError(StackView stackView, Exception exception, DetailedStackStatus detailedStackStatus, ResourceEvent resourceEvent, String logMessage) {
    LOGGER.debug(logMessage, exception);
    Status stackStatus = detailedStackStatus.getStatus();
    stackUpdater.updateStackStatus(stackView.getId(), detailedStackStatus, logMessage + exception.getMessage());
    flowMessageService.fireEventAndLog(stackView.getId(), stackStatus.name(), resourceEvent, exception.getMessage());
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) InstanceStatus(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)

Example 13 with DetailedStackStatus

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus 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 14 with DetailedStackStatus

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

the class ClusterCommonService method saveAndFireEventOnClusterStatusChange.

private void saveAndFireEventOnClusterStatusChange(Stack stack, DetailedStackStatus newDetailedStackStatus, ResourceEvent event) {
    Status actualStatus = stack.getStatus();
    if (!actualStatus.equals(newDetailedStackStatus.getStatus())) {
        clusterService.updateClusterStatusByStackId(stack.getId(), newDetailedStackStatus);
        cloudbreakEventService.fireCloudbreakEvent(stack.getId(), event.name(), event);
    }
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) MaintenanceModeStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.MaintenanceModeStatus)

Example 15 with DetailedStackStatus

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

the class ClusterStatusUpdater method updateClusterStatus.

private boolean updateClusterStatus(Stack stack, ClusterStatus clusterStatus) {
    boolean result = false;
    Cluster cluster = stack.getCluster();
    Status actualStatus = stack.getStatus();
    DetailedStackStatus newDetailedStackStatus = clusterStatus.getDetailedStackStatus();
    Status newStatus = newDetailedStackStatus.getStatus();
    if (actualStatus != newStatus) {
        if (!actualStatus.equals(Status.MAINTENANCE_MODE_ENABLED) || !newStatus.equals(Status.AVAILABLE)) {
            LOGGER.debug("Cluster {} status is updated from {} to {}/{}", cluster.getId(), actualStatus, newStatus, newDetailedStackStatus);
            clusterService.updateClusterStatusByStackId(stack.getId(), newDetailedStackStatus, clusterStatus.getStatusReason());
            result = true;
        }
    } else {
        LOGGER.debug("Cluster {} status hasn't changed: {}", cluster.getId(), actualStatus);
    }
    return result;
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) ClusterStatus(com.sequenceiq.cloudbreak.cluster.status.ClusterStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)18 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)9 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)5 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)3 Test (org.junit.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 InstanceGroupAdjustmentV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request)1 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)1 MaintenanceModeStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.MaintenanceModeStatus)1 RecoveryStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus)1 RecoveryValidationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response)1 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)1 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)1 InstanceStatus (com.sequenceiq.cloudbreak.cloud.model.InstanceStatus)1 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)1 NodeIsBusyException (com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException)1 NotEnoughNodeException (com.sequenceiq.cloudbreak.cluster.service.NotEnoughNodeException)1 ClusterStatus (com.sequenceiq.cloudbreak.cluster.status.ClusterStatus)1