Search in sources :

Example 1 with DetailedStackStatus

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

the class ClusterCreationService method handleClusterCreationFailure.

public void handleClusterCreationFailure(StackView stackView, Exception exception, ProvisionType provisionType) {
    if (stackView.getClusterView() != null) {
        String errorMessage = getErrorMessageFromException(exception);
        DetailedStackStatus failureDetailedStatus = provisionType.isRecovery() ? DetailedStackStatus.CLUSTER_RECOVERY_FAILED : DetailedStackStatus.CLUSTER_CREATE_FAILED;
        stackUpdater.updateStackStatus(stackView.getId(), failureDetailedStatus, errorMessage);
        flowMessageService.fireEventAndLog(stackView.getId(), CREATE_FAILED.name(), CLUSTER_CREATE_FAILED, errorMessage);
    } else {
        LOGGER.info("Cluster was null. Flow action was not required.");
    }
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)

Example 2 with DetailedStackStatus

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

the class StackCreationService method handleStackCreationFailure.

public void handleStackCreationFailure(StackView stack, Exception errorDetails, ProvisionType provisionType) {
    LOGGER.info("Error during stack creation flow:", errorDetails);
    String errorReason = errorDetails == null ? "Unknown error" : errorDetails.getMessage();
    if (errorDetails instanceof CancellationException || ExceptionUtils.getRootCause(errorDetails) instanceof CancellationException) {
        LOGGER.debug("The flow has been cancelled.");
    } else {
        if (!stack.isStackInDeletionPhase()) {
            handleFailure(stack, errorReason);
            DetailedStackStatus failureStatus = (provisionType == ProvisionType.REGULAR) ? PROVISION_FAILED : CLUSTER_RECOVERY_FAILED;
            stackUpdater.updateStackStatus(stack.getId(), failureStatus, errorReason);
            flowMessageService.fireEventAndLog(stack.getId(), Status.CREATE_FAILED.name(), STACK_INFRASTRUCTURE_CREATE_FAILED, errorReason);
        } else {
            flowMessageService.fireEventAndLog(stack.getId(), UPDATE_IN_PROGRESS.name(), STACK_INFRASTRUCTURE_CREATE_FAILED, errorReason);
        }
    }
}
Also used : CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)

Example 3 with DetailedStackStatus

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

the class StackTerminationService method handleStackTerminationError.

public void handleStackTerminationError(StackView stackView, Exception errorDetails, boolean forced) {
    Long stackId = stackView.getId();
    String stackUpdateMessage;
    ResourceEvent resourceEvent;
    DetailedStackStatus status;
    if (!forced) {
        stackUpdateMessage = "Termination failed: " + errorDetails.getMessage();
        status = DetailedStackStatus.DELETE_FAILED;
        resourceEvent = STACK_INFRASTRUCTURE_DELETE_FAILED;
        stackUpdater.updateStackStatus(stackId, status, stackUpdateMessage);
        LOGGER.debug("Error during stack termination flow: ", errorDetails);
    } else {
        clusterService.updateClusterStatusByStackId(stackId, DetailedStackStatus.CLUSTER_DELETE_COMPLETED);
        terminationService.finalizeTermination(stackId, true);
        stackUpdateMessage = "Stack was force terminated.";
        status = DetailedStackStatus.DELETE_COMPLETED;
        resourceEvent = STACK_FORCED_DELETE_COMPLETED;
    }
    flowMessageService.fireEventAndLog(stackId, status.name(), resourceEvent, stackUpdateMessage);
    metricService.incrementMetricCounter(MetricType.STACK_TERMINATION_FAILED, stackView, errorDetails);
}
Also used : ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)

Example 4 with DetailedStackStatus

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

the class StackUpdater method doUpdateStackStatus.

private Stack doUpdateStackStatus(Long stackId, Status newStatus, DetailedStackStatus newDetailedStatus, String statusReason) {
    Stack stack = stackService.getByIdWithTransaction(stackId);
    StackStatus actualStackStatus = stack.getStackStatus();
    LOGGER.info("Update stack status from: {}/{} to: {}/{} stack: {} reason: {}", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus(), newStatus, newDetailedStatus, stackId, statusReason);
    if (actualStackStatus.getStatus().equals(newStatus)) {
        LOGGER.debug("New status is the same as previous status {}/{}, skip status update.", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus());
        return stack;
    } else if (!stack.isDeleteCompleted()) {
        stack.setStackStatus(new StackStatus(stack, newStatus, statusReason, newDetailedStatus));
        Cluster cluster = stack.getCluster();
        if (newStatus.isRemovableStatus()) {
            InMemoryStateStore.deleteStack(stackId);
            if (cluster != null) {
                InMemoryStateStore.deleteCluster(cluster.getId());
            }
        } else {
            InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(newStatus));
            if (cluster != null) {
                InMemoryStateStore.putCluster(cluster.getId(), statusToPollGroupConverter.convert(newStatus));
            }
        }
        stack = stackService.save(stack);
        saveDeprecatedClusterStatus(statusReason, stack, newStatus);
        usageLoggingUtil.logClusterStatusChangeUsageEvent(actualStackStatus.getStatus(), newStatus, cluster);
    } else {
        LOGGER.info("Stack is in DELETE_COMPLETED status, cannot update status.");
    }
    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 5 with DetailedStackStatus

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

the class StackUpdaterTest method skipStackStatusUpdateWhenActualStatusEqualsNewStatus.

@Test
public void skipStackStatusUpdateWhenActualStatusEqualsNewStatus() {
    Stack stack = TestUtil.stack();
    DetailedStackStatus newStatus = DetailedStackStatus.AVAILABLE;
    when(stackService.getByIdWithTransaction(anyLong())).thenReturn(stack);
    Stack modifiedStack = underTest.updateStackStatus(1L, newStatus, "newReason");
    assertEquals(stack.getStatus(), modifiedStack.getStatus());
    assertEquals(newStatus.getStatus(), 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)

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