Skip to content

Commit 99fafc4

Browse files
KAFKA-19876 Use eclipse-temurin as the base image to align with 3.9 (#20945)
`sapmachine` doesn't support JDK 8, so we switched to use `eclipse-temurin` so that previous AK versions such as AK 3.9 (#20897) can use the same image provider. We also use symlinks to fix the java path problem for `eclipse-temurin`, based on a solution proposed by @unknowntpo. # Java path problem and its solution After switching to `eclipse-temurin`, we encountered a `java not found` problem. This was unexpected because we had already written PATH to `~/.ssh/environment` and set `PermitUserEnvironment yes` in `sshd_config`. It turns out that the `PAM (Pluggable Authentication Modules)` re-reads `/etc/environment` after `~/.ssh/environment`. Unfortunately, there is a `PATH` variable in `/etc/environment` in ubuntu, which overwrites the `PATH` from `~/.ssh/environment`. Some images didn't have this problem because the java path was already in `PATH` before we changed it. The possible solutions are: * Prevent PAM from reading `/etc/environment` by editing `/etc/pam.d/sshd` * Write PATH to `~/.pam_environment` (ref: [help.ubuntu article](https://help.ubuntu.com/community/EnvironmentVariables#A.2BAH4-.2F.pam_environment)) * Write PATH to `/etc/environment/` * Add a symlink so that java can be found without changing PATH However, we think first two solutions are prone to being distribution-specific. Modifying `/etc/environment` affects all users' `PATH`, which is not ideal. Therefore, we adopt the symlink solution suggested by @unknowntpo Passed `pluggable_test` on my local mac with image `eclipse-temurin:17-jdk-jammy` ``` > TC_PATHS="tests/kafkatest/tests/client/pluggable_test.py" bash tests/docker/run_tests.sh ... docker build --memory=3200m --build-arg ducker_creator= --build-arg jdk_version=eclipse-temurin:17-jdk-jammy --build-arg UID=501 --build-arg KAFKA_MODE=jvm -t ducker-ak-eclipse-temurin-17-jdk-jammy -f /Users/ming/code/kafka/tests/docker/Dockerfile -- . ... ================================================================================ SESSION REPORT (ALL TESTS) ducktape version: 0.12.0 session_id: 2025-11-21--001 run time: 15.249 seconds tests run: 1 passed: 1 flaky: 0 failed: 0 ignored: 0 ================================================================================ test_id: kafkatest.tests.client.pluggable_test.PluggableConsumerTest.test_start_stop.metadata_quorum=ISOLATED_KRAFT status: PASS run time: 15.103 seconds -------------------------------------------------------------------------------- ``` Reviewers: Chia-Ping Tsai <[email protected]> Co-authored-by: Eric Chang <[email protected]>
1 parent e8459d3 commit 99fafc4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/docker/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,13 @@ RUN useradd -u $UID -ms /bin/bash ducker \
149149
&& mkdir -p /home/ducker/ \
150150
&& rsync -aiq /root/.ssh/ /home/ducker/.ssh \
151151
&& chown -R ducker /home/ducker/ /mnt/ /var/log/ \
152-
&& echo "PATH=$(runuser -l ducker -c 'echo $PATH'):$JAVA_HOME/bin" >> /home/ducker/.ssh/environment \
153-
&& echo 'PATH=$PATH:'"$JAVA_HOME/bin" >> /home/ducker/.profile \
154152
&& echo 'ducker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
155153

154+
# Symlink all JDK binaries (java, jcmd, jps, etc.) to /usr/bin.
155+
# We don't add PATH env to ~/.ssh/environment because on some Linux distributions,
156+
# PAM (Pluggable Authentication Modules) may re-read /etc/environment, overwriting PATH.
157+
RUN cp -sn $JAVA_HOME/bin/* /usr/bin/
158+
156159
USER ducker
157160

158161
CMD ["sudo", "service", "ssh", "start", "-D"]

tests/docker/ducker-ak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ default_num_nodes=14
4646

4747
# The default JDK base image with apt-get support.
4848
# The openjdk image has been officially deprecated. For more information, see: https://hub.docker.com/_/openjdk
49-
default_jdk="sapmachine:17-jdk-ubuntu-jammy"
49+
default_jdk="eclipse-temurin:17-jdk-jammy"
5050

5151
# The default ducker-ak image name.
5252
default_image_name="ducker-ak"

0 commit comments

Comments
 (0)