You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/05/17 18:40:54 UTC

[GitHub] [kafka] cmccabe opened a new pull request #10714: MINOR: add ConfigUtils method for printing configurations

cmccabe opened a new pull request #10714:
URL: https://github.com/apache/kafka/pull/10714


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] mumrah commented on a change in pull request #10714: MINOR: add ConfigUtils method for printing configurations

Posted by GitBox <gi...@apache.org>.
mumrah commented on a change in pull request #10714:
URL: https://github.com/apache/kafka/pull/10714#discussion_r635452472



##########
File path: core/src/main/scala/kafka/server/DynamicBrokerConfig.scala
##########
@@ -601,7 +601,8 @@ class DynamicBrokerConfig(private val kafkaConfig: KafkaConfig) extends Logging
     }
 
     if (!validateOnly) {
-      info(s"Reconfiguring $reconfigurable, updated configs: $updatedConfigNames custom configs: $newCustomConfigs")
+      info(s"Reconfiguring $reconfigurable, updated configs: $updatedConfigNames " +
+        s"custom configs: ${ConfigUtils.configMapToRedactedString(newCustomConfigs, KafkaConfig.configDef)}")

Review comment:
       nit: alignment

##########
File path: core/src/main/scala/kafka/server/DynamicBrokerConfig.scala
##########
@@ -34,7 +34,7 @@ import org.apache.kafka.common.metrics.MetricsReporter
 import org.apache.kafka.common.config.types.Password
 import org.apache.kafka.common.network.{ListenerName, ListenerReconfigurable}
 import org.apache.kafka.common.security.authenticator.LoginManager
-import org.apache.kafka.common.utils.Utils
+import org.apache.kafka.common.utils.{ConfigUtils, Utils};

Review comment:
       nit: errant semicolon 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] cmccabe merged pull request #10714: MINOR: add ConfigUtils method for printing configurations

Posted by GitBox <gi...@apache.org>.
cmccabe merged pull request #10714:
URL: https://github.com/apache/kafka/pull/10714


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] cmccabe commented on a change in pull request #10714: MINOR: add ConfigUtils method for printing configurations

Posted by GitBox <gi...@apache.org>.
cmccabe commented on a change in pull request #10714:
URL: https://github.com/apache/kafka/pull/10714#discussion_r635462133



##########
File path: clients/src/test/java/org/apache/kafka/common/utils/ConfigUtilsTest.java
##########
@@ -140,4 +144,28 @@ public void testMultipleDeprecations() {
         assertNull(newConfig.get("foo.bar.deprecated"));
         assertNull(newConfig.get("foo.bar.even.more.deprecated"));
     }
+
+    private static final ConfigDef CONFIG = new ConfigDef().
+        define("foo", Type.PASSWORD, Importance.HIGH, "").
+        define("bar", Type.STRING, Importance.HIGH, "").
+        define("quux", Type.INT, Importance.HIGH, "").
+        define("blah", Type.STRING, Importance.HIGH, "");
+
+    @Test
+    public void testConfigMapToRedactedStringForEmptyMap() {
+        assertEquals("{}", ConfigUtils.
+            configMapToRedactedString(Collections.emptyMap(), CONFIG));
+    }
+
+    @Test
+    public void testConfigMapToRedactedStringWithSecrets() {
+        Map<String, Object> testMap1 = new HashMap<>();
+        testMap1.put("bar", "whatever");
+        testMap1.put("quux", Integer.valueOf(123));
+        testMap1.put("foo", "foosecret");
+        testMap1.put("blah", null);
+        testMap1.put("quuux", Integer.valueOf(456));
+        assertEquals("{bar=\"whatever\", blah=null, foo=(redacted), quuux=(redacted), quux=123}",

Review comment:
       ok




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] showuon commented on a change in pull request #10714: MINOR: add ConfigUtils method for printing configurations

Posted by GitBox <gi...@apache.org>.
showuon commented on a change in pull request #10714:
URL: https://github.com/apache/kafka/pull/10714#discussion_r634877755



##########
File path: clients/src/test/java/org/apache/kafka/common/utils/ConfigUtilsTest.java
##########
@@ -140,4 +144,28 @@ public void testMultipleDeprecations() {
         assertNull(newConfig.get("foo.bar.deprecated"));
         assertNull(newConfig.get("foo.bar.even.more.deprecated"));
     }
+
+    private static final ConfigDef CONFIG = new ConfigDef().
+        define("foo", Type.PASSWORD, Importance.HIGH, "").
+        define("bar", Type.STRING, Importance.HIGH, "").
+        define("quux", Type.INT, Importance.HIGH, "").
+        define("blah", Type.STRING, Importance.HIGH, "");
+
+    @Test
+    public void testConfigMapToRedactedStringForEmptyMap() {
+        assertEquals("{}", ConfigUtils.
+            configMapToRedactedString(Collections.emptyMap(), CONFIG));
+    }
+
+    @Test
+    public void testConfigMapToRedactedStringWithSecrets() {
+        Map<String, Object> testMap1 = new HashMap<>();
+        testMap1.put("bar", "whatever");
+        testMap1.put("quux", Integer.valueOf(123));
+        testMap1.put("foo", "foosecret");
+        testMap1.put("blah", null);
+        testMap1.put("quuux", Integer.valueOf(456));
+        assertEquals("{bar=\"whatever\", blah=null, foo=(redacted), quuux=(redacted), quux=123}",

Review comment:
       `nit`: could we rename the config name into a "meaningful" name? So that we can read the name and know which type it is, and what expected result it is. ex:
   ```
   define("passwordConfig", Type.PASSWORD, Importance.HIGH, "").
   define("stringConfig", Type.STRING, Importance.HIGH, "")
   ...
   testMap1.put("stringConfig", "whatever");
   testMap1.put("passwordConfig", "foosecret");
   testMap1.put("undefinedConfig", Integer.valueOf(456));
   ```
   So, in assert we can have this result:
   ```
   assertEquals("{stringConfig=\"whatever\", ..., passwordConfig=(redacted), undefinedConfig=(redacted), ...}",
   ``` 
   
   What do you think?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org