Search in sources :

Example 21 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class StackStatusTest method available.

@Test
@DisplayName("GIVEN an available stack " + "WHEN FreeIpa instance is available " + "THEN stack status should not change")
void available() throws Exception {
    setUp(1);
    setUpFreeIpaAvailabilityResponse(true);
    when(stackInstanceProviderChecker.checkStatus(stack, notTerminatedInstances)).thenReturn(List.of(createCloudVmInstanceStatus(INSTANCE_1, com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.STARTED)));
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:altus:iam:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    StackStatus stackStatus = new StackStatus();
    stackStatus.setDetailedStackStatus(DetailedStackStatus.AVAILABLE);
    stack.setStackStatus(stackStatus);
    underTest.executeTracedJob(jobExecutionContext);
    verify(stackUpdater, never()).updateStackStatus(eq(stack), any(), any());
}
Also used : StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 22 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class FreeipaStructuredFlowEventFactory method createStructuredFlowEvent.

@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Exception exception) {
    Stack stack = stackService.getStackById(resourceId);
    String resourceType = CloudbreakEventService.FREEIPA_RESOURCE_TYPE;
    CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, stack.getId(), stack.getName(), nodeConfig.getId(), serviceVersion, stack.getAccountId(), stack.getResourceCrn(), ThreadBasedUserCrnProvider.getUserCrn(), stack.getEnvironmentCrn(), null);
    StackDetails stackDetails = stackToStackDetailsConverter.convert(stack);
    StackStatus stackStatus = stack.getStackStatus();
    CDPFreeIpaStructuredFlowEvent event = new CDPFreeIpaStructuredFlowEvent(operationDetails, flowDetails, stackDetails, stackStatus.getDetailedStackStatus().name(), stackStatus.getStatusReason());
    if (exception != null) {
        event.setException(ExceptionUtils.getStackTrace(exception));
    }
    return event;
}
Also used : CDPFreeIpaStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.freeipa.CDPFreeIpaStructuredFlowEvent) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) StackDetails(com.sequenceiq.cloudbreak.structuredevent.event.StackDetails) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 23 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class StackUpdater method doUpdateStackStatus.

private Stack doUpdateStackStatus(Stack stack, DetailedStackStatus newDetailedStatus, String rawNewStatusReason) {
    Status newStatus = newDetailedStatus.getStatus();
    StackStatus stackStatus = stack.getStackStatus();
    if (!Status.DELETE_COMPLETED.equals(stackStatus.getStatus())) {
        rawNewStatusReason = serviceStatusRawMessageTransformer.transformMessage(rawNewStatusReason, stack.getTunnel());
        String transformedStatusReason = stackStatusMessageTransformator.transformMessage(rawNewStatusReason);
        if (isStatusChanged(stack, newDetailedStatus, transformedStatusReason, newStatus)) {
            stack = handleStatusChange(stack, newDetailedStatus, transformedStatusReason, newStatus, stackStatus);
        } else {
            LOGGER.debug("Statuses are the same, it will not update");
            updateInMemoryStoreIfStackIsMissing(stack, newStatus);
        }
    }
    return stack;
}
Also used : StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)

Example 24 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class StackUpdater method saveStackNewStatus.

private Stack saveStackNewStatus(Stack stack, DetailedStackStatus newDetailedStatus, String newStatusReason, Status newStatus, StackStatus stackStatus) {
    LOGGER.debug("Updated: status from {} to {} - detailed status from {} to {} - reason from {} to {}", stackStatus.getStatus(), newStatus, stackStatus.getDetailedStackStatus(), newDetailedStatus, stackStatus.getStatusReason(), newStatusReason);
    stack.setStackStatus(new StackStatus(stack, newStatus, newStatusReason, newDetailedStatus));
    stack = stackService.save(stack);
    return stack;
}
Also used : StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)

Aggregations

StackStatus (com.sequenceiq.freeipa.entity.StackStatus)24 Stack (com.sequenceiq.freeipa.entity.Stack)17 DetailedStackStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)14 Test (org.junit.jupiter.api.Test)9 Status (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status)5 InstanceStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus)5 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)4 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)3 Secret (com.sequenceiq.cloudbreak.service.secret.domain.Secret)3 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)3 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)3 StackDetails (com.sequenceiq.cloudbreak.structuredevent.event.StackDetails)2 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)2 HashSet (java.util.HashSet)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)1 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)1