Search in sources :

Example 1 with ManagedKafkaAgentStatusBuilder

use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class ManagedKafkaAgentController method buildStatus.

/**
 * TODO: this needs to be replaced with actual metrics
 * @return
 */
private ManagedKafkaAgentStatus buildStatus(ManagedKafkaAgent resource) {
    ManagedKafkaAgentStatus status = resource.getStatus();
    ManagedKafkaCondition readyCondition = null;
    if (status != null) {
        readyCondition = ConditionUtils.findManagedKafkaCondition(status.getConditions(), Type.Ready).orElse(null);
    }
    List<StrimziVersionStatus> strimziVersions = this.strimziManager.getStrimziVersions();
    log.debugf("Strimzi versions %s", strimziVersions);
    // consider the fleetshard operator ready when observability is running and a Strimzi bundle is installed (aka at least one available version)
    Status statusValue = this.observabilityManager.isObservabilityRunning() && !strimziVersions.isEmpty() ? ManagedKafkaCondition.Status.True : ManagedKafkaCondition.Status.False;
    if (readyCondition == null) {
        readyCondition = ConditionUtils.buildCondition(ManagedKafkaCondition.Type.Ready, statusValue);
    } else {
        ConditionUtils.updateConditionStatus(readyCondition, statusValue, null, null);
    }
    ClusterCapacity total = new ClusterCapacityBuilder().withConnections(10000).withDataRetentionSize(Quantity.parse("40Gi")).withIngressEgressThroughputPerSec(Quantity.parse("40Gi")).withPartitions(10000).build();
    ClusterCapacity remaining = new ClusterCapacityBuilder().withConnections(10000).withDataRetentionSize(Quantity.parse("40Gi")).withIngressEgressThroughputPerSec(Quantity.parse("40Gi")).withPartitions(10000).build();
    ClusterCapacity delta = new ClusterCapacityBuilder().withConnections(10000).withDataRetentionSize(Quantity.parse("40Gi")).withIngressEgressThroughputPerSec(Quantity.parse("40Gi")).withPartitions(10000).build();
    NodeCounts nodeInfo = new NodeCountsBuilder().withCeiling(0).withCurrent(0).withCurrentWorkLoadMinimum(0).withFloor(0).build();
    ClusterResizeInfo resize = new ClusterResizeInfoBuilder().withDelta(delta).withNodeDelta(3).build();
    return new ManagedKafkaAgentStatusBuilder().withConditions(status == null ? Arrays.asList(readyCondition) : status.getConditions()).withTotal(total).withRemaining(remaining).withNodeInfo(nodeInfo).withResizeInfo(resize).withUpdatedTimestamp(ConditionUtils.iso8601Now()).withStrimzi(strimziVersions).build();
}
Also used : Status(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status) StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) ManagedKafkaAgentStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus) ManagedKafkaAgentStatusBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder) StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) ClusterResizeInfoBuilder(org.bf2.operator.resources.v1alpha1.ClusterResizeInfoBuilder) ClusterCapacity(org.bf2.operator.resources.v1alpha1.ClusterCapacity) ClusterCapacityBuilder(org.bf2.operator.resources.v1alpha1.ClusterCapacityBuilder) NodeCountsBuilder(org.bf2.operator.resources.v1alpha1.NodeCountsBuilder) NodeCounts(org.bf2.operator.resources.v1alpha1.NodeCounts) ManagedKafkaCondition(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition) ClusterResizeInfo(org.bf2.operator.resources.v1alpha1.ClusterResizeInfo) ManagedKafkaAgentStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus)

Example 2 with ManagedKafkaAgentStatusBuilder

use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class AgentPollerTest method testAddDelete.

@Test
public void testAddDelete() {
    assertNull(lookup.getLocalManagedKafkaAgent());
    ManagedKafkaAgent managedKafkaAgent = ManagedKafkaAgentResourceClient.getDummyInstance();
    Mockito.reset(controlPlaneRestClient);
    Mockito.when(controlPlaneRestClient.get(CLUSTER_ID)).thenReturn(managedKafkaAgent);
    // pick up the agent from the control plane
    managedKafkaAgentSync.loop();
    ManagedKafkaAgent local = lookup.getLocalManagedKafkaAgent();
    local.setStatus(new ManagedKafkaAgentStatusBuilder().withRemaining(new ClusterCapacityBuilder().withConnections(1000).build()).build());
    client.replaceStatus(local);
    assertEquals("test-token", local.getSpec().getObservability().getAccessToken());
    assertEquals(ManagedKafkaAgentResourceClient.RESOURCE_NAME, local.getMetadata().getName());
    managedKafkaAgent.getSpec().getObservability().setAccessToken("abc");
    // pick up the update
    managedKafkaAgentSync.loop();
    local = lookup.getLocalManagedKafkaAgent();
    assertEquals("abc", local.getSpec().getObservability().getAccessToken());
    assertEquals(1000, local.getStatus().getRemaining().getConnections());
}
Also used : ManagedKafkaAgentStatusBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder) ClusterCapacityBuilder(org.bf2.operator.resources.v1alpha1.ClusterCapacityBuilder) ManagedKafkaAgent(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterCapacityBuilder (org.bf2.operator.resources.v1alpha1.ClusterCapacityBuilder)2 ManagedKafkaAgentStatusBuilder (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder)2 QuarkusTest (io.quarkus.test.junit.QuarkusTest)1 ClusterCapacity (org.bf2.operator.resources.v1alpha1.ClusterCapacity)1 ClusterResizeInfo (org.bf2.operator.resources.v1alpha1.ClusterResizeInfo)1 ClusterResizeInfoBuilder (org.bf2.operator.resources.v1alpha1.ClusterResizeInfoBuilder)1 ManagedKafkaAgent (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent)1 ManagedKafkaAgentStatus (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus)1 ManagedKafkaCondition (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition)1 Status (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status)1 NodeCounts (org.bf2.operator.resources.v1alpha1.NodeCounts)1 NodeCountsBuilder (org.bf2.operator.resources.v1alpha1.NodeCountsBuilder)1 StrimziVersionStatus (org.bf2.operator.resources.v1alpha1.StrimziVersionStatus)1 Test (org.junit.jupiter.api.Test)1