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

build: add metadata descriptor to enable kafka connect use the plugin discovery mechanism #285

Conversation

eliax1996
Copy link
Contributor

@eliax1996 eliax1996 commented Sep 2, 2024

This pr add the descriptors to enable kafka connect loading the connectors just by scanning the plugin jars.
The specific require creating a file called META-INF/services/org.apache.kafka.connect.sink.SinkConnector (note well that this is the interface, not the implementation. I've done this error before).
The content of the file should be the fully qualified classname of the file implementing the interface.

To check that the modification its accepted you can use a cli tool, e.g. /opt/kafka-3.6/bin/connect-plugin-path.sh list --plugin-path /opt/myFancyFolder/kafka-connect-bigquery/.
The output will be like:

pluginName	firstAlias	secondAlias	pluginVersion	pluginType	isLoadable	hasManifest	pluginLocation
com.wepay.kafka.connect.bigquery.BigQuerySinkConnector	BigQuerySinkConnector	BigQuerySink	unknown	sink	true	true	/opt/myFancyFolder/connect-plugins/kafka-connect-bigquery/kcbq-connector-2.6.1-SNAPSHOT.jar
io.debezium.transforms.UnwrapFromEnvelope	UnwrapFromEnvelope	N/A	undefined	transformation	true	false	/opt/myFancyFolderconnect-plugins/kafka-connect-bigquery/debezium-core-0.6.2.jar
io.debezium.transforms.ByLogicalTableRouter	ByLogicalTableRouter	N/A	undefined	transformation	true	false	/opt/myFancyFolder/connect-plugins/kafka-connect-bigquery/debezium-core-0.6.2.jar

In this example the hasManifest its true just for the kafka-connect-bigquery/kcbq-connector-2.6.1-SNAPSHOT.jar meaning that the jar containing the implementation under META-INF/services/org.apache.kafka.connect.sink.SinkConnector has 1 row with specified com.wepay.kafka.connect.bigquery.BigQuerySinkConnector .
While the other two classes under /opt/myFancyFolder/connect-plugins/kafka-connect-bigquery/debezium-core-0.6.2.jar have two transformations that can be scanned with a runtime scanner (basically checking with the reflection for each class if its implementing the method) but do not have a valid descriptor for them.

NB with the descriptor the scan time its several orders of time faster for non trivial classpath (classpath with multiple big jars ~= 2/300 MB)

@eliax1996 eliax1996 requested review from a team as code owners September 2, 2024 15:53
@eliax1996 eliax1996 marked this pull request as draft September 2, 2024 16:55
@eliax1996 eliax1996 force-pushed the eliax1996/add-META-INF-services-to-enable-service_load-loading branch 4 times, most recently from e7f3371 to dd3ea20 Compare September 6, 2024 09:57
@@ -186,12 +186,14 @@ tasks.distZip { dependsOn(":commons:jar") }
distributions {
main {
contents {
from("jar")
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
from(tasks.jar)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wasn't adding the right folder to the installDist step

@eliax1996 eliax1996 force-pushed the eliax1996/add-META-INF-services-to-enable-service_load-loading branch from dd3ea20 to de7d201 Compare September 6, 2024 15:31
@eliax1996 eliax1996 marked this pull request as ready for review September 6, 2024 15:44
gharris1727
gharris1727 previously approved these changes Sep 6, 2024
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.

I confirmed that the manifests are correct. Thanks for rolling this out!

@eliax1996 eliax1996 force-pushed the eliax1996/add-META-INF-services-to-enable-service_load-loading branch from de7d201 to 6a21e5d Compare September 10, 2024 08:35
@eliax1996 eliax1996 changed the title build: add metadata descriptor to enable kafka connect use the plugin discovery mechanism build: add metadata descriptor to enable kafka connect use the plugin discovery mechanism [EC-498] Sep 10, 2024
@eliax1996 eliax1996 changed the title build: add metadata descriptor to enable kafka connect use the plugin discovery mechanism [EC-498] build: add metadata descriptor to enable kafka connect use the plugin discovery mechanism Sep 10, 2024
@eliax1996 eliax1996 force-pushed the eliax1996/add-META-INF-services-to-enable-service_load-loading branch 5 times, most recently from e6369f7 to f5d3f21 Compare September 10, 2024 13:49
@eliax1996 eliax1996 force-pushed the eliax1996/add-META-INF-services-to-enable-service_load-loading branch 3 times, most recently from 63c6605 to 09e9e4d Compare September 10, 2024 14:09
… discovery mechanism

generating jars instead of class files in the `distInstall` (just keeping the runtime classpath and not extracting it with the zip plugin).
@eliax1996 eliax1996 force-pushed the eliax1996/add-META-INF-services-to-enable-service_load-loading branch from 09e9e4d to 839ba33 Compare September 11, 2024 07:23
@jjaakola-aiven jjaakola-aiven merged commit 510763e into main Sep 11, 2024
6 checks passed
@jjaakola-aiven jjaakola-aiven deleted the eliax1996/add-META-INF-services-to-enable-service_load-loading branch September 11, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants