Search in sources :

Example 6 with Version

use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaManager method currentKafkaVersion.

/**
 * Returns the current Kafka version for the Kafka instance
 * It comes directly from the Kafka custom resource or from the ManagedKafka in case of creation
 *
 * @param managedKafka ManagedKafka instance
 * @return current Kafka version for the Kafka instance
 */
public String currentKafkaVersion(ManagedKafka managedKafka) {
    Kafka kafka = cachedKafka(managedKafka);
    // on first time Kafka resource creation, we take the Kafka version from the ManagedKafka resource spec
    String kafkaVersion = kafka != null ? kafka.getSpec().getKafka().getVersion() : managedKafka.getSpec().getVersions().getKafka();
    log.debugf("[%s/%s] currentKafkaVersion = %s", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), kafkaVersion);
    return kafkaVersion;
}
Also used : Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka)

Example 7 with Version

use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaManager method currentKafkaLogMessageFormatVersion.

/**
 * Returns the current Kafka log message format version for the Kafka instance
 * It comes directly from the Kafka custom resource or from the ManagedKafka in case of creation
 *
 * @param managedKafka ManagedKafka instance
 * @return current Kafka log message format version for the Kafka instance
 */
public String currentKafkaLogMessageFormatVersion(ManagedKafka managedKafka) {
    Kafka kafka = cachedKafka(managedKafka);
    String kafkaLogMessageFormatVersion;
    String current;
    // on first time Kafka resource creation, we take the Kafka log message format version from the ManagedKafka resource spec
    if (kafka != null) {
        Object logMessageFormat = kafka.getSpec().getKafka().getConfig().get("log.message.format.version");
        current = logMessageFormat != null ? logMessageFormat.toString() : kafka.getSpec().getKafka().getVersion();
    } else {
        current = managedKafka.getSpec().getVersions().getKafka();
    }
    kafkaLogMessageFormatVersion = AbstractKafkaCluster.getKafkaLogMessageFormatVersion(current);
    log.debugf("[%s/%s] currentKafkaLogMessageFormatVersion = %s", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), kafkaLogMessageFormatVersion);
    return kafkaLogMessageFormatVersion;
}
Also used : Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka)

Example 8 with Version

use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaManager method currentKafkaIbpVersion.

/**
 * Returns the current Kafka inter broker protocol version for the Kafka instance
 * It comes directly from the Kafka custom resource or from the ManagedKafka in case of creation
 *
 * @param managedKafka ManagedKafka instance
 * @return current Kafka inter broker protocol version for the Kafka instance
 */
public String currentKafkaIbpVersion(ManagedKafka managedKafka) {
    Kafka kafka = cachedKafka(managedKafka);
    String kafkaIbpVersion;
    // on first time Kafka resource creation, we take the Kafka inter broker protocol version from the ManagedKafka resource spec
    if (kafka != null) {
        Object interBrokerProtocol = kafka.getSpec().getKafka().getConfig().get("inter.broker.protocol.version");
        kafkaIbpVersion = interBrokerProtocol != null ? AbstractKafkaCluster.getKafkaIbpVersion(interBrokerProtocol.toString()) : AbstractKafkaCluster.getKafkaIbpVersion(kafka.getSpec().getKafka().getVersion());
    } else {
        kafkaIbpVersion = managedKafka.getSpec().getVersions().getKafkaIbp();
        // dealing with ManagedKafka instances not having the IBP field specified
        if (kafkaIbpVersion == null) {
            kafkaIbpVersion = AbstractKafkaCluster.getKafkaIbpVersion(managedKafka.getSpec().getVersions().getKafka());
        }
    }
    log.debugf("[%s/%s] currentKafkaIbpVersion = %s", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), kafkaIbpVersion);
    return kafkaIbpVersion;
}
Also used : Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka)

Example 9 with Version

use of org.bf2.cos.fleetshard.api.Version 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 10 with Version

use of org.bf2.cos.fleetshard.api.Version in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class OlmBasedStrimziOperatorManager method isSubscriptionInstalled.

private boolean isSubscriptionInstalled() {
    OpenShiftClient client = kubeClient.client().adapt(OpenShiftClient.class);
    Subscription s = client.operatorHub().subscriptions().inNamespace(namespace).withName(OLM_SUBSCRIPTION_NAME).get();
    if (s != null && s.getStatus() != null && !s.getStatus().getCatalogHealth().isEmpty()) {
        List<SubscriptionCatalogHealth> healths = s.getStatus().getCatalogHealth();
        boolean result = !healths.stream().filter(h -> h.getHealthy()).map(ref -> ref.getCatalogSourceRef()).filter(h -> h.getName().equals(CATALOG_SOURCE_NAME)).collect(Collectors.toList()).isEmpty();
        if (result) {
            String currentCsv = s.getStatus().getCurrentCSV();
            if (currentCsv == null) {
                return false;
            }
            ClusterServiceVersion csv = client.operatorHub().clusterServiceVersions().inNamespace(namespace).withName(currentCsv).get();
            if (csv == null) {
                return false;
            }
            versions = csv.getSpec().getInstall().getSpec().getDeployments().stream().map(sds -> sds.getName()).filter(version -> version.startsWith("strimzi-cluster-operator.")).collect(Collectors.toList());
        }
        return result;
    }
    return false;
}
Also used : CatalogSource(io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSource) StrimziOperatorManager(org.bf2.systemtest.operator.StrimziOperatorManager) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) OperatorGroupBuilder(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupBuilder) CatalogSourceBuilder(io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSourceBuilder) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Collectors(java.util.stream.Collectors) SubscriptionBuilder(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder) List(java.util.List) OperatorGroup(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) Logger(org.apache.logging.log4j.Logger) KubeClient(org.bf2.test.k8s.KubeClient) SubscriptionCatalogHealth(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth) Map(java.util.Map) NamespaceBuilder(io.fabric8.kubernetes.api.model.NamespaceBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) SubscriptionCatalogHealth(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth)

Aggregations

ManagedKafka (org.bf2.operator.resources.v1alpha1.ManagedKafka)10 Test (org.junit.jupiter.api.Test)6 Kafka (io.strimzi.api.kafka.model.Kafka)5 ManagedConnector (org.bf2.cos.fleetshard.api.ManagedConnector)5 NamespaceBuilder (io.fabric8.kubernetes.api.model.NamespaceBuilder)4 QuarkusTest (io.quarkus.test.junit.QuarkusTest)4 ArrayList (java.util.ArrayList)4 Collections (java.util.Collections)4 List (java.util.List)4 Map (java.util.Map)4 Objects (java.util.Objects)4 Collectors (java.util.stream.Collectors)4 LoggerFactory (org.slf4j.LoggerFactory)4 Namespace (io.fabric8.kubernetes.api.model.Namespace)3 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)3 OperatorSelector (org.bf2.cos.fleetshard.api.OperatorSelector)3 StrimziVersionStatus (org.bf2.operator.resources.v1alpha1.StrimziVersionStatus)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 Container (io.fabric8.kubernetes.api.model.Container)2 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)2