Search in sources :

Example 6 with ManagedKafkaAgent

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

the class ControlPlane method updateAgentStatus.

private void updateAgentStatus() {
    log.debug("Updating agent status");
    executorService.execute(() -> {
        ManagedKafkaAgent localManagedKafkaAgent = localLookup.getLocalManagedKafkaAgent();
        if (localManagedKafkaAgent == null) {
            return;
        }
        ManagedKafkaAgentStatus status = localManagedKafkaAgent.getStatus();
        if (status == null) {
            // as they are not looking for this sync yet as a heartbeat
            return;
        }
        controlPlaneClient.updateStatus(id, status);
    });
}
Also used : ManagedKafkaAgent(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent) ManagedKafkaAgentStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus)

Example 7 with ManagedKafkaAgent

use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent 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)

Example 8 with ManagedKafkaAgent

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

the class ManagedKafkaAgentController method statusUpdateLoop.

@Timed(value = "controller.status.update", extraTags = { "resource", "ManagedKafkaAgent" }, description = "Time spent processing status updates")
@Counted(value = "controller.status.update", extraTags = { "resource", "ManagedKafkaAgent" }, description = "The number of status updates")
@Scheduled(every = "{agent.status.interval}", concurrentExecution = ConcurrentExecution.SKIP)
void statusUpdateLoop() {
    ManagedKafkaAgent resource = this.agentClient.getByName(this.agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME);
    if (resource != null) {
        // check and reinstate if the observability config changed
        this.observabilityManager.createOrUpdateObservabilitySecret(resource.getSpec().getObservability(), resource);
        log.debugf("Tick to update Kafka agent Status in namespace %s", this.agentClient.getNamespace());
        resource.setStatus(buildStatus(resource));
        this.agentClient.replaceStatus(resource);
    }
}
Also used : ManagedKafkaAgent(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent) Scheduled(io.quarkus.scheduler.Scheduled) Counted(io.micrometer.core.annotation.Counted) Timed(io.micrometer.core.annotation.Timed)

Example 9 with ManagedKafkaAgent

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

the class ManagedKafkaAgentControllerTest method shouldCreateStatus.

@Test
void shouldCreateStatus() {
    // try without an agent - nothing should happen
    mkaController.statusUpdateLoop();
    ManagedKafkaAgent dummyInstance = ManagedKafkaAgentResourceClient.getDummyInstance();
    dummyInstance.getMetadata().setNamespace(agentClient.getNamespace());
    assertNull(dummyInstance.getStatus());
    agentClient.create(dummyInstance);
    // should create the status even if
    mkaController.statusUpdateLoop();
    ManagedKafkaAgent agent = agentClient.getByName(agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME);
    assertNotNull(agent.getStatus());
    agentClient.delete(agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME);
}
Also used : ManagedKafkaAgent(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

ManagedKafkaAgent (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent)8 Counted (io.micrometer.core.annotation.Counted)3 Timed (io.micrometer.core.annotation.Timed)3 Scheduled (io.quarkus.scheduler.Scheduled)3 QuarkusTest (io.quarkus.test.junit.QuarkusTest)2 ClusterCapacityBuilder (org.bf2.operator.resources.v1alpha1.ClusterCapacityBuilder)2 ManagedKafkaAgentStatus (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus)2 ManagedKafkaAgentStatusBuilder (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder)2 ManagedKafkaCondition (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition)2 StrimziVersionStatus (org.bf2.operator.resources.v1alpha1.StrimziVersionStatus)2 Test (org.junit.jupiter.api.Test)2 ConcurrentExecution (io.quarkus.scheduler.Scheduled.ConcurrentExecution)1 ArrayList (java.util.ArrayList)1 Objects (java.util.Objects)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 ManagedKafkaAgentResourceClient (org.bf2.common.ManagedKafkaAgentResourceClient)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