use of org.bf2.operator.resources.v1alpha1.StrimziVersionStatus in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManager method setStrimziPendingInstallationVersions.
/**
* Notify the strimzi manager of pending versions.
* @param pendingVersions
* @return true if the pending state has changed
*/
public boolean setStrimziPendingInstallationVersions(List<String> pendingVersions) {
if (!Collections.disjoint(strimziPendingInstallationVersions.keySet(), pendingVersions)) {
return false;
}
log.infof("Notified of pending strimzi versions %s", pendingVersions);
ConcurrentHashMap<String, StrimziVersionStatus> next = new ConcurrentHashMap<>();
for (String version : pendingVersions) {
StrimziVersionStatus existing = strimziVersions.get(version);
if (existing != null) {
next.put(version, new StrimziVersionStatusBuilder(existing).withReady(false).build());
} else {
next.put(version, EMPTY_STATUS);
}
}
this.strimziPendingInstallationVersions = next;
informerManager.resyncManagedKafkaAgent();
return true;
}
use of org.bf2.operator.resources.v1alpha1.StrimziVersionStatus 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.StrimziVersionStatus in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class StrimziManager method getStrimziVersions.
/**
* @return list of installed Strimzi versions with related readiness status. it will not
* include versions that may be removed or non-common versions that are pending installation.
* Common versions are those found in both an old and a new CSV.
*/
public List<StrimziVersionStatus> getStrimziVersions() {
Map<String, StrimziVersionStatus> nextVersions = new HashMap<>(strimziPendingInstallationVersions);
Map<String, StrimziVersionStatus> result = this.strimziVersions;
// if there are pending versions, then merge the lists by keeping only the valid next
if (!nextVersions.isEmpty()) {
result = nextVersions;
for (Iterator<Map.Entry<String, StrimziVersionStatus>> iter = result.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<String, StrimziVersionStatus> entry = iter.next();
StrimziVersionStatus live = this.strimziVersions.get(entry.getKey());
if (live != null) {
entry.setValue(live);
} else if (entry.getValue() == EMPTY_STATUS) {
iter.remove();
}
}
}
return new ArrayList<>(result.values());
}
use of org.bf2.operator.resources.v1alpha1.StrimziVersionStatus 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.StrimziVersionStatus in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaController method validity.
/**
* Run a validity check on the ManagedKafka custom resource
*
* @param managedKafka ManagedKafka custom resource to validate
* @return readiness indicating an error in the ManagedKafka custom resource, empty Optional otherwise
*/
private Optional<OperandReadiness> validity(ManagedKafka managedKafka) {
String message = null;
StrimziVersionStatus strimziVersion = this.strimziManager.getStrimziVersion(managedKafka.getSpec().getVersions().getStrimzi());
if (strimziVersion == null) {
message = String.format("The requested Strimzi version %s is not supported", managedKafka.getSpec().getVersions().getStrimzi());
} else {
if (!strimziVersion.getKafkaVersions().contains(managedKafka.getSpec().getVersions().getKafka())) {
message = String.format("The requested Kafka version %s is not supported by the Strimzi version %s", managedKafka.getSpec().getVersions().getKafka(), strimziVersion.getVersion());
} else if (managedKafka.getSpec().getVersions().getKafkaIbp() != null && !strimziVersion.getKafkaIbpVersions().contains(managedKafka.getSpec().getVersions().getKafkaIbp())) {
message = String.format("The requested Kafka inter broker protocol version %s is not supported by the Strimzi version %s", managedKafka.getSpec().getVersions().getKafkaIbp(), strimziVersion.getVersion());
}
}
if (message != null) {
log.error(message);
return Optional.of(new OperandReadiness(Status.False, Reason.Error, message));
}
return Optional.empty();
}
Aggregations