This is an automated email from the ASF dual-hosted git repository. rhauch pushed a commit to branch 2.6 in repository https://gitbox.apache.org/repos/asf/kafka.git
commit df2ab9f4c9e44187455366848522cb135e6ab6e8 Author: Chris Egerton <chr...@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 <rha...@gmail.com> Co-authored-by: Nigel Liang <ni...@nigelliang.com> Co-authored-by: Randall Hauch <rha...@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 1b31a5f..a137b2d 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 @@ -38,6 +38,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.regex.Pattern; import org.eclipse.jetty.util.StringUtil; @@ -212,7 +213,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 = @@ -407,6 +411,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; } @@ -430,6 +451,7 @@ public class WorkerConfig extends AbstractConfig { public WorkerConfig(ConfigDef definition, Map<String, String> props) { super(definition, props); logInternalConverterDeprecationWarnings(props); + logPluginPathConfigProviderWarning(props); } // Visible for testing