-
Couldn't load subscription status.
- Fork 62
Upgrade Kafka client to v4 #205
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
Merged
kaisecheng
merged 16 commits into
logstash-plugins:main
from
kaisecheng:upgrade_kafka_client_v4
Oct 16, 2025
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ade87bb
test: add support to test against Kafka v3 and v4
kaisecheng f05f8b2
bump version & changelog
kaisecheng cfc1f84
updated kafka-client and dependencies
kaisecheng 19ec2d5
add `group_protocol` option
kaisecheng b6cbe0b
remove `default` partitioner
kaisecheng 535c539
test: fix default partitioner
kaisecheng cdf94c0
refactor partitioner
kaisecheng ff1aa50
Update docs/output-kafka.asciidoc
kaisecheng 23bd223
update linger_ms default to 5
kaisecheng 053e53a
Merge branch 'upgrade_kafka_client_v4' of github.com:kaisecheng/logst…
kaisecheng ab59874
align partitioner options with Kafka client
kaisecheng 99c076d
Update lib/logstash/inputs/kafka.rb
kaisecheng 08e1542
update comment on dependency
kaisecheng 557f516
update release note
kaisecheng c3256e8
update dependency to match confluent version
kaisecheng 96e7338
Update docs/input-kafka.asciidoc
kaisecheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,11 @@ set -ex | |
| if [ -n "${KAFKA_VERSION+1}" ]; then | ||
| echo "KAFKA_VERSION is $KAFKA_VERSION" | ||
| else | ||
| KAFKA_VERSION=3.4.1 | ||
| KAFKA_VERSION=4.1.0 | ||
| fi | ||
|
|
||
| KAFKA_MAJOR_VERSION="${KAFKA_VERSION%%.*}" | ||
|
|
||
| export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true" | ||
|
|
||
| rm -rf build | ||
|
|
@@ -17,54 +19,70 @@ mkdir build | |
| echo "Setup Kafka version $KAFKA_VERSION" | ||
| if [ ! -e "kafka_2.13-$KAFKA_VERSION.tgz" ]; then | ||
| echo "Kafka not present locally, downloading" | ||
| curl -s -o "kafka_2.13-$KAFKA_VERSION.tgz" "https://archive.apache.org/dist/kafka/$KAFKA_VERSION/kafka_2.13-$KAFKA_VERSION.tgz" | ||
| curl -s -o "kafka_2.13-$KAFKA_VERSION.tgz" "https://downloads.apache.org/kafka/$KAFKA_VERSION/kafka_2.13-$KAFKA_VERSION.tgz" | ||
| fi | ||
| cp kafka_2.13-$KAFKA_VERSION.tgz build/kafka.tgz | ||
| mkdir build/kafka && tar xzf build/kafka.tgz -C build/kafka --strip-components 1 | ||
| cp "kafka_2.13-$KAFKA_VERSION.tgz" "build/kafka.tgz" | ||
| mkdir "build/kafka" && tar xzf "build/kafka.tgz" -C "build/kafka" --strip-components 1 | ||
|
|
||
| echo "Starting ZooKeeper" | ||
| build/kafka/bin/zookeeper-server-start.sh -daemon build/kafka/config/zookeeper.properties | ||
| sleep 10 | ||
| if [ -f "build/kafka/bin/zookeeper-server-start.sh" ]; then | ||
| echo "Starting ZooKeeper" | ||
| build/kafka/bin/zookeeper-server-start.sh -daemon "build/kafka/config/zookeeper.properties" | ||
| sleep 10 | ||
| else | ||
| echo "Use KRaft for Kafka version $KAFKA_VERSION" | ||
|
|
||
| echo "log.dirs=${PWD}/build/kafka-logs" >> build/kafka/config/server.properties | ||
|
|
||
| build/kafka/bin/kafka-storage.sh format \ | ||
| --cluster-id $(build/kafka/bin/kafka-storage.sh random-uuid) \ | ||
| --config build/kafka/config/server.properties \ | ||
| --ignore-formatted \ | ||
| --standalone | ||
| fi | ||
| echo "Starting Kafka broker" | ||
| build/kafka/bin/kafka-server-start.sh -daemon build/kafka/config/server.properties --override advertised.host.name=127.0.0.1 --override log.dirs="${PWD}/build/kafka-logs" | ||
| build/kafka/bin/kafka-server-start.sh -daemon "build/kafka/config/server.properties" --override advertised.host.name=127.0.0.1 --override log.dirs="${PWD}/build/kafka-logs" | ||
| sleep 10 | ||
|
|
||
| echo "Setup Confluent Platform" | ||
| # check if CONFLUENT_VERSION env var is set | ||
| if [ -n "${CONFLUENT_VERSION+1}" ]; then | ||
| echo "CONFLUENT_VERSION is $CONFLUENT_VERSION" | ||
| else | ||
| CONFLUENT_VERSION=7.4.0 | ||
| CONFLUENT_VERSION=8.0.0 | ||
| fi | ||
| if [ ! -e confluent-community-$CONFLUENT_VERSION.tar.gz ]; then | ||
| if [ ! -e "confluent-community-$CONFLUENT_VERSION.tar.gz" ]; then | ||
| echo "Confluent Platform not present locally, downloading" | ||
| CONFLUENT_MINOR=$(echo "$CONFLUENT_VERSION" | sed -n 's/^\([[:digit:]]*\.[[:digit:]]*\)\.[[:digit:]]*$/\1/p') | ||
| echo "CONFLUENT_MINOR is $CONFLUENT_MINOR" | ||
| curl -s -o confluent-community-$CONFLUENT_VERSION.tar.gz http://packages.confluent.io/archive/$CONFLUENT_MINOR/confluent-community-$CONFLUENT_VERSION.tar.gz | ||
| curl -s -o "confluent-community-$CONFLUENT_VERSION.tar.gz" "http://packages.confluent.io/archive/$CONFLUENT_MINOR/confluent-community-$CONFLUENT_VERSION.tar.gz" | ||
| fi | ||
| cp confluent-community-$CONFLUENT_VERSION.tar.gz build/confluent_platform.tar.gz | ||
| mkdir build/confluent_platform && tar xzf build/confluent_platform.tar.gz -C build/confluent_platform --strip-components 1 | ||
| cp "confluent-community-$CONFLUENT_VERSION.tar.gz" "build/confluent_platform.tar.gz" | ||
| mkdir "build/confluent_platform" && tar xzf "build/confluent_platform.tar.gz" -C "build/confluent_platform" --strip-components 1 | ||
|
|
||
| echo "Configuring TLS on Schema registry" | ||
| rm -Rf tls_repository | ||
| mkdir tls_repository | ||
| ./setup_keystore_and_truststore.sh | ||
| # configure schema-registry to handle https on 8083 port | ||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||
| sed -i '' 's/http:\/\/0.0.0.0:8081/http:\/\/0.0.0.0:8081, https:\/\/0.0.0.0:8083/g' build/confluent_platform/etc/schema-registry/schema-registry.properties | ||
| sed -i '' 's/http:\/\/0.0.0.0:8081/http:\/\/0.0.0.0:8081, https:\/\/0.0.0.0:8083/g' "build/confluent_platform/etc/schema-registry/schema-registry.properties" | ||
| else | ||
| sed -i 's/http:\/\/0.0.0.0:8081/http:\/\/0.0.0.0:8081, https:\/\/0.0.0.0:8083/g' build/confluent_platform/etc/schema-registry/schema-registry.properties | ||
| sed -i 's/http:\/\/0.0.0.0:8081/http:\/\/0.0.0.0:8081, https:\/\/0.0.0.0:8083/g' "build/confluent_platform/etc/schema-registry/schema-registry.properties" | ||
| fi | ||
| echo "ssl.keystore.location=`pwd`/tls_repository/schema_reg.jks" >> "build/confluent_platform/etc/schema-registry/schema-registry.properties" | ||
| echo "ssl.keystore.password=changeit" >> "build/confluent_platform/etc/schema-registry/schema-registry.properties" | ||
| echo "ssl.key.password=changeit" >> "build/confluent_platform/etc/schema-registry/schema-registry.properties" | ||
|
|
||
| cp "build/confluent_platform/etc/schema-registry/schema-registry.properties" "build/confluent_platform/etc/schema-registry/authed-schema-registry.properties" | ||
| echo "authentication.method=BASIC" >> "build/confluent_platform/etc/schema-registry/authed-schema-registry.properties" | ||
| echo "authentication.roles=admin,developer,user,sr-user" >> "build/confluent_platform/etc/schema-registry/authed-schema-registry.properties" | ||
| echo "authentication.realm=SchemaRegistry-Props" >> "build/confluent_platform/etc/schema-registry/authed-schema-registry.properties" | ||
| cp spec/fixtures/jaas.config "build/confluent_platform/etc/schema-registry" | ||
| if [[ "$KAFKA_MAJOR_VERSION" -eq 3 ]]; then | ||
| cp "spec/fixtures/jaas$KAFKA_MAJOR_VERSION.config" "build/confluent_platform/etc/schema-registry/jaas.config" | ||
|
Comment on lines
+81
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI only tests against Kafka 4. Keeping old jaas.config for development testing against Kafka 3. |
||
| fi | ||
| echo "ssl.keystore.location=`pwd`/tls_repository/schema_reg.jks" >> build/confluent_platform/etc/schema-registry/schema-registry.properties | ||
| echo "ssl.keystore.password=changeit" >> build/confluent_platform/etc/schema-registry/schema-registry.properties | ||
| echo "ssl.key.password=changeit" >> build/confluent_platform/etc/schema-registry/schema-registry.properties | ||
|
|
||
| cp build/confluent_platform/etc/schema-registry/schema-registry.properties build/confluent_platform/etc/schema-registry/authed-schema-registry.properties | ||
| echo "authentication.method=BASIC" >> build/confluent_platform/etc/schema-registry/authed-schema-registry.properties | ||
| echo "authentication.roles=admin,developer,user,sr-user" >> build/confluent_platform/etc/schema-registry/authed-schema-registry.properties | ||
| echo "authentication.realm=SchemaRegistry-Props" >> build/confluent_platform/etc/schema-registry/authed-schema-registry.properties | ||
| cp spec/fixtures/jaas.config build/confluent_platform/etc/schema-registry | ||
| cp spec/fixtures/pwd build/confluent_platform/etc/schema-registry | ||
| cp spec/fixtures/pwd "build/confluent_platform/etc/schema-registry" | ||
|
|
||
| echo "Setting up test topics with test data" | ||
| build/kafka/bin/kafka-topics.sh --create --partitions 3 --replication-factor 1 --topic logstash_integration_topic_plain --bootstrap-server localhost:9092 | ||
|
|
@@ -82,8 +100,8 @@ build/kafka/bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 - | |
| build/kafka/bin/kafka-topics.sh --create --partitions 3 --replication-factor 1 --topic logstash_integration_partitioner_topic --bootstrap-server localhost:9092 | ||
| build/kafka/bin/kafka-topics.sh --create --partitions 3 --replication-factor 1 --topic logstash_integration_static_membership_topic --bootstrap-server localhost:9092 | ||
| curl -s -o build/apache_logs.txt https://s3.amazonaws.com/data.elasticsearch.org/apache_logs/apache_logs.txt | ||
| cat build/apache_logs.txt | build/kafka/bin/kafka-console-producer.sh --topic logstash_integration_topic_plain --broker-list localhost:9092 | ||
| cat build/apache_logs.txt | build/kafka/bin/kafka-console-producer.sh --topic logstash_integration_topic_snappy --broker-list localhost:9092 --compression-codec snappy | ||
| cat build/apache_logs.txt | build/kafka/bin/kafka-console-producer.sh --topic logstash_integration_topic_lz4 --broker-list localhost:9092 --compression-codec lz4 | ||
| cat build/apache_logs.txt | build/kafka/bin/kafka-console-producer.sh --topic logstash_integration_topic_plain --bootstrap-server localhost:9092 | ||
| cat build/apache_logs.txt | build/kafka/bin/kafka-console-producer.sh --topic logstash_integration_topic_snappy --bootstrap-server localhost:9092 --compression-codec snappy | ||
| cat build/apache_logs.txt | build/kafka/bin/kafka-console-producer.sh --topic logstash_integration_topic_lz4 --bootstrap-server localhost:9092 --compression-codec lz4 | ||
|
|
||
| echo "Setup complete, running specs" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.