KAFKA-18215: KIP-891 Connect Multiversioning Support (Configs and Validation changes for Connectors and Converters)#17741
Conversation
| return plugins; | ||
| } | ||
|
|
||
| public PluginsRecommenders recommender() { |
There was a problem hiding this comment.
If we keep this as part of Plugins, then we can avoid the new PluginsRecommendors(plugins) call on every validate. Since the plugins information, once scanned remains static we don't really need to initialize all the recommenders again and again.
This is premature optimization, please don't do it. When someone has a benchmark that shows the benefit of this, it is trivial to implement.
The constructor of PluginsRecommenders does not perform any substantial pre-computation.
Validation already constructs hundreds of objects (ConfigValues, etc) each time it is called.
Also, if the plugins can be improved to be mutable in future it would be easier to revoke the current instance of recommenders in plugins and generate the new recommender, and have it reflected across all the uses.
YAGNI. When/if we get around to mutable Plugins, this class will look very different.
| VersionRange range = PluginUtils.connectorVersionRequirement(connectorVersion); | ||
| ClassLoader connectorLoader = plugins.pluginLoader(connectorClass, range); | ||
| try (LoaderSwap loaderSwap = plugins.withClassLoader(connectorLoader)) { | ||
| T plugin = (T) plugins.newPlugin(pluginName, pluginClass, null); | ||
| if (plugin instanceof Versioned) { | ||
| return ((Versioned) plugin).version(); | ||
| } | ||
| } |
There was a problem hiding this comment.
If two different version of the same plugin is bundled under the same plugin classloader
This is impossible from Connect's perspective. Once a ClassLoader returns a Class, it is cached and cannot be redefined. If two versions of a plugin are both present within the same ClassLoader, one will be picked arbitrarily, and it will always be picked (on the local machine). Effectively, Connect cant even know the second class file is there, which is why we don't try and detect it.
|
Hi @gharris1727. Please take another pass. I have made the requested changes, lmk if I have missed anything. Some tests are failing, will look into those soon. There is another unrelated issue I came across while testing this PR. There might be a regression in #16604, which seems to break reflections based isolation for plugins that are already defined in the classpath. Looks like the new classgraph scanner is always loading the classpath plugins even if there is a another version in an isolated plugin.path. This is causing the runtime to ignore the plugin due to this check. In my setup, I have built the following plugin hierarchy for testing, and I found that the different versions of json converter are never identified due to the one being present in the classpath. I changed the debug logs to error in the class and observed the following errors during scanning. The fix I made was to use |
Great catch! That regression hasn't been released yet and would definitely be a blocker for the release. Please open a blocker ticket for that we can fix it.
I think this is the right fix. It looks like Classgraph by default expects parent-first loaders, while our loaders are child-first. When the same class is defined multiple times, it masks all later copies, which would hide all of the other versions of the plugins. |
gharris1727
left a comment
There was a problem hiding this comment.
Please also fix the build/tests.
| @@ -1,149 +1,149 @@ | |||
| /* | |||
There was a problem hiding this comment.
nit: large diff.
How does this happen? I don't see what the change is...
There was a problem hiding this comment.
It was happening when I was rolling back changes via IDE. I think it somehow adding carriage returns to the lines since its on windows. Does not normally happen If I do operation with WSL.
There was a problem hiding this comment.
Ah yeah the line endings could cause a big diff. Thanks for looking into it!
|
Created https://issues.apache.org/jira/browse/KAFKA-18211 for the issue. |
gharris1727
left a comment
There was a problem hiding this comment.
LGTM, thanks @snehashisp
| " or use \"FileStreamSink\" or \"FileStreamSinkConnector\" to make the configuration a bit shorter"; | ||
| private static final String CONNECTOR_CLASS_DISPLAY = "Connector class"; | ||
|
|
||
| public static final String CONNECTOR_VERSION = "connector." + WorkerConfig.PLUGIN_VERSION_SUFFIX; |
There was a problem hiding this comment.
@snehashisp Thanks for this great patch. I have one small comment: It seems we are using connector.plugin.version instead of connector.version, correct? If so, could you please update the KIP accordingly?
…idation changes for Connectors and Converters) (apache#17741) Reviewers: Greg Harris <greg.harris@aiven.io>
…idation changes for Connectors and Converters) (apache#17741) Reviewers: Greg Harris <greg.harris@aiven.io>
… and Validation changes for Connectors and Converters) (apache#17741)" This reverts commit f4fe606.
These changes will be postponed to the 4.1 release. * Revert "KAFKA-18215: KIP-891 Connect Multiversioning Support (Configs and Validation changes for Connectors and Converters) (#17741)" This reverts commit f4fe606. * Revert "KAFKA-18182: KIP-891 Add VersionRange to Plugins and DelegatingClassLoader APIs (#16984)" This reverts commit af0054b. Reviewers: Greg Harris <greg.harris@aiven.io>
The is one of a set of PRs for KIP-891. The list of total PRs given below all build one the previous one in the list. They can be reviewed individually, or if the complete set of changes is preferrable, please refer to the last PR.
This is PR#2 and contains changes to connector-config and connector validation endpoints to do appropriate validation considering the version provided and provide accurate defaults. This is primarily for connectors and converter PR#3 is for transformations.
Committer Checklist (excluded from commit message)