New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KAFKA-14843] fix(connect): include base connector config to return #13445
Conversation
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Yash Mayya <yash.mayya@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the change!
I think that providing the standard sink and source ConfigDefs is a good idea, since that allows the API to be self-describing. Since the existing connector configuration does not separate the namespace for standard sink and source configurations from plugin-specific ones, I think it's acceptable to merge them together in this endpoint.
I only had some nits regarding repeated code. Thanks in advance for humoring me!
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java
Outdated
Show resolved
Hide resolved
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java
Outdated
Show resolved
Hide resolved
Sure, thanks @gharris1727! let me know how it looks now. |
} | ||
return results; | ||
addConfigDefToResult(results, configDefs); | ||
return new ArrayList<>(results); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used Set to build the result and avoid duplicates in case the configdef comes with common configs -- which could be the case? Happy to adjust if doesn't make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like ConfigKeyInfo uses very strict equality, such that if a connector exports a ConfigKeyInfo with the same name but with some other difference, the Set would consider them distinct. This means that the list and set are largely equivalent here.
It looks like in the validate call, connector config keys with the same name as framework keys override the framework provided key: https://github.com/apache/kafka/blob/trunk/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java#L511
We could replicate the same behavior here so that users don't get two distinct keys with the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jeqo! Two minor comments and then this should be good to go.
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractHerderTest.java
Outdated
Show resolved
Hide resolved
@@ -835,11 +835,16 @@ public List<ConfigKeyInfo> connectorPluginConfig(String pluginName) { | |||
try (LoaderSwap loaderSwap = p.withClassLoader(pluginClass.getClassLoader())) { | |||
Object plugin = p.newPlugin(pluginName); | |||
PluginType pluginType = PluginType.from(plugin.getClass()); | |||
Map<String, ConfigKey> configsMap = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make this part a bit cleaner with some small tweaks:
- Instead of instantiating
configsMap
here, declare aConfigDef baseConfigDefs
and initialize it tonull
(possibly with a comment about how this contains definitions for properties that are automatically supported by the Connect framework, instead of declared by the specific plugin class) - Rename
configDefs
topluginConfigDefs
(and possibly add a comment about how this contains definitions for properties that are explicitly declared by the plugin class) - Set
baseConfigDefs
toSinkConnectorConfig.configDef()
orSourceConnectorConfig.configDef()
in the switch statement - Combine everything together after the switch statement with something like this:
// Track config properties by name and, if the same property is defined in multiple places, give precedence to the one defined by the plugin class
Map<String, ConfigKey> configsMap = new HashMap<>();
if (baseConfigDefs != null)
configsMap.putAll(baseConfigDefs.configKeys());
configsMap.putAll(pluginConfigDefs.configKeys());
Co-authored-by: Chris Egerton <fearthecellos@gmail.com>
Thank you all for your feedback. It's looking good! Let's see what CI says :) |
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java
Outdated
Show resolved
Hide resolved
Thanks @jeqo! I've just noticed one more thing that we may want to change but I promise it's the last thing before we can merge this. |
Co-authored-by: Chris Egerton <fearthecellos@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @jeqo!
…nector config definitions (#13445) Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
…nector config definitions (#13445) Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
…nector config definitions (#13445) Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
…nector config definitions (apache#13445) Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
Issue: https://issues.apache.org/jira/browse/KAFKA-14843
Committer Checklist (excluded from commit message)