use of org.bf2.operator.resources.v1alpha1.Versions 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.Versions 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.Versions 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.Versions 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.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class VersionsTest method testCompareStrimziVersionToMajor.
@ParameterizedTest
@CsvSource({ "strimzi-cluster-operator.v0.22.1-6, 0.22.1-5, GT", "strimzi-cluster-operator.v0.22.1-6, 0.22.1-6, EQ", "strimzi-cluster-operator.v0.22.1-6, 0.22.1-7, LT", "strimzi-cluster-operator.v0.23.0, 0.23.0-1, LT", "strimzi-cluster-operator.v0.23.1, 0.23.0-1, GT", "0.23.1, 0.22.1, GT", ".23.1, .24.1, LT", "0.23.1-0, 0.23.1, GT", "0.22, 0.23.0-1, LT" })
void testCompareStrimziVersionToMajor(String strimziVersion, String compareToVersion, String expectation) {
Versions versions = new Versions();
versions.setStrimzi(strimziVersion);
switch(expectation) {
case "LT":
assertTrue(versions.compareStrimziVersionTo(compareToVersion) < 0);
break;
case "EQ":
assertEquals(0, versions.compareStrimziVersionTo(compareToVersion));
break;
case "GT":
assertTrue(versions.compareStrimziVersionTo(compareToVersion) > 0);
break;
}
}
Aggregations