You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by rh...@apache.org on 2020/06/11 04:39:18 UTC

[kafka] branch 2.5 updated: KAFKA-9845: Warn users about using config providers with plugin.path property (#8455)

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

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


The following commit(s) were added to refs/heads/2.5 by this push:
     new a23bd36  KAFKA-9845: Warn users about using config providers with plugin.path property (#8455)
a23bd36 is described below

commit a23bd36d2a2325e0033d9f67b320ccdf464db167
Author: Chris Egerton <ch...@confluent.io>
AuthorDate: Wed Jun 10 20:06:38 2020 -0700

    KAFKA-9845: Warn users about using config providers with plugin.path property (#8455)
    
    * KAFKA-9845: Fix plugin.path when config provider is used
    
    * Revert "KAFKA-9845: Fix plugin.path when config provider is used"
    
    This reverts commit 96caaa9a4934bcef78d7b145d18aa1718cb10009.
    
    * KAFKA-9845: Emit ERROR-level log message when config provider is used for plugin.path property
    
    * KAFKA-9845: Demote log message level from ERROR to WARN
    
    Co-Authored-By: Nigel Liang <ni...@nigelliang.com>
    
    * KAFKA-94845: Fix failing unit tests
    
    * KAFKA-9845: Add warning message to docstring for plugin.path config
    
    * KAFKA-9845: Apply suggestions from code review
    
    Co-authored-by: Randall Hauch <rh...@gmail.com>
    
    Co-authored-by: Nigel Liang <ni...@nigelliang.com>
    Co-authored-by: Randall Hauch <rh...@gmail.com>
---
 .../apache/kafka/connect/runtime/WorkerConfig.java | 24 +++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java
index 352d225..6039eaf 100644
--- a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java
+++ b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfig.java
@@ -37,6 +37,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.regex.Pattern;
 
 import static org.apache.kafka.common.config.ConfigDef.Range.atLeast;
@@ -205,7 +206,10 @@ public class WorkerConfig extends AbstractConfig {
             + "plugins and their dependencies\n"
             + "Note: symlinks will be followed to discover dependencies or plugins.\n"
             + "Examples: plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,"
-            + "/opt/connectors";
+            + "/opt/connectors\n" 
+            + "Do not use config provider variables in this property, since the raw path is used "
+            + "by the worker's scanner before config providers are initialized and used to "
+            + "replace variables.";
 
     public static final String CONFIG_PROVIDERS_CONFIG = "config.providers";
     protected static final String CONFIG_PROVIDERS_DOC =
@@ -381,6 +385,23 @@ public class WorkerConfig extends AbstractConfig {
         }
     }
 
+    private void logPluginPathConfigProviderWarning(Map<String, String> rawOriginals) {
+        String rawPluginPath = rawOriginals.get(PLUGIN_PATH_CONFIG);
+        // Can't use AbstractConfig::originalsStrings here since some values may be null, which
+        // causes that method to fail
+        String transformedPluginPath = Objects.toString(originals().get(PLUGIN_PATH_CONFIG));
+        if (!Objects.equals(rawPluginPath, transformedPluginPath)) {
+            log.warn(
+                "Variables cannot be used in the 'plugin.path' property, since the property is "
+                + "used by plugin scanning before the config providers that replace the " 
+                + "variables are initialized. The raw value '{}' was used for plugin scanning, as " 
+                + "opposed to the transformed value '{}', and this may cause unexpected results.",
+                rawPluginPath,
+                transformedPluginPath
+            );
+        }
+    }
+
     public Integer getRebalanceTimeout() {
         return null;
     }
@@ -400,6 +421,7 @@ public class WorkerConfig extends AbstractConfig {
     public WorkerConfig(ConfigDef definition, Map<String, String> props) {
         super(definition, props);
         logInternalConverterDeprecationWarnings(props);
+        logPluginPathConfigProviderWarning(props);
     }
 
     private static class AdminListenersValidator implements ConfigDef.Validator {