-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Changes from all commits
a76f457
6e7c057
59e84df
a3f6b46
0419312
a9c07aa
380f2d8
a4b8063
ebe5c1b
778d8af
adab89a
e25f977
2fcf50f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 " | ||
fi | ||
|
||
# JMX port to use | ||
|
@@ -340,9 +340,16 @@ CLASSPATH=${CLASSPATH#:} | |
# If Cygwin is detected, classpath is converted to Windows format. | ||
(( WINDOWS_OS_FORMAT )) && CLASSPATH=$(cygpath --path --mixed "${CLASSPATH}") | ||
|
||
# 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, it will bring up Kafka in the native mode. | ||
# It expects the Kafka executable binary to be present at $base_dir/kafka.Kafka. | ||
# This is specifically used to run system tests on native Kafka - by bringing up Kafka in the native mode. | ||
if [[ "x$KAFKA_MODE" == "xnative" ]] && [[ "$*" == *"kafka.Kafka"* ]]; then | ||
exec $base_dir/kafka.Kafka start --config "$2" $KAFKA_LOG4J_CMD_OPTS $KAFKA_JMX_OPTS $KAFKA_OPTS | ||
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. Dont we need to pass 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. As per the
Though they have given mechanism to override it explicitly, I am making use of the automatic mechanism. |
||
else | ||
exec "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_CMD_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@" | ||
# 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 & | ||
else | ||
exec "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_CMD_OPTS -cp "$CLASSPATH" $KAFKA_OPTS "$@" | ||
fi | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# $1 - The path of the GraalVM native-image. This binary is used to compile Java applications ahead-of-time into a standalone native binary. | ||
# $2 - The path of the directory that contains the native-image configuration files. | ||
# $3 - The path of the directory that contains the Apache Kafka libs. | ||
# $4 - The path of the resulting Kafka native binary after the build process. | ||
|
||
$1 --no-fallback \ | ||
--enable-http \ | ||
--enable-https \ | ||
--allow-incomplete-classpath \ | ||
--report-unsupported-elements-at-runtime \ | ||
--install-exit-handlers \ | ||
--enable-monitoring=jmxserver,jmxclient,heapdump,jvmstat \ | ||
-H:+ReportExceptionStackTraces \ | ||
-H:+EnableAllSecurityServices \ | ||
-H:EnableURLProtocols=http,https \ | ||
-H:AdditionalSecurityProviders=sun.security.jgss.SunProvider \ | ||
-H:ReflectionConfigurationFiles="$2"/reflect-config.json \ | ||
-H:JNIConfigurationFiles="$2"/jni-config.json \ | ||
-H:ResourceConfigurationFiles="$2"/resource-config.json \ | ||
-H:SerializationConfigurationFiles="$2"/serialization-config.json \ | ||
-H:PredefinedClassesConfigurationFiles="$2"/predefined-classes-config.json \ | ||
-H:DynamicProxyConfigurationFiles="$2"/proxy-config.json \ | ||
--verbose \ | ||
-march=compatibility \ | ||
-cp "$3/*" kafka.docker.KafkaDockerWrapper \ | ||
-o "$4" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,34 @@ | |
# limitations under the License. | ||
|
||
ARG jdk_version=openjdk:8 | ||
FROM $jdk_version AS build-native-image | ||
|
||
WORKDIR /build | ||
|
||
COPY native/ native | ||
|
||
ARG KAFKA_MODE | ||
ARG GRAALVM_URL="https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.1/graalvm-community-jdk-21.0.1_linux-aarch64_bin.tar.gz" | ||
|
||
ENV NATIVE_IMAGE_PATH="/build/graalvm/bin/native-image" | ||
ENV NATIVE_CONFIGS_DIR="/build/native/native-image-configs" | ||
ENV KAFKA_LIBS_DIR="/build/kafka/libs" | ||
ENV KAFKA_BIN_DIR="/build/kafka-binary" | ||
ENV TARGET_PATH="$KAFKA_BIN_DIR/kafka.Kafka" | ||
|
||
RUN mkdir $KAFKA_BIN_DIR | ||
|
||
RUN if [ "$KAFKA_MODE" = "native" ]; then \ | ||
apt update && apt install -y sudo build-essential libz-dev zlib1g-dev curl jq coreutils libffi-dev cmake pkg-config libfuse-dev && apt-get -y clean ; \ | ||
mkdir graalvm ; \ | ||
curl -L "$GRAALVM_URL" -o graalvm.tar.gz ; \ | ||
tar -xzf graalvm.tar.gz -C graalvm --strip-components=1 ; \ | ||
mkdir kafka ; \ | ||
tar xfz native/kafka.tgz -C kafka --strip-components 1 ; \ | ||
rm graalvm.tar.gz kafka.tgz ; \ | ||
/build/native/native_command.sh $NATIVE_IMAGE_PATH $NATIVE_CONFIGS_DIR $KAFKA_LIBS_DIR $TARGET_PATH ; \ | ||
fi | ||
|
||
FROM $jdk_version | ||
|
||
MAINTAINER Apache Kafka [email protected] | ||
|
@@ -37,6 +65,7 @@ RUN apt update && apt install -y sudo git netcat iptables rsync unzip wget curl | |
RUN python3 -m pip install -U pip==21.1.1; | ||
RUN pip3 install --upgrade cffi virtualenv pyasn1 boto3 pycrypto pywinrm ipaddress enum34 debugpy && pip3 install --upgrade "ducktape>0.8" | ||
|
||
COPY --from=build-native-image /build/kafka-binary/ /opt/kafka-binary/ | ||
# Set up ssh | ||
COPY ./ssh-config /root/.ssh/config | ||
# NOTE: The paramiko library supports the PEM-format private key, but does not support the RFC4716 format. | ||
|
@@ -107,7 +136,7 @@ ARG KIBOSH_VERSION="8841dd392e6fbf02986e2fb1f1ebf04df344b65a" | |
ARG UID="1000" | ||
|
||
# Install Kibosh | ||
RUN apt-get install fuse | ||
RUN apt-get install fuse -y | ||
RUN cd /opt && git clone -q https://github.com/confluentinc/kibosh.git && cd "/opt/kibosh" && git reset --hard $KIBOSH_VERSION && mkdir "/opt/kibosh/build" && cd "/opt/kibosh/build" && ../configure && make -j 2 | ||
|
||
# Set up the ducker user. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -806,7 +806,13 @@ def render_configs(self, configs): | |
return s | ||
|
||
def start_cmd(self, node): | ||
cmd = "export JMX_PORT=%d; " % self.jmx_port | ||
""" | ||
To bring up kafka using native image, pass following in ducktape options | ||
--globals '{"kafka_mode": "native"}' | ||
""" | ||
kafka_mode = self.context.globals.get("kafka_mode", "") | ||
cmd = f"export KAFKA_MODE={kafka_mode}; " | ||
cmd += "export JMX_PORT=%d; " % self.jmx_port | ||
cmd += "export KAFKA_LOG4J_OPTS=\"-Dlog4j.configuration=file:%s\"; " % self.LOG4J_CONFIG | ||
heap_kafka_opts = "-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%s" % \ | ||
self.logs["kafka_heap_dump_file"]["path"] | ||
|
@@ -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() | ||
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.
|
||
cmd = "ps ax | grep -i %s | grep -v grep | awk '{print $1}'" % self.java_class_name() | ||
pid_arr = [pid for pid in node.account.ssh_capture(cmd, allow_fail=True, callback=int)] | ||
return pid_arr | ||
except (RemoteCommandError, ValueError) as e: | ||
|
@@ -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(), | ||
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.
|
||
node.account.kill_process(self.java_class_name(), | ||
clean_shutdown=False, allow_fail=True) | ||
node.account.ssh("sudo rm -rf -- %s" % KafkaService.PERSISTENT_ROOT, allow_fail=False) | ||
|
||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.