From 515daa4be7f6cfc9ee91f920c6e04cbbe018c650 Mon Sep 17 00:00:00 2001 From: Paolo Patierno Date: Sat, 25 Jan 2025 08:10:15 +0100 Subject: [PATCH] Refactoring around bridge ConfigMap naming and volume mounts (#11075) Signed-off-by: Paolo Patierno --- .../api/kafka/model/bridge/KafkaBridgeResources.java | 7 ++++--- .../operator/cluster/model/KafkaBridgeCluster.java | 10 +++++----- .../operator/assembly/KafkaBridgeAssemblyOperator.java | 2 +- .../io/strimzi/systemtest/bridge/HttpBridgeST.java | 2 +- .../java/io/strimzi/systemtest/log/LogSettingST.java | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/api/src/main/java/io/strimzi/api/kafka/model/bridge/KafkaBridgeResources.java b/api/src/main/java/io/strimzi/api/kafka/model/bridge/KafkaBridgeResources.java index 6b63029002a..53c2d5bce5a 100644 --- a/api/src/main/java/io/strimzi/api/kafka/model/bridge/KafkaBridgeResources.java +++ b/api/src/main/java/io/strimzi/api/kafka/model/bridge/KafkaBridgeResources.java @@ -31,11 +31,12 @@ public static String serviceName(String clusterName) { } /** - * Returns the name of the Kafka Bridge metrics and log {@code ConfigMap} for a {@code KafkaBridge} cluster of the given name. + * Returns the name of the Kafka Bridge {@code ConfigMap} for a {@code KafkaBridge} cluster of the given name. + * Such {@code ConfigMap} contains metrics, logging and overall bridge configuration parameters. * @param clusterName The {@code metadata.name} of the {@code KafkaBridge} resource. - * @return The name of the corresponding Kafka Bridge metrics and log {@code ConfigMap}. + * @return The name of the corresponding Kafka Bridge {@code ConfigMap}. */ - public static String metricsAndLogConfigMapName(String clusterName) { + public static String configMapName(String clusterName) { return clusterName + "-bridge-config"; } diff --git a/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaBridgeCluster.java b/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaBridgeCluster.java index 9912764388a..5fa4312e398 100644 --- a/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaBridgeCluster.java +++ b/cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaBridgeCluster.java @@ -77,8 +77,8 @@ public class KafkaBridgeCluster extends AbstractModel implements SupportsLogging protected static final String TLS_CERTS_BASE_VOLUME_MOUNT = "/opt/strimzi/bridge-certs/"; protected static final String PASSWORD_VOLUME_MOUNT = "/opt/strimzi/bridge-password/"; protected static final String ENV_VAR_KAFKA_INIT_INIT_FOLDER_KEY = "INIT_FOLDER"; - private static final String LOG_AND_METRICS_CONFIG_VOLUME_NAME = "kafka-metrics-and-logging"; - private static final String LOG_AND_METRICS_CONFIG_VOLUME_MOUNT = "/opt/strimzi/custom-config/"; + private static final String KAFKA_BRIDGE_CONFIG_VOLUME_NAME = "kafka-bridge-configurations"; + private static final String KAFKA_BRIDGE_CONFIG_VOLUME_MOUNT = "/opt/strimzi/custom-config/"; // Cluster Operator environment variables for custom discovery labels and annotations protected static final String CO_ENV_VAR_CUSTOM_SERVICE_LABELS = "STRIMZI_CUSTOM_KAFKA_BRIDGE_SERVICE_LABELS"; @@ -281,7 +281,7 @@ protected List getContainerPortList() { protected List getVolumes(boolean isOpenShift) { List volumeList = new ArrayList<>(2); volumeList.add(VolumeUtils.createTempDirVolume(templatePod)); - volumeList.add(VolumeUtils.createConfigMapVolume(LOG_AND_METRICS_CONFIG_VOLUME_NAME, KafkaBridgeResources.metricsAndLogConfigMapName(cluster))); + volumeList.add(VolumeUtils.createConfigMapVolume(KAFKA_BRIDGE_CONFIG_VOLUME_NAME, KafkaBridgeResources.configMapName(cluster))); if (tls != null) { CertUtils.createTrustedCertificatesVolumes(volumeList, tls.getTrustedCertificates(), isOpenShift); @@ -302,7 +302,7 @@ protected List getVolumeMounts() { List volumeMountList = new ArrayList<>(2); volumeMountList.add(VolumeUtils.createTempDirVolumeMount()); - volumeMountList.add(VolumeUtils.createVolumeMount(LOG_AND_METRICS_CONFIG_VOLUME_NAME, LOG_AND_METRICS_CONFIG_VOLUME_MOUNT)); + volumeMountList.add(VolumeUtils.createVolumeMount(KAFKA_BRIDGE_CONFIG_VOLUME_NAME, KAFKA_BRIDGE_CONFIG_VOLUME_MOUNT)); if (tls != null) { CertUtils.createTrustedCertificatesVolumeMounts(volumeMountList, tls.getTrustedCertificates(), TLS_CERTS_BASE_VOLUME_MOUNT); @@ -575,7 +575,7 @@ public ConfigMap generateBridgeConfigMap(MetricsAndLogging metricsAndLogging) { return ConfigMapUtils .createConfigMap( - KafkaBridgeResources.metricsAndLogConfigMapName(cluster), + KafkaBridgeResources.configMapName(cluster), namespace, labels, ownerReference, diff --git a/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaBridgeAssemblyOperator.java b/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaBridgeAssemblyOperator.java index 90af04b512a..551597f856a 100644 --- a/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaBridgeAssemblyOperator.java +++ b/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaBridgeAssemblyOperator.java @@ -107,7 +107,7 @@ protected Future createOrUpdate(Reconciliation reconciliation .compose(metricsAndLogging -> { ConfigMap configMap = bridge.generateBridgeConfigMap(metricsAndLogging); podAnnotations.put(KafkaBridgeCluster.ANNO_STRIMZI_IO_CONFIGURATION_HASH, Util.hashStub(configMap.getData().get(KafkaBridgeCluster.BRIDGE_CONFIGURATION_FILENAME))); - return configMapOperations.reconcile(reconciliation, namespace, KafkaBridgeResources.metricsAndLogConfigMapName(reconciliation.name()), configMap); + return configMapOperations.reconcile(reconciliation, namespace, KafkaBridgeResources.configMapName(reconciliation.name()), configMap); }) .compose(i -> isPodDisruptionBudgetGeneration ? podDisruptionBudgetOperator.reconcile(reconciliation, namespace, bridge.getComponentName(), bridge.generatePodDisruptionBudget()) : Future.succeededFuture()) .compose(i -> VertxUtil.authTlsHash(secretOperations, namespace, auth, trustedCertificates)) diff --git a/systemtest/src/test/java/io/strimzi/systemtest/bridge/HttpBridgeST.java b/systemtest/src/test/java/io/strimzi/systemtest/bridge/HttpBridgeST.java index 5dc246efd1b..8bb3176d726 100644 --- a/systemtest/src/test/java/io/strimzi/systemtest/bridge/HttpBridgeST.java +++ b/systemtest/src/test/java/io/strimzi/systemtest/bridge/HttpBridgeST.java @@ -268,7 +268,7 @@ void testCustomAndUpdatedValues() { updatedPeriodSeconds, successThreshold, updatedFailureThreshold); VerificationUtils.verifyContainerEnvVariables(Environment.TEST_SUITE_NAMESPACE, KafkaBridgeResources.componentName(bridgeName), KafkaBridgeResources.componentName(bridgeName), envVarUpdated); - ConfigMap configMap = kubeClient().namespace(Environment.TEST_SUITE_NAMESPACE).getConfigMap(KafkaBridgeResources.metricsAndLogConfigMapName(bridgeName)); + ConfigMap configMap = kubeClient().namespace(Environment.TEST_SUITE_NAMESPACE).getConfigMap(KafkaBridgeResources.configMapName(bridgeName)); String bridgeConfiguration = configMap.getData().get("application.properties"); Map config = StUtils.loadProperties(bridgeConfiguration); Map producerConfigMap = config.entrySet().stream().filter(e -> e.getKey().startsWith("kafka.producer.")).collect(Collectors.toMap(e -> e.getKey().replace("kafka.producer.", ""), Map.Entry::getValue)); diff --git a/systemtest/src/test/java/io/strimzi/systemtest/log/LogSettingST.java b/systemtest/src/test/java/io/strimzi/systemtest/log/LogSettingST.java index b4f427b04a7..4c3d5580898 100644 --- a/systemtest/src/test/java/io/strimzi/systemtest/log/LogSettingST.java +++ b/systemtest/src/test/java/io/strimzi/systemtest/log/LogSettingST.java @@ -402,7 +402,7 @@ void testBridgeLogSetting() { final String bridgeDepName = KafkaBridgeResources.componentName(testStorage.getClusterName()); final Map bridgePods = DeploymentUtils.depSnapshot(Environment.TEST_SUITE_NAMESPACE, bridgeDepName); - final String bridgeMap = KafkaBridgeResources.metricsAndLogConfigMapName(testStorage.getClusterName()); + final String bridgeMap = KafkaBridgeResources.configMapName(testStorage.getClusterName()); final LabelSelector labelSelector = KafkaBridgeResource.getLabelSelector(bridgeDepName, KafkaMirrorMaker2Resources.componentName(bridgeDepName)); LOGGER.info("Checking if Bridge has log level set properly");