use of com.sequenceiq.cloudbreak.domain.stack.StackStatus in project cloudbreak by hortonworks.
the class CcmUpgradeFlowIntegrationTest method mockStack.
private Stack mockStack() {
stack = new Stack();
stack.setId(STACK_ID);
stack.setName("stackname");
StackStatus stackStatus = new StackStatus(stack, Status.AVAILABLE, "no reason at all", DetailedStackStatus.AVAILABLE);
stack.setStackStatus(stackStatus);
stack.setCluster(new Cluster());
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.StackStatus 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;
}
use of com.sequenceiq.cloudbreak.domain.stack.StackStatus in project cloudbreak by hortonworks.
the class TerminationTriggerServiceTest method stackWithStatus.
private Stack stackWithStatus(Status status) {
Stack stack = new Stack();
stack.setId(1L);
stack.setEnvironmentCrn("envcrn");
stack.setName("stackname");
StackStatus stackStatus = new StackStatus();
stackStatus.setStatus(status);
stack.setStackStatus(stackStatus);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.StackStatus in project cloudbreak by hortonworks.
the class StackStatusIntegrationTest method availableStackInstancesAreHealthy.
@Test
@DisplayName("GIVEN an available stack " + "WHEN all instances are healthy " + "THEN stack is still available")
void availableStackInstancesAreHealthy() throws JobExecutionException {
setUpClusterStatus(ClusterStatus.STARTED);
stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.AVAILABLE));
setUpHealthForInstance(INSTANCE_1, HealthCheckResult.HEALTHY);
setUpHealthForInstance(INSTANCE_2, HealthCheckResult.HEALTHY);
setUpCloudVmInstanceStatuses(Map.of(INSTANCE_1, com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.STARTED, INSTANCE_2, com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.STARTED));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.datahub()).thenReturn(regionAwareInternalCrnGenerator);
underTest.executeTracedJob(jobExecutionContext);
verify(instanceMetaDataService, never()).findHostInStack(eq(STACK_ID), any());
verify(hostGroupService, never()).getRepairViewByClusterIdAndName(anyLong(), anyString());
verify(flowManager, never()).triggerClusterRepairFlow(anyLong(), any(), anyBoolean());
verify(instanceMetaDataService, never()).saveAll(any());
verify(clusterService, never()).updateClusterStatusByStackId(any(), any(), any());
verify(clusterService).updateClusterCertExpirationState(stack.getCluster(), false);
verify(instanceMetaDataService, never()).save(any());
verify(stackUpdater, never()).updateStackStatus(eq(STACK_ID), any(DetailedStackStatus.class));
verify(stackUpdater, never()).updateStackStatus(eq(STACK_ID), any(), any());
}
use of com.sequenceiq.cloudbreak.domain.stack.StackStatus in project cloudbreak by hortonworks.
the class StackStatusIntegrationTest method availableStackAllInstancesGoesDown.
@Test
@DisplayName("GIVEN an available stack " + "WHEN all instances go down " + "THEN stack is no more available")
void availableStackAllInstancesGoesDown() throws JobExecutionException {
setUpClusterStatus(ClusterStatus.STARTED);
stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.AVAILABLE));
setUpHealthForInstance(INSTANCE_1, HealthCheckResult.HEALTHY);
setUpHealthForInstance(INSTANCE_2, HealthCheckResult.UNHEALTHY);
setUpCloudVmInstanceStatuses(Map.of(INSTANCE_1, com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.TERMINATED_BY_PROVIDER, INSTANCE_2, com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.TERMINATED_BY_PROVIDER));
when(instanceMetaDataService.findNotTerminatedAndNotZombieForStackWithoutInstanceGroups(STACK_ID)).thenReturn(Set.of());
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.datahub()).thenReturn(regionAwareInternalCrnGenerator);
underTest.executeTracedJob(jobExecutionContext);
verify(instanceMetaDataService, never()).findHostInStack(eq(STACK_ID), any());
verify(hostGroupService, never()).getRepairViewByClusterIdAndName(anyLong(), anyString());
verify(flowManager, never()).triggerClusterRepairFlow(anyLong(), any(), anyBoolean());
verify(instanceMetaDataService, never()).saveAll(any());
verify(clusterService, never()).updateClusterStatusByStackId(any(), any(), any());
verify(clusterService).updateClusterCertExpirationState(stack.getCluster(), false);
assertInstancesSavedWithStatuses(Map.of(INSTANCE_1, InstanceStatus.DELETED_BY_PROVIDER, INSTANCE_2, InstanceStatus.DELETED_BY_PROVIDER));
verify(stackUpdater).updateStackStatus(eq(STACK_ID), eq(DetailedStackStatus.DELETED_ON_PROVIDER_SIDE), any());
}
Aggregations