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);
});
}
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());
}
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);
}
}
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);
}
Aggregations