Search in sources :

Example 6 with Status

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

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

the class ClusterCommonService method put.

public FlowIdentifier put(String crn, UpdateClusterV4Request updateJson) {
    Stack stack = stackService.getByCrnWithLists(crn);
    Long stackId = stack.getId();
    MDCBuilder.buildMdcContext(stack);
    UserNamePasswordV4Request userNamePasswordJson = updateJson.getUserNamePassword();
    FlowIdentifier flowIdentifier;
    if (userNamePasswordJson != null) {
        flowIdentifier = clusterManagerUserNamePasswordChange(stack, userNamePasswordJson);
    } else if (updateJson.getStatus() != null) {
        LOGGER.debug("Cluster status update request received. Stack id:  {}, status: {} ", stackId, updateJson.getStatus());
        flowIdentifier = clusterOperationService.updateStatus(stackId, updateJson.getStatus());
    } else if (updateJson.getBlueprintName() != null && updateJson.getHostgroups() != null && stack.getCluster().isCreateFailed()) {
        LOGGER.debug("Cluster rebuild request received. Stack id:  {}", stackId);
        try {
            flowIdentifier = recreateCluster(stack, updateJson);
        } catch (TransactionExecutionException e) {
            throw new TransactionRuntimeExecutionException(e);
        }
    } else if (updateJson.getHostGroupAdjustment() != null) {
        environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable());
        flowIdentifier = clusterHostgroupAdjustmentChange(stackId, updateJson, stack);
    } else {
        LOGGER.info("Invalid cluster update request received. Stack id: {}", stackId);
        throw new BadRequestException("Invalid update cluster request!");
    }
    return flowIdentifier;
}
Also used : TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) UserNamePasswordV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.UserNamePasswordV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Example 8 with Status

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

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

the class ClusterStatusUpdater method updateClusterStatus.

private void updateClusterStatus(Stack stack, ClusterStatusResult clusterStatusResult) {
    Status statusInEvent = stack.getStatus();
    ClusterStatus clusterStatus = clusterStatusResult.getClusterStatus();
    String statusReason = clusterStatusResult.getStatusReason();
    if (isUpdateEnabled(clusterStatus)) {
        if (updateClusterStatus(stack, clusterStatus)) {
            statusInEvent = clusterStatus.getDetailedStackStatus().getStatus();
            statusReason = clusterStatus.getStatusReason();
        } else {
            statusReason = "The cluster's state is up to date.";
        }
    }
    cloudbreakEventService.fireCloudbreakEvent(stack.getId(), statusInEvent.name(), CLUSTER_AMBARI_CLUSTER_SYNCHRONIZED, Collections.singletonList(statusReason));
}
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) ClusterStatus(com.sequenceiq.cloudbreak.cluster.status.ClusterStatus)

Example 10 with Status

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

the class ClusterStatusSyncHandlerTest method getStackResponse.

private StackStatusV4Response getStackResponse(Status clusterStatus) {
    StackStatusV4Response stackResponse = new StackStatusV4Response();
    stackResponse.setStatus(clusterStatus);
    stackResponse.setClusterStatus(clusterStatus);
    return stackResponse;
}
Also used : StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

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