Search in sources :

Example 16 with DetailedStackStatus

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

the class StackOperationServiceTest method testUpdateNodeCountStartInstances.

@ParameterizedTest(name = "{0}: With stackStatus={1}")
@MethodSource("stackStatusForUpdateNodeCount")
public void testUpdateNodeCountStartInstances(String methodName, DetailedStackStatus stackStatus) throws TransactionService.TransactionExecutionException {
    Stack stack = new Stack();
    stack.setId(9876L);
    stack.setStackStatus(new StackStatus(stack, stackStatus));
    Cluster cluster = new Cluster();
    cluster.setStatus(Status.AVAILABLE);
    stack.setCluster(cluster);
    when(stackService.getByIdWithLists(stack.getId())).thenReturn(stack);
    InstanceGroupAdjustmentV4Request upscaleAdjustment = new InstanceGroupAdjustmentV4Request();
    upscaleAdjustment.setScalingAdjustment(5);
    when(transactionService.required(any(Supplier.class))).thenAnswer(ans -> ((Supplier) ans.getArgument(0)).get());
    doNothing().when(updateNodeCountValidator).validateServiceRoles(any(), any(InstanceGroupAdjustmentV4Request.class));
    if (stackStatus != CLUSTER_UPGRADE_FAILED) {
        doNothing().when(updateNodeCountValidator).validateInstanceGroup(any(), any());
        doNothing().when(updateNodeCountValidator).validateScalabilityOfInstanceGroup(any(), any(InstanceGroupAdjustmentV4Request.class));
        doNothing().when(updateNodeCountValidator).validateScalingAdjustment(any(InstanceGroupAdjustmentV4Request.class), any());
        doNothing().when(updateNodeCountValidator).validateHostGroupIsPresent(any(InstanceGroupAdjustmentV4Request.class), any());
        doNothing().when(updateNodeCountValidator).validateInstanceGroupForStopStart(any(), any(), anyInt());
    }
    // Regular
    try {
        underTest.updateNodeCountStartInstances(stack, upscaleAdjustment, true, ScalingStrategy.STOPSTART);
        String expectedStatusReason = "Requested node count for upscaling (stopstart): " + upscaleAdjustment.getScalingAdjustment();
        verify(stackUpdater).updateStackStatus(stack.getId(), DetailedStackStatus.UPSCALE_BY_START_REQUESTED, expectedStatusReason);
        verify(flowManager).triggerStopStartStackUpscale(stack.getId(), upscaleAdjustment, true);
    } catch (Exception e) {
        assertSame(CLUSTER_UPGRADE_FAILED, stackStatus);
        assertSame(BadRequestException.class, e.getClass());
    }
    // Somehow invoked with a negative value
    upscaleAdjustment.setScalingAdjustment(-1);
    assertThrows(BadRequestException.class, () -> underTest.updateNodeCountStartInstances(stack, upscaleAdjustment, true, ScalingStrategy.STOPSTART));
    upscaleAdjustment.setScalingAdjustment(0);
    assertThrows(BadRequestException.class, () -> underTest.updateNodeCountStartInstances(stack, upscaleAdjustment, true, ScalingStrategy.STOPSTART));
}
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) InstanceGroupAdjustmentV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Supplier(java.util.function.Supplier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 17 with DetailedStackStatus

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

the class RecoveryTeardownService method handleRecoveryTeardownError.

public void handleRecoveryTeardownError(StackView stack, Exception errorDetails) {
    Long stackId = stack.getId();
    String stackUpdateMessage = "Recovery failed: " + errorDetails.getMessage();
    DetailedStackStatus status = DetailedStackStatus.CLUSTER_RECOVERY_FAILED;
    stackUpdater.updateStackStatus(stackId, status, stackUpdateMessage);
    LOGGER.info("Error during stack recovery flow: ", errorDetails);
    metricService.incrementMetricCounter(MetricType.STACK_RECOVERY_TEARDOWN_FAILED, stack, errorDetails);
    flowMessageService.fireEventAndLog(stackId, status.name(), DATALAKE_RECOVERY_FAILED, stackUpdateMessage);
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)

Example 18 with DetailedStackStatus

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

the class StackImageFilterServiceTest method getStack.

private Stack getStack(DetailedStackStatus detailedStackStatus) {
    Stack stack = new Stack();
    stack.setId(STACK_ID);
    stack.setCloudPlatform(PROVIDER_AWS);
    stack.setPlatformVariant(PROVIDER_AWS);
    stack.setName(STACK_NAME);
    stack.setStackStatus(new StackStatus(stack, detailedStackStatus.getStatus(), "", detailedStackStatus));
    Cluster cluster = new Cluster();
    stack.setCluster(cluster);
    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)

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