Search in sources :

Example 1 with ManagedKafkaResourceType

use of org.bf2.systemtest.framework.resource.ManagedKafkaResourceType in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class ManagedKafkaResourceType method readiness.

@Override
public Predicate<ManagedKafka> readiness(KubeClient client) {
    AtomicInteger count = new AtomicInteger();
    Set<String> messages = Collections.synchronizedSet(new LinkedHashSet<>());
    return mk -> {
        if (mk == null) {
            throw new IllegalStateException("ManagedKafka is null");
        }
        ManagedKafkaCondition mkc = getCondition(mk.getStatus(), ManagedKafkaCondition.Type.Ready).orElse(null);
        if (mkc == null) {
            return false;
        }
        if (ManagedKafkaCondition.Status.True.name().equals(mkc.getStatus())) {
            return true;
        }
        if (ManagedKafkaCondition.Reason.Error.name().equals(mkc.getReason())) {
            if (messages.add(mkc.getMessage())) {
                LOGGER.warn("ManagedKafka {} in error state {}", mk.getMetadata().getName(), mkc.getMessage());
            }
        // throw new IllegalStateException(String.format("ManagedKafka %s in error state %s", mk.getMetadata().getName(), mkc.getMessage()));
        }
        if (count.getAndIncrement() % 15 == 0) {
            ListOptions opts = new ListOptionsBuilder().withFieldSelector("status.phase=Pending").build();
            client.client().pods().inNamespace(mk.getMetadata().getNamespace()).withLabel("strimzi.io/cluster").list(opts).getItems().forEach(ManagedKafkaResourceType::checkUnschedulablePod);
        }
        return false;
    };
}
Also used : KubernetesResourceList(io.fabric8.kubernetes.api.model.KubernetesResourceList) MixedOperation(io.fabric8.kubernetes.client.dsl.MixedOperation) ListOptionsBuilder(io.fabric8.kubernetes.api.model.ListOptionsBuilder) ListOptions(io.fabric8.kubernetes.api.model.ListOptions) Resource(io.fabric8.kubernetes.client.dsl.Resource) KubeClient(org.bf2.test.k8s.KubeClient) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ManagedKafkaStatus(org.bf2.operator.resources.v1alpha1.ManagedKafkaStatus) LinkedHashSet(java.util.LinkedHashSet) KeycloakInstance(org.bf2.systemtest.framework.KeycloakInstance) SecurityUtils(org.bf2.systemtest.framework.SecurityUtils) Predicate(java.util.function.Predicate) TestUtils(org.bf2.test.TestUtils) Pod(io.fabric8.kubernetes.api.model.Pod) SystemTestEnvironment(org.bf2.systemtest.framework.SystemTestEnvironment) Set(java.util.Set) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Collectors(java.util.stream.Collectors) List(java.util.List) Logger(org.apache.logging.log4j.Logger) ManagedKafkaCondition(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition) Optional(java.util.Optional) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) Collections(java.util.Collections) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ListOptions(io.fabric8.kubernetes.api.model.ListOptions) ListOptionsBuilder(io.fabric8.kubernetes.api.model.ListOptionsBuilder) ManagedKafkaCondition(org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition)

Example 2 with ManagedKafkaResourceType

use of org.bf2.systemtest.framework.resource.ManagedKafkaResourceType in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class ManagedKafkaDeployment method start.

public void start() {
    ManagedKafkaResourceType type = new ManagedKafkaResourceType();
    Resource<ManagedKafka> resource = type.resource(cluster.kubeClient(), managedKafka);
    Predicate<ManagedKafka> readyCheck = type.readiness(cluster.kubeClient());
    readyFuture = TestUtils.asyncWaitFor("cluster ready", 1000, 600_000, () -> readyCheck.test(resource.get()));
}
Also used : ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaResourceType(org.bf2.systemtest.framework.resource.ManagedKafkaResourceType)

Aggregations

ManagedKafka (org.bf2.operator.resources.v1alpha1.ManagedKafka)2 KubernetesResourceList (io.fabric8.kubernetes.api.model.KubernetesResourceList)1 ListOptions (io.fabric8.kubernetes.api.model.ListOptions)1 ListOptionsBuilder (io.fabric8.kubernetes.api.model.ListOptionsBuilder)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1 Kafka (io.strimzi.api.kafka.model.Kafka)1 Collections (java.util.Collections)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 ManagedKafkaCondition (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition)1