use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziBundleManager method updateStatus.
/**
* Update status of ManagedKafkaAgent resource about approval of Strimzi bundle installation
* NOTE: it creates a condition if Strimzi bundle installation was not approved. The condition is taken out if approved.
*
* @param approval the status of the approval
*/
private void updateStatus(Approval approval) {
ManagedKafkaAgent resource = this.agentClient.getByName(this.agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME);
if (resource != null && resource.getStatus() != null) {
List<ManagedKafkaCondition> conditions = resource.getStatus().getConditions();
ManagedKafkaCondition bundleReadyCondition = ConditionUtils.findManagedKafkaCondition(conditions, ManagedKafkaCondition.Type.StrimziBundleReady).orElse(null);
ManagedKafkaCondition.Reason reason = ManagedKafkaCondition.Reason.OrphanedKafkas;
ManagedKafkaCondition.Status status = ManagedKafkaCondition.Status.False;
if (approval != Approval.ORPHANED) {
if (bundleReadyCondition == null) {
return;
}
conditions.remove(bundleReadyCondition);
} else {
if (bundleReadyCondition == null) {
bundleReadyCondition = ConditionUtils.buildCondition(ManagedKafkaCondition.Type.StrimziBundleReady, status);
bundleReadyCondition.reason(reason);
conditions.add(bundleReadyCondition);
} else {
ConditionUtils.updateConditionStatus(bundleReadyCondition, status, reason, null);
}
}
this.agentClient.replaceStatus(resource);
}
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManager method updateStatus.
private void updateStatus() {
List<StrimziVersionStatus> versions = new ArrayList<>(this.strimziVersions.values());
// create the Kafka informer only when a Strimzi bundle is installed (aka at least one available version)
if (!versions.isEmpty()) {
informerManager.createKafkaInformer();
}
ManagedKafkaAgent resource = agentClient.getByName(agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME);
if (resource != null && resource.getStatus() != null) {
List<StrimziVersionStatus> existing = resource.getStatus().getStrimzi();
if (!versions.equals(existing)) {
log.debugf("Updating Strimzi versions %s", versions);
resource.getStatus().setStrimzi(versions);
agentClient.replaceStatus(resource);
// version changes should sync the managed kafkas
if (existing == null || !toVersionKeySet(versions).equals(toVersionKeySet(existing))) {
informerManager.resyncManagedKafka();
}
}
}
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent 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();
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaAgentSync method createOrUpdateManagedKafkaAgent.
private void createOrUpdateManagedKafkaAgent(ManagedKafkaAgent remoteAgent) {
ManagedKafkaAgent resource = lookup.getLocalManagedKafkaAgent();
if (resource == null) {
// the informer may not have run yet, so check more definitively
resource = this.agentClient.getByName(this.agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME);
}
if (resource == null) {
remoteAgent.getMetadata().setNamespace(agentClient.getNamespace());
remoteAgent.getMetadata().setName(ManagedKafkaAgentResourceClient.RESOURCE_NAME);
this.agentClient.create(remoteAgent);
log.infof("ManagedKafkaAgent CR created");
} else if (!remoteAgent.getSpec().equals(resource.getSpec())) {
this.agentClient.edit(this.agentClient.getNamespace(), ManagedKafkaAgentResourceClient.RESOURCE_NAME, mka -> {
mka.setSpec(remoteAgent.getSpec());
return mka;
});
log.infof("ManagedKafkaAgent CR updated");
}
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaAgentSync method loop.
@Timed(value = "sync.poll", extraTags = { "resource", "ManagedKafkaAgent" }, description = "The time spent processing polling calls")
@Counted(value = "sync.poll", extraTags = { "resource", "ManagedKafkaAgent" }, description = "The number of polling calls")
@Scheduled(every = "{poll.interval}", concurrentExecution = ConcurrentExecution.SKIP)
void loop() {
ManagedKafkaAgent managedKafkaAgent = controlPlane.getManagedKafkaAgent();
Objects.requireNonNull(managedKafkaAgent);
createOrUpdateManagedKafkaAgent(managedKafkaAgent);
}
Aggregations