Search in sources :

Example 36 with OrderedProperties

use of io.strimzi.operator.common.model.OrderedProperties in project strimzi-kafka-operator by strimzi.

the class AbstractConnectOperator method reconcileConnectors.

/**
 * Reconcile all the connectors selected by the given connect instance, updated each connectors status with the result.
 * @param reconciliation The reconciliation
 * @param connect The connector
 * @param connectStatus Status of the KafkaConnect  resource (will be used to set the available
 *                      connector plugins)
 * @param scaledToZero  Indicated whether the related Connect cluster is currently scaled to 0 replicas
 * @return A future, failed if any of the connectors' statuses could not be updated.
 */
protected Future<Void> reconcileConnectors(Reconciliation reconciliation, T connect, S connectStatus, boolean scaledToZero, String desiredLogging, OrderedProperties defaultLogging) {
    String connectName = connect.getMetadata().getName();
    String namespace = connect.getMetadata().getNamespace();
    String host = KafkaConnectResources.qualifiedServiceName(connectName, namespace);
    if (!isUseResources(connect)) {
        return Future.succeededFuture();
    }
    if (scaledToZero) {
        return connectorOperator.listAsync(namespace, Optional.of(new LabelSelectorBuilder().addToMatchLabels(Labels.STRIMZI_CLUSTER_LABEL, connectName).build())).compose(connectors -> CompositeFuture.join(connectors.stream().map(connector -> maybeUpdateConnectorStatus(reconciliation, connector, null, zeroReplicas(namespace, connectName))).collect(Collectors.toList()))).map((Void) null);
    }
    KafkaConnectApi apiClient = connectClientProvider.apply(vertx);
    return CompositeFuture.join(apiClient.list(host, port), connectorOperator.listAsync(namespace, Optional.of(new LabelSelectorBuilder().addToMatchLabels(Labels.STRIMZI_CLUSTER_LABEL, connectName).build())), apiClient.listConnectorPlugins(reconciliation, host, port), apiClient.updateConnectLoggers(reconciliation, host, port, desiredLogging, defaultLogging)).compose(cf -> {
        List<String> runningConnectorNames = cf.resultAt(0);
        List<KafkaConnector> desiredConnectors = cf.resultAt(1);
        List<ConnectorPlugin> connectorPlugins = cf.resultAt(2);
        LOGGER.debugCr(reconciliation, "Setting list of connector plugins in Kafka Connect status");
        connectStatus.setConnectorPlugins(connectorPlugins);
        Set<String> deleteConnectorNames = new HashSet<>(runningConnectorNames);
        deleteConnectorNames.removeAll(desiredConnectors.stream().map(c -> c.getMetadata().getName()).collect(Collectors.toSet()));
        LOGGER.debugCr(reconciliation, "{} cluster: delete connectors: {}", kind(), deleteConnectorNames);
        Stream<Future<Void>> deletionFutures = deleteConnectorNames.stream().map(connectorName -> reconcileConnectorAndHandleResult(reconciliation, host, apiClient, true, connectorName, null));
        LOGGER.debugCr(reconciliation, "{} cluster: required connectors: {}", kind(), desiredConnectors);
        Stream<Future<Void>> createUpdateFutures = desiredConnectors.stream().map(connector -> reconcileConnectorAndHandleResult(reconciliation, host, apiClient, true, connector.getMetadata().getName(), connector));
        return CompositeFuture.join(Stream.concat(deletionFutures, createUpdateFutures).collect(Collectors.toList())).map((Void) null);
    }).recover(error -> {
        if (error instanceof ConnectTimeoutException) {
            Promise<Void> connectorStatuses = Promise.promise();
            LOGGER.warnCr(reconciliation, "Failed to connect to the REST API => trying to update the connector status");
            connectorOperator.listAsync(namespace, Optional.of(new LabelSelectorBuilder().addToMatchLabels(Labels.STRIMZI_CLUSTER_LABEL, connectName).build())).compose(connectors -> CompositeFuture.join(connectors.stream().map(connector -> maybeUpdateConnectorStatus(reconciliation, connector, null, error)).collect(Collectors.toList()))).onComplete(ignore -> connectorStatuses.fail(error));
            return connectorStatuses.future();
        } else {
            return Future.failedFuture(error);
        }
    });
}
Also used : KafkaConnectorList(io.strimzi.api.kafka.KafkaConnectorList) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) CustomResourceList(io.fabric8.kubernetes.client.CustomResourceList) BiFunction(java.util.function.BiFunction) Watcher(io.fabric8.kubernetes.client.Watcher) Annotations(io.strimzi.operator.common.Annotations) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) ClusterRoleBindingOperator(io.strimzi.operator.common.operator.resource.ClusterRoleBindingOperator) ResourceVisitor(io.strimzi.operator.common.model.ResourceVisitor) Resource(io.fabric8.kubernetes.client.dsl.Resource) PodDisruptionBudgetV1Beta1Operator(io.strimzi.operator.common.operator.resource.PodDisruptionBudgetV1Beta1Operator) KafkaConnectStatus(io.strimzi.api.kafka.model.status.KafkaConnectStatus) Map(java.util.Map) KafkaConnectorSpec(io.strimzi.api.kafka.model.KafkaConnectorSpec) ANNO_STRIMZI_IO_RESTART_TASK(io.strimzi.operator.common.Annotations.ANNO_STRIMZI_IO_RESTART_TASK) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) JsonObject(io.vertx.core.json.JsonObject) Operator(io.strimzi.operator.common.Operator) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) Counter(io.micrometer.core.instrument.Counter) AbstractOperator(io.strimzi.operator.common.AbstractOperator) StatusUtils(io.strimzi.operator.common.operator.resource.StatusUtils) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) LabelSelectorBuilder(io.fabric8.kubernetes.api.model.LabelSelectorBuilder) ConnectTimeoutException(io.netty.channel.ConnectTimeoutException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ValidationVisitor(io.strimzi.operator.common.model.ValidationVisitor) SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) Set(java.util.Set) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) NoSuchResourceException(io.strimzi.operator.cluster.model.NoSuchResourceException) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) KafkaConnectCluster(io.strimzi.operator.cluster.model.KafkaConnectCluster) List(java.util.List) ANNO_STRIMZI_IO_RESTART(io.strimzi.operator.common.Annotations.ANNO_STRIMZI_IO_RESTART) Labels(io.strimzi.operator.common.model.Labels) Stream(java.util.stream.Stream) KafkaConnectorStatus(io.strimzi.api.kafka.model.status.KafkaConnectorStatus) Secret(io.fabric8.kubernetes.api.model.Secret) Optional(java.util.Optional) Condition(io.strimzi.api.kafka.model.status.Condition) KafkaConnectList(io.strimzi.api.kafka.KafkaConnectList) PodDisruptionBudgetOperator(io.strimzi.operator.common.operator.resource.PodDisruptionBudgetOperator) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) CustomResource(io.fabric8.kubernetes.client.CustomResource) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) BackOff(io.strimzi.operator.common.BackOff) NetworkPolicyOperator(io.strimzi.operator.common.operator.resource.NetworkPolicyOperator) Watch(io.fabric8.kubernetes.client.Watch) LocalObjectReference(io.fabric8.kubernetes.api.model.LocalObjectReference) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WatcherException(io.fabric8.kubernetes.client.WatcherException) ServiceOperator(io.strimzi.operator.common.operator.resource.ServiceOperator) CompositeFuture(io.vertx.core.CompositeFuture) Timer(io.micrometer.core.instrument.Timer) ServiceAccountOperator(io.strimzi.operator.common.operator.resource.ServiceAccountOperator) ConfigMapOperator(io.strimzi.operator.common.operator.resource.ConfigMapOperator) CrdOperator(io.strimzi.operator.common.operator.resource.CrdOperator) Status(io.strimzi.api.kafka.model.status.Status) ReconcileResult(io.strimzi.operator.common.operator.resource.ReconcileResult) LinkedHashSet(java.util.LinkedHashSet) KafkaConnectorBuilder(io.strimzi.api.kafka.model.KafkaConnectorBuilder) KafkaConnectorConfiguration(io.strimzi.operator.cluster.model.KafkaConnectorConfiguration) ReconciliationLogger(io.strimzi.operator.common.ReconciliationLogger) Collections.emptyMap(java.util.Collections.emptyMap) InvalidResourceException(io.strimzi.operator.cluster.model.InvalidResourceException) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) AbstractKafkaConnectSpec(io.strimzi.api.kafka.model.AbstractKafkaConnectSpec) ConnectorPlugin(io.strimzi.api.kafka.model.connect.ConnectorPlugin) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Reconciliation(io.strimzi.operator.common.Reconciliation) ImagePullPolicy(io.strimzi.operator.cluster.model.ImagePullPolicy) StatusDiff(io.strimzi.operator.cluster.model.StatusDiff) Util(io.strimzi.operator.common.Util) TreeMap(java.util.TreeMap) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) NetworkPolicy(io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) KafkaConnectSpec(io.strimzi.api.kafka.model.KafkaConnectSpec) Collections(java.util.Collections) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) LabelSelectorBuilder(io.fabric8.kubernetes.api.model.LabelSelectorBuilder) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) KafkaConnectorList(io.strimzi.api.kafka.KafkaConnectorList) CustomResourceList(io.fabric8.kubernetes.client.CustomResourceList) List(java.util.List) KafkaConnectList(io.strimzi.api.kafka.KafkaConnectList) ArrayList(java.util.ArrayList) Stream(java.util.stream.Stream) ConnectTimeoutException(io.netty.channel.ConnectTimeoutException)

Example 37 with OrderedProperties

use of io.strimzi.operator.common.model.OrderedProperties in project strimzi-kafka-operator by strimzi.

the class KafkaBrokerConfigurationDiff method diff.

/**
 * Computes diff between two maps. Entries in IGNORABLE_PROPERTIES are skipped
 * @param brokerId id of compared broker
 * @param desired desired configuration, may be null if the related ConfigMap does not exist yet or no changes are required
 * @param brokerConfigs current configuration
 * @param configModel default configuration for {@code kafkaVersion} of broker
 * @return Collection of AlterConfigOp containing all entries which were changed from current in desired configuration
 */
private Collection<AlterConfigOp> diff(int brokerId, String desired, Config brokerConfigs, Map<String, ConfigModel> configModel) {
    if (brokerConfigs == null || desired == null) {
        return Collections.emptyList();
    }
    Map<String, String> currentMap;
    Collection<AlterConfigOp> updatedCE = new ArrayList<>();
    currentMap = brokerConfigs.entries().stream().collect(Collectors.toMap(ConfigEntry::name, configEntry -> configEntry.value() == null ? "null" : configEntry.value()));
    OrderedProperties orderedProperties = new OrderedProperties();
    orderedProperties.addStringPairs(desired);
    Map<String, String> desiredMap = orderedProperties.asMap();
    fillPlaceholderValue(desiredMap, Integer.toString(brokerId));
    JsonNode source = patchMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true).valueToTree(currentMap);
    JsonNode target = patchMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true).valueToTree(desiredMap);
    JsonNode jsonDiff = JsonDiff.asJson(source, target);
    for (JsonNode d : jsonDiff) {
        String pathValue = d.get("path").asText();
        String pathValueWithoutSlash = pathValue.substring(1);
        Optional<ConfigEntry> optEntry = brokerConfigs.entries().stream().filter(configEntry -> configEntry.name().equals(pathValueWithoutSlash)).findFirst();
        String op = d.get("op").asText();
        if (optEntry.isPresent()) {
            ConfigEntry entry = optEntry.get();
            if ("remove".equals(op)) {
                removeProperty(configModel, updatedCE, pathValueWithoutSlash, entry);
            } else if ("replace".equals(op)) {
                // entry is in the current, desired is updated value
                updateOrAdd(entry.name(), configModel, desiredMap, updatedCE);
            }
        } else {
            if ("add".equals(op)) {
                // entry is not in the current, it is added
                updateOrAdd(pathValueWithoutSlash, configModel, desiredMap, updatedCE);
            }
        }
        if ("remove".equals(op)) {
            // there is a lot of properties set by default - not having them in desired causes very noisy log output
            LOGGER.traceCr(reconciliation, "Kafka Broker {} Config Differs : {}", brokerId, d);
            LOGGER.traceCr(reconciliation, "Current Kafka Broker Config path {} has value {}", pathValueWithoutSlash, lookupPath(source, pathValue));
            LOGGER.traceCr(reconciliation, "Desired Kafka Broker Config path {} has value {}", pathValueWithoutSlash, lookupPath(target, pathValue));
        } else {
            LOGGER.debugCr(reconciliation, "Kafka Broker {} Config Differs : {}", brokerId, d);
            LOGGER.debugCr(reconciliation, "Current Kafka Broker Config path {} has value {}", pathValueWithoutSlash, lookupPath(source, pathValue));
            LOGGER.debugCr(reconciliation, "Desired Kafka Broker Config path {} has value {}", pathValueWithoutSlash, lookupPath(target, pathValue));
        }
    }
    return updatedCE;
}
Also used : Scope(io.strimzi.kafka.config.model.Scope) AbstractJsonDiff(io.strimzi.operator.common.operator.resource.AbstractJsonDiff) Config(org.apache.kafka.clients.admin.Config) ReconciliationLogger(io.strimzi.operator.common.ReconciliationLogger) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) Collection(java.util.Collection) KafkaVersion(io.strimzi.operator.cluster.model.KafkaVersion) ConfigEntry(org.apache.kafka.clients.admin.ConfigEntry) JsonDiff(io.fabric8.zjsonpatch.JsonDiff) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ConfigModel(io.strimzi.kafka.config.model.ConfigModel) Reconciliation(io.strimzi.operator.common.Reconciliation) AlterConfigOp(org.apache.kafka.clients.admin.AlterConfigOp) PatchUtils.patchMapper(io.fabric8.kubernetes.client.internal.PatchUtils.patchMapper) KafkaConfiguration(io.strimzi.operator.cluster.model.KafkaConfiguration) Map(java.util.Map) Optional(java.util.Optional) JsonNode(com.fasterxml.jackson.databind.JsonNode) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) ConfigEntry(org.apache.kafka.clients.admin.ConfigEntry) ArrayList(java.util.ArrayList) AlterConfigOp(org.apache.kafka.clients.admin.AlterConfigOp) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 38 with OrderedProperties

use of io.strimzi.operator.common.model.OrderedProperties in project strimzi-kafka-operator by strimzi.

the class AbstractModel method maybeAddMonitorIntervalToExternalLogging.

/**
 * Adds 'monitorInterval=30' to external logging ConfigMap. If ConfigMap already has this value, it is persisted.
 *
 * @param data String with log4j2 properties in format key=value separated by new lines
 * @return log4j2 configuration with monitorInterval property
 */
protected String maybeAddMonitorIntervalToExternalLogging(String data) {
    OrderedProperties orderedProperties = new OrderedProperties();
    orderedProperties.addStringPairs(data);
    Optional<String> mi = orderedProperties.asMap().keySet().stream().filter(key -> key.matches("^monitorInterval$")).findFirst();
    if (mi.isPresent()) {
        return data;
    } else {
        // do not override custom value
        return data + "\nmonitorInterval=" + LOG4J2_MONITOR_INTERVAL + "\n";
    }
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) RollingUpdateDeploymentBuilder(io.fabric8.kubernetes.api.model.apps.RollingUpdateDeploymentBuilder) PodDisruptionBudget(io.fabric8.kubernetes.api.model.policy.v1.PodDisruptionBudget) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) Map(java.util.Map) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) Affinity(io.fabric8.kubernetes.api.model.Affinity) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) LabelSelectorBuilder(io.fabric8.kubernetes.api.model.LabelSelectorBuilder) Set(java.util.Set) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) PolicyRule(io.fabric8.kubernetes.api.model.rbac.PolicyRule) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) PodSecurityContextBuilder(io.fabric8.kubernetes.api.model.PodSecurityContextBuilder) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim) PersistentVolumeClaimBuilder(io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) PodDisruptionBudgetBuilder(io.fabric8.kubernetes.api.model.policy.v1.PodDisruptionBudgetBuilder) StatefulSetBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) ServicePortBuilder(io.fabric8.kubernetes.api.model.ServicePortBuilder) IpFamily(io.strimzi.api.kafka.model.template.IpFamily) LocalObjectReference(io.fabric8.kubernetes.api.model.LocalObjectReference) OwnerReference(io.fabric8.kubernetes.api.model.OwnerReference) ArrayList(java.util.ArrayList) RoleBuilder(io.fabric8.kubernetes.api.model.rbac.RoleBuilder) RoleBinding(io.fabric8.kubernetes.api.model.rbac.RoleBinding) ReconciliationLogger(io.strimzi.operator.common.ReconciliationLogger) RoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder) Pod(io.fabric8.kubernetes.api.model.Pod) IOException(java.io.IOException) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) Reconciliation(io.strimzi.operator.common.Reconciliation) Util(io.strimzi.operator.common.Util) ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) PodSecurityContext(io.fabric8.kubernetes.api.model.PodSecurityContext) Storage(io.strimzi.api.kafka.model.storage.Storage) Role(io.fabric8.kubernetes.api.model.rbac.Role) ServicePort(io.fabric8.kubernetes.api.model.ServicePort) Annotations(io.strimzi.operator.common.Annotations) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) StrimziPodSetBuilder(io.strimzi.api.kafka.model.StrimziPodSetBuilder) Locale(java.util.Locale) PodRevision(io.strimzi.operator.cluster.operator.resource.PodRevision) ExternalLogging(io.strimzi.api.kafka.model.ExternalLogging) IpFamilyPolicy(io.strimzi.api.kafka.model.template.IpFamilyPolicy) JvmOptions(io.strimzi.api.kafka.model.JvmOptions) ServiceAccountBuilder(io.fabric8.kubernetes.api.model.ServiceAccountBuilder) Collectors(java.util.stream.Collectors) RoleRef(io.fabric8.kubernetes.api.model.rbac.RoleRef) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) EnvVarSource(io.fabric8.kubernetes.api.model.EnvVarSource) StrimziPodSet(io.strimzi.api.kafka.model.StrimziPodSet) Secret(io.fabric8.kubernetes.api.model.Secret) DeploymentStrategy(io.fabric8.kubernetes.api.model.apps.DeploymentStrategy) Optional(java.util.Optional) Condition(io.strimzi.api.kafka.model.status.Condition) PersistentClaimStorageOverride(io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverride) PodManagementPolicy(io.strimzi.api.kafka.model.template.PodManagementPolicy) Container(io.fabric8.kubernetes.api.model.Container) Subject(io.fabric8.kubernetes.api.model.rbac.Subject) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) HashMap(java.util.HashMap) Function(java.util.function.Function) MetricsAndLogging(io.strimzi.operator.common.MetricsAndLogging) HashSet(java.util.HashSet) HostAlias(io.fabric8.kubernetes.api.model.HostAlias) JmxPrometheusExporterMetrics(io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics) DeploymentStrategyBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentStrategyBuilder) EnvVarSourceBuilder(io.fabric8.kubernetes.api.model.EnvVarSourceBuilder) InlineLogging(io.strimzi.api.kafka.model.InlineLogging) MetricsConfig(io.strimzi.api.kafka.model.MetricsConfig) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) Service(io.fabric8.kubernetes.api.model.Service) Volume(io.fabric8.kubernetes.api.model.Volume) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage) Collections.emptyMap(java.util.Collections.emptyMap) TopologySpreadConstraint(io.fabric8.kubernetes.api.model.TopologySpreadConstraint) StatefulSetUpdateStrategyBuilder(io.fabric8.kubernetes.api.model.apps.StatefulSetUpdateStrategyBuilder) OwnerReferenceBuilder(io.fabric8.kubernetes.api.model.OwnerReferenceBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Toleration(io.fabric8.kubernetes.api.model.Toleration) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Logging(io.strimzi.api.kafka.model.Logging) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) ContainerPortBuilder(io.fabric8.kubernetes.api.model.ContainerPortBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) Collections(java.util.Collections) InputStream(java.io.InputStream) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) IntOrString(io.fabric8.kubernetes.api.model.IntOrString)

Example 39 with OrderedProperties

use of io.strimzi.operator.common.model.OrderedProperties in project strimzi-kafka-operator by strimzi.

the class TestConfigurationWithoutDefaults method testNonEmptyJson.

@ParallelTest
public void testNonEmptyJson() {
    JsonObject configuration = new JsonObject().put("var1", "aaa").put("var2", "bbb").put("var3", "ccc");
    OrderedProperties expectedConfiguration = createWithDefaults("var3", "ccc", "var2", "bbb", "var1", "aaa");
    AbstractConfiguration config = new TestConfiguration(configuration);
    assertThat(config.asOrderedProperties(), is(expectedConfiguration));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 40 with OrderedProperties

use of io.strimzi.operator.common.model.OrderedProperties in project strimzi-kafka-operator by strimzi.

the class TestConfigurationWithoutDefaults method testJsonWithForbiddenKeys.

@ParallelTest
public void testJsonWithForbiddenKeys() {
    JsonObject configuration = new JsonObject().put("var1", "aaa").put("var2", "bbb").put("var3", "ccc").put("forbidden.option", "ddd");
    OrderedProperties expectedConfiguration = createWithDefaults("var3", "ccc", "var2", "bbb", "var1", "aaa");
    AbstractConfiguration config = new TestConfiguration(configuration);
    assertThat(config.asOrderedProperties(), is(expectedConfiguration));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

OrderedProperties (io.strimzi.operator.common.model.OrderedProperties)46 ParallelTest (io.strimzi.test.annotations.ParallelTest)24 Map (java.util.Map)20 Reconciliation (io.strimzi.operator.common.Reconciliation)16 JsonObject (io.vertx.core.json.JsonObject)16 ArrayList (java.util.ArrayList)14 List (java.util.List)14 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)12 LabelSelectorBuilder (io.fabric8.kubernetes.api.model.LabelSelectorBuilder)12 LocalObjectReference (io.fabric8.kubernetes.api.model.LocalObjectReference)12 Collections (java.util.Collections)10 Collections.emptyMap (java.util.Collections.emptyMap)10 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)8 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)8 HostAlias (io.fabric8.kubernetes.api.model.HostAlias)8 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)8 PodSecurityContextBuilder (io.fabric8.kubernetes.api.model.PodSecurityContextBuilder)8 Quantity (io.fabric8.kubernetes.api.model.Quantity)8 Secret (io.fabric8.kubernetes.api.model.Secret)8 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)8