Search in sources :

Example 6 with DetailedStackStatus

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

the class StackUpdaterTest method updateStackStatusAndReason.

@Test
public void updateStackStatusAndReason() {
    Stack stack = TestUtil.stack(TestUtil.cluster());
    DetailedStackStatus newStatus = DetailedStackStatus.DELETE_COMPLETED;
    String newStatusReason = "test";
    when(stackService.getByIdWithTransaction(anyLong())).thenReturn(stack);
    when(stackService.save(any(Stack.class))).thenReturn(stack);
    Stack newStack = underTest.updateStackStatus(1L, newStatus, newStatusReason);
    assertEquals(newStatus.getStatus(), newStack.getStatus());
    assertEquals(newStatusReason, newStack.getStatusReason());
    verify(stackService, times(1)).save(eq(stack));
    verify(clusterService, times(1)).save(eq(stack.getCluster()));
    verify(usageLoggingUtil, times(1)).logClusterStatusChangeUsageEvent(eq(Status.AVAILABLE), eq(Status.DELETE_COMPLETED), eq(stack.getCluster()));
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 7 with DetailedStackStatus

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

the class StackOperationServiceTest method testStop.

@ParameterizedTest(name = "{0}: With stackStatus={1}")
@MethodSource("stackStatusForStop")
public void testStop(String methodName, DetailedStackStatus stackStatus) {
    Stack stack = new Stack();
    stack.setId(9876L);
    stack.setStackStatus(new StackStatus(stack, stackStatus));
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    stack.setCluster(cluster);
    when(stackStopRestrictionService.isInfrastructureStoppable(any())).thenReturn(StopRestrictionReason.NONE);
    // On demand instances
    when(spotInstanceUsageCondition.isStackRunsOnSpotInstances(stack)).thenReturn(false);
    when(stackService.getByIdWithLists(stack.getId())).thenReturn(stack);
    when(clusterService.findOneWithLists(cluster.getId())).thenReturn(Optional.of(cluster));
    underTest.updateStatus(stack.getId(), StatusRequest.STOPPED, true);
    if (stackStatus == STOP_FAILED) {
        verify(flowManager).triggerStackStop(stack.getId());
    } else {
        verify(clusterOperationService).updateStatus(stack.getId(), StatusRequest.STOPPED);
    }
}
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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 8 with DetailedStackStatus

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

the class ClusterStatusUpdaterTest method createStack.

private Stack createStack(DetailedStackStatus detailedStackStatus) {
    Stack stack = new Stack();
    stack.setId(TEST_STACK_ID);
    stack.setStackStatus(new StackStatus(stack, detailedStackStatus.getStatus(), "", detailedStackStatus));
    return stack;
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 9 with DetailedStackStatus

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

the class ClusterDownscaleService method handleClusterDownscaleFailure.

public void handleClusterDownscaleFailure(long stackId, Exception error) {
    String errorDetails = error.getMessage();
    LOGGER.warn("Error during Cluster downscale flow: ", error);
    DetailedStackStatus detailedStackStatus = DetailedStackStatus.DOWNSCALE_FAILED;
    if (error instanceof NotEnoughNodeException || error instanceof NodeIsBusyException) {
        detailedStackStatus = DetailedStackStatus.AVAILABLE;
    }
    stackUpdater.updateStackStatus(stackId, detailedStackStatus, "Node(s) could not be removed from the cluster: " + errorDetails);
    flowMessageService.fireEventAndLog(stackId, UPDATE_FAILED.name(), CLUSTER_SCALING_FAILED, "removed from", errorDetails);
}
Also used : NotEnoughNodeException(com.sequenceiq.cloudbreak.cluster.service.NotEnoughNodeException) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) NodeIsBusyException(com.sequenceiq.cloudbreak.cluster.service.NodeIsBusyException)

Example 10 with DetailedStackStatus

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

the class BlueprintServiceTest method patchWithStackStatus.

private void patchWithStackStatus(Cluster cluster1, DetailedStackStatus detailedStackStatus) {
    Stack stack = new Stack();
    stack.setStackStatus(new StackStatus(stack, detailedStackStatus));
    stack.setType(StackType.WORKLOAD);
    stack.setName(cluster1.getName());
    stack.setId(cluster1.getId());
    cluster1.setStack(stack);
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) 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