Skip to content

Commit

Permalink
[Backport 2.x] Run docker OS cluster with different JDK version (#338)
Browse files Browse the repository at this point in the history
Signed-off-by: Khushboo Rajput <[email protected]>
  • Loading branch information
khushbr authored Apr 17, 2023
1 parent ac92f17 commit 48136d5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
# Enable RCA for Integration Tests
- name: Spin up Docker cluster for integ testing
working-directory: ./tmp/performance-analyzer-rca
run: ./gradlew enableRca
run: ./gradlew enableRca -Dbuild.docker_jdk_ver=${{matrix.java}}

# Run Integration Tests in PA
- name: Run integration tests
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ ext {
opensearch_version = System.getProperty("opensearch.version", "2.7.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
buildDockerJdkVersion = System.getProperty("build.docker_jdk_ver", "11")

// 2.4.0-SNAPSHOT -> 2.4.0.0-SNAPSHOT
// 2.7.0-SNAPSHOT -> 2.7.0.0-SNAPSHOT
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
if (buildVersionQualifier) {
Expand Down Expand Up @@ -473,7 +474,7 @@ task buildDocker(type: Exec) {
dependsOn(copyAllArtifacts)

workingDir(dockerArtifactsDir)
commandLine 'docker', 'build', '-t', 'opensearch/pa-rca:2.4', '.'
commandLine 'docker', 'build', '-t', 'opensearch/pa-rca:2.7', '.', '--build-arg', "JDK_VER=${buildDockerJdkVersion}"
}

task runDocker(type: Exec) {
Expand Down
26 changes: 21 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@
################################################################################

FROM centos:7 AS prep_open_search_files
ARG JDK_VER=11

ENV PATH /usr/share/opensearch/bin:$PATH
RUN curl -s https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz | tar -C /opt -zxf -
ENV OPENSEARCH_JAVA_HOME /opt/jdk-11.0.1

RUN if [[ "${JDK_VER}" = "17" ]] ; then \
curl -s https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz | tar -C /opt -zxf -; \
mkdir /opt/jdk ; \
mv -v /opt/jdk-17.0.2/* /opt/jdk; \
else \
curl -s https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz | tar -C /opt -zxf -; \
mkdir /opt/jdk ; \
mv -v /opt/jdk-11.0.1/* /opt/jdk; \
fi


ENV OPENSEARCH_JAVA_HOME /opt/jdk
RUN yum install -y unzip
RUN yum install -y lsof

Expand Down Expand Up @@ -54,6 +66,10 @@ RUN chown -R opensearch:0 . && \
RUN unzip config/performance-analyzer-rca-2.7.0.0-SNAPSHOT.zip

RUN chmod -R 755 /dev/shm

RUN if [[ "${JDK_VER}" = "17" ]] ; then \
echo "--add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED" >> /usr/share/opensearch/config/jvm.options ; \
fi
################################################################################
# Build stage 1 (the actual OpenSearch image):
# Copy OpenSearch from stage 0
Expand Down Expand Up @@ -86,13 +102,13 @@ RUN yum update -y && \
yum install -y nc unzip wget which && \
yum clean all
COPY CENTOS_LICENSING.txt /root
COPY --from=prep_open_search_files --chown=1000:0 /opt/jdk-11.0.1 /opt/jdk-11.0.1
ENV OPENSEARCH_JAVA_HOME /opt/jdk-11.0.1
COPY --from=prep_open_search_files --chown=1000:0 /opt/jdk /opt/jdk
ENV OPENSEARCH_JAVA_HOME /opt/jdk
ENV OPENSEARCH_PATH_CONF /usr/share/opensearch/config

# Replace OpenJDK's built-in CA certificate keystore with the one from the OS
# vendor. The latter is superior in several ways.
RUN ln -sf /etc/pki/ca-trust/extracted/java/cacerts /opt/jdk-11.0.1/lib/security/cacerts
RUN ln -sf /etc/pki/ca-trust/extracted/java/cacerts /opt/jdk/lib/security/cacerts

ENV PATH $PATH:$OPENSEARCH_JAVA_HOME/bin

Expand Down

0 comments on commit 48136d5

Please sign in to comment.