You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2022/02/05 19:35:53 UTC

[kafka] branch trunk updated: MINOR: disable zookeeper.sasl.client to avoid false error (#11469)

This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f49524e  MINOR: disable zookeeper.sasl.client to avoid false error (#11469)
f49524e is described below

commit f49524e4c315e47f6a29cf330db8755fb6d51c57
Author: Chia-Ping Tsai <ch...@gmail.com>
AuthorDate: Sun Feb 6 03:34:22 2022 +0800

    MINOR: disable zookeeper.sasl.client to avoid false error (#11469)
    
    Reviewers: Mickael Maison <mi...@users.noreply.github.com>
---
 core/src/main/scala/kafka/server/KafkaServer.scala          |  2 ++
 core/src/test/scala/unit/kafka/server/KafkaServerTest.scala | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/kafka/server/KafkaServer.scala b/core/src/main/scala/kafka/server/KafkaServer.scala
index bd899e1..5d56b40 100755
--- a/core/src/main/scala/kafka/server/KafkaServer.scala
+++ b/core/src/main/scala/kafka/server/KafkaServer.scala
@@ -75,6 +75,8 @@ object KafkaServer {
       KafkaConfig.setZooKeeperClientProperty(clientConfig, KafkaConfig.ZkSslCrlEnableProp, config.ZkSslCrlEnable.toString)
       KafkaConfig.setZooKeeperClientProperty(clientConfig, KafkaConfig.ZkSslOcspEnableProp, config.ZkSslOcspEnable.toString)
     }
+    // The zk sasl is enabled by default so it can produce false error when broker does not intend to use SASL.
+    if (!JaasUtils.isZkSaslEnabled) clientConfig.setProperty(JaasUtils.ZK_SASL_CLIENT, "false")
     clientConfig
   }
 
diff --git a/core/src/test/scala/unit/kafka/server/KafkaServerTest.scala b/core/src/test/scala/unit/kafka/server/KafkaServerTest.scala
index 6ab6930..79bfc24 100755
--- a/core/src/test/scala/unit/kafka/server/KafkaServerTest.scala
+++ b/core/src/test/scala/unit/kafka/server/KafkaServerTest.scala
@@ -19,7 +19,7 @@ package kafka.server
 
 import kafka.api.ApiVersion
 import kafka.utils.TestUtils
-import kafka.server.QuorumTestHarness
+import org.apache.kafka.common.security.JaasUtils
 import org.junit.jupiter.api.Assertions.{assertEquals, assertNull, assertThrows, fail}
 import org.junit.jupiter.api.Test
 
@@ -42,6 +42,14 @@ class KafkaServerTest extends QuorumTestHarness {
   }
 
   @Test
+  def testCreatesProperZkConfigWhenSaslDisabled(): Unit = {
+    val props = new Properties
+    props.put(KafkaConfig.ZkConnectProp, zkConnect) // required, otherwise we would leave it out
+    val zkClientConfig = KafkaServer.zkClientConfigFromKafkaConfig(KafkaConfig.fromProps(props))
+    assertEquals("false", zkClientConfig.getProperty(JaasUtils.ZK_SASL_CLIENT))
+  }
+
+  @Test
   def testCreatesProperZkTlsConfigWhenDisabled(): Unit = {
     val props = new Properties
     props.put(KafkaConfig.ZkConnectProp, zkConnect) // required, otherwise we would leave it out