Search in sources :

Example 1 with Versions

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

Example 2 with Versions

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

Example 3 with Versions

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

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

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;
    }
}
Also used : Versions(org.bf2.operator.resources.v1alpha1.Versions) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)11 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)6 StrimziVersionStatus (org.bf2.operator.resources.v1alpha1.StrimziVersionStatus)4 VersionsService (com.netflix.spinnaker.halyard.config.services.v1.VersionsService)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)2 DeploymentType (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment.DeploymentType)2 Validator (com.netflix.spinnaker.halyard.config.model.v1.node.Validator)2 ConfigProblemSetBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder)2 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ManagedKafka (org.bf2.operator.resources.v1alpha1.ManagedKafka)2 Versions (org.bf2.operator.resources.v1alpha1.Versions)2 Test (org.junit.jupiter.api.Test)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1