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-16827: Integrate kafka native-image with system tests #16046

Merged
merged 13 commits into from
May 30, 2024

Conversation

kagarwal06
Copy link
Contributor

@kagarwal06 kagarwal06 commented May 23, 2024

This PR does following things

  1. System tests should bring up Kafka broker in the native mode
  • bin/kafka-run-class.sh
  1. System tests should run on Kafka broker in native mode
  • tests/kafkatest/services/kafka/kafka.py
  • tests/kafkatest/services/security/templates/jaas.conf
  1. Extract out native build command so that it can be reused.
  • docker/native/Dockerfile
  • docker/native/native_command.sh
  1. Allow system tests to run on Native Kafka broker using Docker mechanism
  • tests/docker/run_tests.sh
  • tests/docker/Dockerfile
  • tests/docker/ducker-ak

To run system tests by bringing up Kafka in native mode:

  • Pass kafka_mode as native in the ducktape globals:--globals '{\"kafka_mode\":\"native\"}'
  • Running system tests by bringing up kafka in native mode via docker mechanism
_DUCKTAPE_OPTIONS="--globals '{\"kafka_mode\":\"native\"}'" TC_PATHS="tests/kafkatest/tests/"  bash tests/docker/run_tests.sh
  • To only bring up ducker nodes to cater native kafka
bash tests/docker/ducker-ak up -m native

TESTING
Ran system tests job 3 ways

  1. Ran ST on this branch in native mode: results-KAFKA-16827-native.txt
  2. Ran ST on this branch in jvm mode: results-KAFKA-16827-jvm.txt
  3. Ran ST on trunk(doesnt include these changes): results-trunk-jvm.txt

We can see the tests results are consistent.

Committer Checklist (excluded from commit message)

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

@kagarwal06 kagarwal06 marked this pull request as draft May 23, 2024 13:43
@kagarwal06 kagarwal06 marked this pull request as ready for review May 28, 2024 05:51
@@ -208,7 +208,7 @@ fi

# JMX settings
if [ -z "$KAFKA_JMX_OPTS" ]; then
KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maynot be required as default is true for this system property

Copy link
Contributor Author

@kagarwal06 kagarwal06 May 28, 2024

Choose a reason for hiding this comment

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

Yes, that is correct for JVM.
But the native binary requires it explicitly. Hence added this.

# Launch mode
if [ "x$DAEMON_MODE" = "xtrue" ]; then
nohup "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_CMD_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@" > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null &
if [ "$KAFKA_MODE" = "native" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the existing convention to test the string like if [ "x$KAFKA_MODE" = "xnative" ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if [ "x$DAEMON_MODE" = "xtrue" ]; then
nohup "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_CMD_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@" > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null &
if [ "$KAFKA_MODE" = "native" ]; then
exec $base_dir/kafka.Kafka start --config "$2" $KAFKA_LOG4J_CMD_OPTS $KAFKA_JMX_OPTS $KAFKA_OPTS
Copy link
Contributor

@omkreddy omkreddy May 28, 2024

Choose a reason for hiding this comment

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

Dont we need to pass $KAFKA_HEAP_OPTS to native run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per the native-image docs

When executing a native image, suitable Java heap settings will be determined automatically based on the system configuration and the used GC. 

Though they have given mechanism to override it explicitly, I am making use of the automatic mechanism.

@@ -926,7 +932,7 @@ def run_features_command(self, op, new_version):
def pids(self, node):
"""Return process ids associated with running processes on the given node."""
try:
cmd = "jcmd | grep -e %s | awk '{print $1}'" % self.java_class_name()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

jcmd command won't work if Kafka is running in the native mode.
Replacing it with ps ax.

@@ -994,7 +1000,7 @@ def thread_dump(self, node):
def clean_node(self, node):
JmxMixin.clean_node(self, node)
self.security_config.clean_node(node)
node.account.kill_java_processes(self.java_class_name(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

kill_java_processes command won't work if Kafka is running in the native mode.
Replacing it with kill_process.

@@ -55,6 +55,7 @@ KafkaServer {
useKeyTab=true
storeKey=true
keyTab="/mnt/security/keytab"
refreshKrb5Config=true
Copy link
Contributor Author

@kagarwal06 kagarwal06 May 28, 2024

Choose a reason for hiding this comment

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

This change is needed because of an issue in GraalVm native-image tool. They will fix it in upcoming releases.
I raised this in their community slack channel.
This is a workaround for now.
Conversation thread: https://graalvm.slack.com/archives/CN9KSFB40/p1700246576831259

else
export KAFKA_MODE="jvm"
fi
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we print the mode here

get_mode
cleanup && mkdir "${TMP_NATIVE_DIR}"
if [ "$KAFKA_MODE" == "native" ]; then
kafka_tarball_filename=(core/build/distributions/kafka*SNAPSHOT.tgz)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we print a line stating building for native image

Copy link
Contributor

@omkreddy omkreddy left a comment

Choose a reason for hiding this comment

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

@kagarwal06 Thanks for the PR. LGTM

@omkreddy omkreddy merged commit bb6a042 into apache:trunk May 30, 2024
1 check failed
chiacyu pushed a commit to chiacyu/kafka that referenced this pull request Jun 1, 2024
…6046)

This PR does following things

System tests should bring up Kafka broker in the native mode
System tests should run on Kafka broker in native mode
Extract out native build command so that it can be reused.
Allow system tests to run on Native Kafka broker using Docker mechanism

To run system tests by bringing up Kafka in native mode:
Pass kafka_mode as native in the ducktape globals:--globals '{\"kafka_mode\":\"native\"}'

Running system tests by bringing up kafka in native mode via docker mechanism
_DUCKTAPE_OPTIONS="--globals '{\"kafka_mode\":\"native\"}'" TC_PATHS="tests/kafkatest/tests/"  bash tests/docker/run_tests.sh

To only bring up ducker nodes to cater native kafka
bash tests/docker/ducker-ak up -m native

Reviewers: Manikumar Reddy <[email protected]>
wernerdv pushed a commit to wernerdv/kafka that referenced this pull request Jun 3, 2024
…6046)

This PR does following things

System tests should bring up Kafka broker in the native mode
System tests should run on Kafka broker in native mode
Extract out native build command so that it can be reused.
Allow system tests to run on Native Kafka broker using Docker mechanism

To run system tests by bringing up Kafka in native mode:
Pass kafka_mode as native in the ducktape globals:--globals '{\"kafka_mode\":\"native\"}'

Running system tests by bringing up kafka in native mode via docker mechanism
_DUCKTAPE_OPTIONS="--globals '{\"kafka_mode\":\"native\"}'" TC_PATHS="tests/kafkatest/tests/"  bash tests/docker/run_tests.sh

To only bring up ducker nodes to cater native kafka
bash tests/docker/ducker-ak up -m native

Reviewers: Manikumar Reddy <[email protected]>
TaiJuWu pushed a commit to TaiJuWu/kafka that referenced this pull request Jun 8, 2024
…6046)

This PR does following things

System tests should bring up Kafka broker in the native mode
System tests should run on Kafka broker in native mode
Extract out native build command so that it can be reused.
Allow system tests to run on Native Kafka broker using Docker mechanism

To run system tests by bringing up Kafka in native mode:
Pass kafka_mode as native in the ducktape globals:--globals '{\"kafka_mode\":\"native\"}'

Running system tests by bringing up kafka in native mode via docker mechanism
_DUCKTAPE_OPTIONS="--globals '{\"kafka_mode\":\"native\"}'" TC_PATHS="tests/kafkatest/tests/"  bash tests/docker/run_tests.sh

To only bring up ducker nodes to cater native kafka
bash tests/docker/ducker-ak up -m native

Reviewers: Manikumar Reddy <[email protected]>
gongxuanzhang pushed a commit to gongxuanzhang/kafka that referenced this pull request Jun 12, 2024
…6046)

This PR does following things

System tests should bring up Kafka broker in the native mode
System tests should run on Kafka broker in native mode
Extract out native build command so that it can be reused.
Allow system tests to run on Native Kafka broker using Docker mechanism

To run system tests by bringing up Kafka in native mode:
Pass kafka_mode as native in the ducktape globals:--globals '{\"kafka_mode\":\"native\"}'

Running system tests by bringing up kafka in native mode via docker mechanism
_DUCKTAPE_OPTIONS="--globals '{\"kafka_mode\":\"native\"}'" TC_PATHS="tests/kafkatest/tests/"  bash tests/docker/run_tests.sh

To only bring up ducker nodes to cater native kafka
bash tests/docker/ducker-ak up -m native

Reviewers: Manikumar Reddy <[email protected]>
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.

2 participants