Skip to content
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

Merged
merged 7 commits into from Mar 28, 2023

Conversation

jeqo
Copy link
Contributor

@jeqo jeqo commented Mar 24, 2023

Issue: https://issues.apache.org/jira/browse/KAFKA-14843

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Co-authored-by: Yash Mayya <yash.mayya@gmail.com>
@jeqo jeqo marked this pull request as ready for review March 24, 2023 09:05
Copy link
Contributor

@gharris1727 gharris1727 left a 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!

@jeqo jeqo requested a review from gharris1727 March 27, 2023 18:57
@jeqo
Copy link
Contributor Author

jeqo commented Mar 27, 2023

Sure, thanks @gharris1727! let me know how it looks now.

}
return results;
addConfigDefToResult(results, configDefs);
return new ArrayList<>(results);
Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@gharris1727 gharris1727 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@C0urante C0urante left a 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.

@@ -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<>();
Copy link
Contributor

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:

  1. Instead of instantiating configsMap here, declare a ConfigDef baseConfigDefs and initialize it to null (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)
  2. Rename configDefs to pluginConfigDefs (and possibly add a comment about how this contains definitions for properties that are explicitly declared by the plugin class)
  3. Set baseConfigDefs to SinkConnectorConfig.configDef() or SourceConnectorConfig.configDef() in the switch statement
  4. 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());

jeqo and others added 2 commits March 28, 2023 07:37
@jeqo
Copy link
Contributor Author

jeqo commented Mar 28, 2023

Thank you all for your feedback. It's looking good! Let's see what CI says :)

@C0urante
Copy link
Contributor

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>
Copy link
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @jeqo!

@C0urante C0urante merged commit 5afedd9 into apache:trunk Mar 28, 2023
@jeqo jeqo deleted the fix-get-plugin-config branch March 28, 2023 15:27
C0urante pushed a commit that referenced this pull request Mar 28, 2023
…nector config definitions (#13445)

Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
C0urante pushed a commit that referenced this pull request Mar 28, 2023
…nector config definitions (#13445)

Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
C0urante pushed a commit that referenced this pull request Mar 28, 2023
…nector config definitions (#13445)

Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
giuseppelillo pushed a commit to aiven/kafka that referenced this pull request Apr 6, 2023
…nector config definitions (apache#13445)

Reviewers: Yash Mayya <yash.mayya@gmail.com>, Greg Harris <greg.harris@aiven.io>, Chris Egerton <chrise@aiven.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants