Search in sources :

Example 76 with Condition

use of io.strimzi.api.kafka.model.status.Condition in project strimzi-kafka-operator by strimzi.

the class CustomResourceStatusIsolatedST method assertKafkaTopicWrongMinInSyncReplicasStatus.

void assertKafkaTopicWrongMinInSyncReplicasStatus(String topicName, String invalidValue) {
    KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(clusterOperator.getDeploymentNamespace()).withName(topicName).get().getStatus();
    assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getType().equals(NotReady.toString())), is(true));
    assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getReason().equals("InvalidRequestException")), is(true));
    assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getMessage().contains(String.format("Invalid value %s for configuration min.insync.replicas", invalidValue))), is(true));
}
Also used : KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus) Quantity(io.fabric8.kubernetes.api.model.Quantity) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) DeletionPropagation(io.fabric8.kubernetes.api.model.DeletionPropagation) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) Disabled(org.junit.jupiter.api.Disabled) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) BeforeAll(org.junit.jupiter.api.BeforeAll) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus) BeforeAllOnce(io.strimzi.systemtest.BeforeAllOnce) KafkaMirrorMaker2Templates(io.strimzi.systemtest.templates.crd.KafkaMirrorMaker2Templates) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) KafkaMirrorMakerUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaMirrorMakerUtils) KafkaMirrorMaker2Resources(io.strimzi.api.kafka.model.KafkaMirrorMaker2Resources) ListenerStatus(io.strimzi.api.kafka.model.status.ListenerStatus) Logger(org.apache.logging.log4j.Logger) KafkaUtils.getKafkaStatusCertificates(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils.getKafkaStatusCertificates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) KafkaConnectorStatus(io.strimzi.api.kafka.model.status.KafkaConnectorStatus) KafkaMirrorMaker2Utils(io.strimzi.systemtest.utils.kafkaUtils.KafkaMirrorMaker2Utils) KafkaMirrorMakerStatus(io.strimzi.api.kafka.model.status.KafkaMirrorMakerStatus) AbstractST(io.strimzi.systemtest.AbstractST) GenericKafkaListener(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener) KafkaConnectTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectTemplates) CONNECT(io.strimzi.systemtest.Constants.CONNECT) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) ExternalKafkaClient(io.strimzi.systemtest.kafkaclients.externalClients.ExternalKafkaClient) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) MIRROR_MAKER(io.strimzi.systemtest.Constants.MIRROR_MAKER) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) LinkedHashMap(java.util.LinkedHashMap) KafkaConnectorResource(io.strimzi.systemtest.resources.crd.KafkaConnectorResource) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) KRaftNotSupported(io.strimzi.systemtest.annotations.KRaftNotSupported) KafkaBridgeUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaBridgeUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Constants(io.strimzi.systemtest.Constants) ConnectorPlugin(io.strimzi.api.kafka.model.connect.ConnectorPlugin) EXTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.EXTERNAL_CLIENTS_USED) SetupClusterOperator(io.strimzi.systemtest.resources.operator.SetupClusterOperator) KafkaMirrorMakerResource(io.strimzi.systemtest.resources.crd.KafkaMirrorMakerResource) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) ResourceManager(io.strimzi.systemtest.resources.ResourceManager) KafkaUserUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUserUtils) CONNECTOR_OPERATOR(io.strimzi.systemtest.Constants.CONNECTOR_OPERATOR) CONNECT_COMPONENTS(io.strimzi.systemtest.Constants.CONNECT_COMPONENTS) KafkaMirrorMaker2Resource(io.strimzi.systemtest.resources.crd.KafkaMirrorMaker2Resource) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) CoreMatchers.is(org.hamcrest.CoreMatchers.is) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Annotations(io.strimzi.operator.common.Annotations) KafkaConnectResource(io.strimzi.systemtest.resources.crd.KafkaConnectResource) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) KafkaUtils.getKafkaSecretCertificates(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils.getKafkaSecretCertificates) KafkaConnectUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaConnectUtils) KafkaConnectStatus(io.strimzi.api.kafka.model.status.KafkaConnectStatus) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) KafkaMirrorMaker2Status(io.strimzi.api.kafka.model.status.KafkaMirrorMaker2Status) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) KafkaBridgeResource(io.strimzi.systemtest.resources.crd.KafkaBridgeResource) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) KafkaConnectorTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectorTemplates) Condition(io.strimzi.api.kafka.model.status.Condition) KafkaTopicResource(io.strimzi.systemtest.resources.crd.KafkaTopicResource) Environment(io.strimzi.systemtest.Environment) KafkaStatus(io.strimzi.api.kafka.model.status.KafkaStatus) KafkaMirrorMakerTemplates(io.strimzi.systemtest.templates.crd.KafkaMirrorMakerTemplates) KafkaUserResource(io.strimzi.systemtest.resources.crd.KafkaUserResource) TestStorage(io.strimzi.systemtest.storage.TestStorage) NotReady(io.strimzi.systemtest.enums.CustomResourceStatus.NotReady) TestUtils(io.strimzi.test.TestUtils) Service(io.fabric8.kubernetes.api.model.Service) NODEPORT_SUPPORTED(io.strimzi.systemtest.Constants.NODEPORT_SUPPORTED) MIRROR_MAKER2(io.strimzi.systemtest.Constants.MIRROR_MAKER2) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) Ready(io.strimzi.systemtest.enums.CustomResourceStatus.Ready) KafkaUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) KafkaBridgeStatus(io.strimzi.api.kafka.model.status.KafkaBridgeStatus) KafkaConnectorUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaConnectorUtils) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) KafkaResources.externalBootstrapServiceName(io.strimzi.api.kafka.model.KafkaResources.externalBootstrapServiceName) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections)

Example 77 with Condition

use of io.strimzi.api.kafka.model.status.Condition in project strimzi-kafka-operator by strimzi.

the class CustomResourceStatusIsolatedST method assertKafkaTopicDecreasePartitionsStatus.

void assertKafkaTopicDecreasePartitionsStatus(String topicName) {
    KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(clusterOperator.getDeploymentNamespace()).withName(topicName).get().getStatus();
    assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getType().equals(NotReady.toString())), is(true));
    assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getReason().equals("PartitionDecreaseException")), is(true));
    assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getMessage().contains("Number of partitions cannot be decreased")), is(true));
}
Also used : KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus) Quantity(io.fabric8.kubernetes.api.model.Quantity) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) DeletionPropagation(io.fabric8.kubernetes.api.model.DeletionPropagation) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) Disabled(org.junit.jupiter.api.Disabled) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) BeforeAll(org.junit.jupiter.api.BeforeAll) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus) BeforeAllOnce(io.strimzi.systemtest.BeforeAllOnce) KafkaMirrorMaker2Templates(io.strimzi.systemtest.templates.crd.KafkaMirrorMaker2Templates) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) KafkaMirrorMakerUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaMirrorMakerUtils) KafkaMirrorMaker2Resources(io.strimzi.api.kafka.model.KafkaMirrorMaker2Resources) ListenerStatus(io.strimzi.api.kafka.model.status.ListenerStatus) Logger(org.apache.logging.log4j.Logger) KafkaUtils.getKafkaStatusCertificates(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils.getKafkaStatusCertificates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) KafkaConnectorStatus(io.strimzi.api.kafka.model.status.KafkaConnectorStatus) KafkaMirrorMaker2Utils(io.strimzi.systemtest.utils.kafkaUtils.KafkaMirrorMaker2Utils) KafkaMirrorMakerStatus(io.strimzi.api.kafka.model.status.KafkaMirrorMakerStatus) AbstractST(io.strimzi.systemtest.AbstractST) GenericKafkaListener(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener) KafkaConnectTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectTemplates) CONNECT(io.strimzi.systemtest.Constants.CONNECT) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) ExternalKafkaClient(io.strimzi.systemtest.kafkaclients.externalClients.ExternalKafkaClient) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) MIRROR_MAKER(io.strimzi.systemtest.Constants.MIRROR_MAKER) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) LinkedHashMap(java.util.LinkedHashMap) KafkaConnectorResource(io.strimzi.systemtest.resources.crd.KafkaConnectorResource) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) KRaftNotSupported(io.strimzi.systemtest.annotations.KRaftNotSupported) KafkaBridgeUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaBridgeUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Constants(io.strimzi.systemtest.Constants) ConnectorPlugin(io.strimzi.api.kafka.model.connect.ConnectorPlugin) EXTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.EXTERNAL_CLIENTS_USED) SetupClusterOperator(io.strimzi.systemtest.resources.operator.SetupClusterOperator) KafkaMirrorMakerResource(io.strimzi.systemtest.resources.crd.KafkaMirrorMakerResource) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) ResourceManager(io.strimzi.systemtest.resources.ResourceManager) KafkaUserUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUserUtils) CONNECTOR_OPERATOR(io.strimzi.systemtest.Constants.CONNECTOR_OPERATOR) CONNECT_COMPONENTS(io.strimzi.systemtest.Constants.CONNECT_COMPONENTS) KafkaMirrorMaker2Resource(io.strimzi.systemtest.resources.crd.KafkaMirrorMaker2Resource) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) CoreMatchers.is(org.hamcrest.CoreMatchers.is) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Annotations(io.strimzi.operator.common.Annotations) KafkaConnectResource(io.strimzi.systemtest.resources.crd.KafkaConnectResource) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) KafkaUtils.getKafkaSecretCertificates(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils.getKafkaSecretCertificates) KafkaConnectUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaConnectUtils) KafkaConnectStatus(io.strimzi.api.kafka.model.status.KafkaConnectStatus) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) KafkaMirrorMaker2Status(io.strimzi.api.kafka.model.status.KafkaMirrorMaker2Status) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) KafkaBridgeResource(io.strimzi.systemtest.resources.crd.KafkaBridgeResource) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) KafkaConnectorTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectorTemplates) Condition(io.strimzi.api.kafka.model.status.Condition) KafkaTopicResource(io.strimzi.systemtest.resources.crd.KafkaTopicResource) Environment(io.strimzi.systemtest.Environment) KafkaStatus(io.strimzi.api.kafka.model.status.KafkaStatus) KafkaMirrorMakerTemplates(io.strimzi.systemtest.templates.crd.KafkaMirrorMakerTemplates) KafkaUserResource(io.strimzi.systemtest.resources.crd.KafkaUserResource) TestStorage(io.strimzi.systemtest.storage.TestStorage) NotReady(io.strimzi.systemtest.enums.CustomResourceStatus.NotReady) TestUtils(io.strimzi.test.TestUtils) Service(io.fabric8.kubernetes.api.model.Service) NODEPORT_SUPPORTED(io.strimzi.systemtest.Constants.NODEPORT_SUPPORTED) MIRROR_MAKER2(io.strimzi.systemtest.Constants.MIRROR_MAKER2) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) Ready(io.strimzi.systemtest.enums.CustomResourceStatus.Ready) KafkaUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) KafkaBridgeStatus(io.strimzi.api.kafka.model.status.KafkaBridgeStatus) KafkaConnectorUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaConnectorUtils) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) KafkaResources.externalBootstrapServiceName(io.strimzi.api.kafka.model.KafkaResources.externalBootstrapServiceName) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections)

Example 78 with Condition

use of io.strimzi.api.kafka.model.status.Condition in project strimzi-kafka-operator by strimzi.

the class AllNamespaceIsolatedST method testUserInDifferentNamespace.

@IsolatedTest
@KRaftNotSupported("UserOperator is not supported by KRaft mode and is used in this test case")
void testUserInDifferentNamespace(ExtensionContext extensionContext) {
    final TestStorage testStorage = new TestStorage(extensionContext, SECOND_NAMESPACE);
    String startingNamespace = cluster.setNamespace(SECOND_NAMESPACE);
    KafkaUser user = KafkaUserTemplates.tlsUser(MAIN_NAMESPACE_CLUSTER_NAME, USER_NAME).build();
    resourceManager.createResource(extensionContext, user);
    Condition kafkaCondition = KafkaUserResource.kafkaUserClient().inNamespace(SECOND_NAMESPACE).withName(USER_NAME).get().getStatus().getConditions().get(0);
    LOGGER.info("KafkaUser condition status: {}", kafkaCondition.getStatus());
    LOGGER.info("KafkaUser condition type: {}", kafkaCondition.getType());
    assertThat(kafkaCondition.getType(), is(Ready.toString()));
    List<Secret> secretsOfSecondNamespace = kubeClient(SECOND_NAMESPACE).listSecrets();
    cluster.setNamespace(THIRD_NAMESPACE);
    for (Secret s : secretsOfSecondNamespace) {
        if (s.getMetadata().getName().equals(USER_NAME)) {
            LOGGER.info("Copying secret {} from namespace {} to namespace {}", s, SECOND_NAMESPACE, THIRD_NAMESPACE);
            copySecret(s, THIRD_NAMESPACE, USER_NAME);
        }
    }
    KafkaClients kafkaClients = new KafkaClientsBuilder().withTopicName(TOPIC_NAME).withMessageCount(MESSAGE_COUNT).withBootstrapAddress(KafkaResources.tlsBootstrapAddress(MAIN_NAMESPACE_CLUSTER_NAME)).withProducerName(testStorage.getProducerName()).withConsumerName(testStorage.getConsumerName()).withNamespaceName(THIRD_NAMESPACE).withUserName(USER_NAME).build();
    resourceManager.createResource(extensionContext, kafkaClients.producerTlsStrimzi(MAIN_NAMESPACE_CLUSTER_NAME), kafkaClients.consumerTlsStrimzi(MAIN_NAMESPACE_CLUSTER_NAME));
    ClientUtils.waitForClientsSuccess(testStorage.getProducerName(), testStorage.getConsumerName(), THIRD_NAMESPACE, MESSAGE_COUNT);
    cluster.setNamespace(startingNamespace);
}
Also used : Condition(io.strimzi.api.kafka.model.status.Condition) Secret(io.fabric8.kubernetes.api.model.Secret) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) TestStorage(io.strimzi.systemtest.storage.TestStorage) KafkaUser(io.strimzi.api.kafka.model.KafkaUser) KRaftNotSupported(io.strimzi.systemtest.annotations.KRaftNotSupported) IsolatedTest(io.strimzi.systemtest.annotations.IsolatedTest)

Example 79 with Condition

use of io.strimzi.api.kafka.model.status.Condition in project strimzi-kafka-operator by strimzi.

the class TopicOperatorBaseIT method assertStatusReady.

protected void assertStatusReady(String topicName) throws InterruptedException, ExecutionException, TimeoutException {
    waitFor(() -> {
        KafkaTopic kafkaTopic = operation().inNamespace(NAMESPACE).withName(topicName).get();
        if (kafkaTopic != null) {
            KafkaTopicStatus status = kafkaTopic.getStatus();
            if (status != null && Objects.equals(status.getObservedGeneration(), kafkaTopic.getMetadata().getGeneration()) && status.getConditions() != null) {
                List<Condition> conditions = status.getConditions();
                assertThat(conditions.size() > 0, is(true));
                if (conditions.stream().anyMatch(condition -> "Ready".equals(condition.getType()) && "True".equals(condition.getStatus()))) {
                    return true;
                } else {
                    LOGGER.info(conditions);
                }
            }
        } else {
            LOGGER.info("{} does not exist", topicName);
        }
        return false;
    }, "status ready for topic " + topicName);
}
Also used : KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus) Condition(io.strimzi.api.kafka.model.status.Condition) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic)

Example 80 with Condition

use of io.strimzi.api.kafka.model.status.Condition in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class DebeziumOperandSupport method computeStatus.

public static void computeStatus(ConnectorStatusSpec statusSpec, KafkaConnect kafkaConnect, KafkaConnector kafkaConnector) {
    statusSpec.setConditions(new ArrayList<>());
    statusSpec.setPhase(ManagedConnector.STATE_PROVISIONING);
    var readyCondition = new io.fabric8.kubernetes.api.model.Condition();
    readyCondition.setType("Ready");
    readyCondition.setStatus("False");
    readyCondition.setReason("Transitioning");
    boolean kafkaConnectorFailed = true;
    if (null != kafkaConnector) {
        for (Condition condition : kafkaConnector.getStatus().getConditions()) {
            var rc = cloneCondition(condition, "KafkaConnector:");
            switch(condition.getType()) {
                case "Ready":
                    readyCondition = cloneCondition(condition);
                    if ("True".equals(condition.getStatus())) {
                        statusSpec.setPhase(ManagedConnector.STATE_READY);
                        kafkaConnectorFailed = false;
                    }
                    break;
                case "NotReady":
                    if ("ConnectRestException".equals(condition.getReason())) {
                        readyCondition = cloneAsReadyFalseCondition(condition);
                        statusSpec.setPhase(ManagedConnector.STATE_FAILED);
                        break;
                    }
                    break;
                default:
                    break;
            }
            statusSpec.getConditions().add(rc);
        }
    }
    if (null != kafkaConnect) {
        for (Condition condition : kafkaConnect.getStatus().getConditions()) {
            var rc = cloneCondition(condition, "KafkaConnect:");
            switch(condition.getType()) {
                case "Ready":
                    if (!"True".equals(condition.getStatus())) {
                        if (!kafkaConnectorFailed) {
                            readyCondition = cloneCondition(condition);
                        }
                        statusSpec.setPhase(ManagedConnector.STATE_PROVISIONING);
                    }
                    break;
                case "NotReady":
                    if ("TimeoutException".equals(condition.getReason())) {
                        statusSpec.setPhase(ManagedConnector.STATE_FAILED);
                        if (!kafkaConnectorFailed) {
                            readyCondition = cloneAsReadyFalseCondition(condition);
                            readyCondition.setReason("KafkaClusterUnreachable");
                            readyCondition.setMessage("The configured Kafka Cluster is unreachable or ACLs deny access.");
                        }
                        break;
                    }
                    break;
                default:
                    break;
            }
            statusSpec.getConditions().add(rc);
        }
    }
    statusSpec.getConditions().add(readyCondition);
    if (null != kafkaConnector) {
        connector(kafkaConnector).map(KafkaConnectorStatus::getState).ifPresent(state -> {
            switch(state) {
                case KafkaConnectorStatus.STATE_FAILED:
                    statusSpec.setPhase(ManagedConnector.STATE_FAILED);
                    break;
                case KafkaConnectorStatus.STATE_UNASSIGNED:
                    statusSpec.setPhase(ManagedConnector.STATE_PROVISIONING);
                    break;
                case KafkaConnectorStatus.STATE_PAUSED:
                    statusSpec.setPhase(ManagedConnector.STATE_STOPPED);
                    break;
                default:
                    break;
            }
        });
    }
}
Also used : Condition(io.strimzi.api.kafka.model.status.Condition)

Aggregations

Condition (io.strimzi.api.kafka.model.status.Condition)150 Test (org.junit.jupiter.api.Test)70 Kafka (io.strimzi.api.kafka.model.Kafka)61 HashMap (java.util.HashMap)49 EphemeralStorage (io.strimzi.api.kafka.model.storage.EphemeralStorage)42 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)38 Collections (java.util.Collections)37 Vertx (io.vertx.core.Vertx)36 Map (java.util.Map)36 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)34 Labels (io.strimzi.operator.common.model.Labels)34 Future (io.vertx.core.Future)34 BeforeAll (org.junit.jupiter.api.BeforeAll)32 Reconciliation (io.strimzi.operator.common.Reconciliation)26 Checkpoint (io.vertx.junit5.Checkpoint)26 VertxExtension (io.vertx.junit5.VertxExtension)26 VertxTestContext (io.vertx.junit5.VertxTestContext)26 AfterAll (org.junit.jupiter.api.AfterAll)26 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)26 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)25