Search in sources :

Example 1 with StrimziVersionStatus

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;
}
Also used : StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) StrimziVersionStatusBuilder(org.bf2.operator.resources.v1alpha1.StrimziVersionStatusBuilder) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 2 with StrimziVersionStatus

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();
            }
        }
    }
}
Also used : StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) ArrayList(java.util.ArrayList) ManagedKafkaAgent(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent)

Example 3 with StrimziVersionStatus

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());
}
Also used : StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 4 with StrimziVersionStatus

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();
}
Also used : Status(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status) StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) ManagedKafkaAgentStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus) ManagedKafkaAgentStatusBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder) StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) ClusterResizeInfoBuilder(org.bf2.operator.resources.v1alpha1.ClusterResizeInfoBuilder) ClusterCapacity(org.bf2.operator.resources.v1alpha1.ClusterCapacity) ClusterCapacityBuilder(org.bf2.operator.resources.v1alpha1.ClusterCapacityBuilder) NodeCountsBuilder(org.bf2.operator.resources.v1alpha1.NodeCountsBuilder) NodeCounts(org.bf2.operator.resources.v1alpha1.NodeCounts) ManagedKafkaCondition(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition) ClusterResizeInfo(org.bf2.operator.resources.v1alpha1.ClusterResizeInfo) ManagedKafkaAgentStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus)

Example 5 with StrimziVersionStatus

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();
}
Also used : StrimziVersionStatus(org.bf2.operator.resources.v1alpha1.StrimziVersionStatus) OperandReadiness(org.bf2.operator.operands.OperandReadiness)

Aggregations

StrimziVersionStatus (org.bf2.operator.resources.v1alpha1.StrimziVersionStatus)5 ArrayList (java.util.ArrayList)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 OperandReadiness (org.bf2.operator.operands.OperandReadiness)1 ClusterCapacity (org.bf2.operator.resources.v1alpha1.ClusterCapacity)1 ClusterCapacityBuilder (org.bf2.operator.resources.v1alpha1.ClusterCapacityBuilder)1 ClusterResizeInfo (org.bf2.operator.resources.v1alpha1.ClusterResizeInfo)1 ClusterResizeInfoBuilder (org.bf2.operator.resources.v1alpha1.ClusterResizeInfoBuilder)1 ManagedKafkaAgent (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent)1 ManagedKafkaAgentStatus (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatus)1 ManagedKafkaAgentStatusBuilder (org.bf2.operator.resources.v1alpha1.ManagedKafkaAgentStatusBuilder)1 ManagedKafkaCondition (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition)1 Status (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status)1 NodeCounts (org.bf2.operator.resources.v1alpha1.NodeCounts)1 NodeCountsBuilder (org.bf2.operator.resources.v1alpha1.NodeCountsBuilder)1 StrimziVersionStatusBuilder (org.bf2.operator.resources.v1alpha1.StrimziVersionStatusBuilder)1