From 728ef338444c7cdef91d6e4c805aa39b5fb26913 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Mon, 7 Mar 2022 10:03:39 +0000 Subject: [PATCH] Remove use of Cloudflare zlib (#84680) Relates to #81662. This library isn't ready for public consumption. Remove it from the Docker build. --- distribution/docker/build.gradle | 21 ++------------ distribution/docker/src/docker/Dockerfile | 29 ------------------- distribution/src/bin/elasticsearch | 8 ----- docs/changelog/84680.yaml | 5 ++++ .../packaging/test/DockerTests.java | 11 ------- 5 files changed, 7 insertions(+), 67 deletions(-) create mode 100644 docs/changelog/84680.yaml diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index a2fa645a63b07..caa007ec0a58d 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -16,8 +16,6 @@ apply plugin: 'elasticsearch.test.fixtures' apply plugin: 'elasticsearch.internal-distribution-download' apply plugin: 'elasticsearch.rest-resources' -ext.cloudflareZlibVersion = '1.2.8' - String buildId = providers.systemProperty('build.id').getOrNull() boolean useLocalArtifacts = buildId != null && buildId.isBlank() == false @@ -36,15 +34,6 @@ repositories { content { includeGroup 'krallin' } } - ivy { - url 'https://github.com/' - patternLayout { - artifact '/[organisation]/[module]/archive/refs/tags/v[revision].[ext]' - } - metadataSources { artifact() } - content { includeGroup 'cloudflare' } - } - // Cloud builds bundle some beats ivy { if (useLocalArtifacts) { @@ -73,7 +62,6 @@ configurations { allPlugins filebeat metricbeat - cloudflareZlib } String beatsArch = Architecture.current() == Architecture.AARCH64 ? 'arm64' : 'x86_64' @@ -87,7 +75,6 @@ dependencies { allPlugins project(path: ':plugins', configuration: 'allPlugins') filebeat "beats:filebeat:${VersionProperties.elasticsearch}:${beatsArch}@tar.gz" metricbeat "beats:metricbeat:${VersionProperties.elasticsearch}:${beatsArch}@tar.gz" - cloudflareZlib "cloudflare:zlib:${cloudflareZlibVersion}@tar.gz" } ext.expansions = { Architecture architecture, DockerBase base -> @@ -112,8 +99,7 @@ ext.expansions = { Architecture architecture, DockerBase base -> 'docker_base' : base.name().toLowerCase(), 'version' : VersionProperties.elasticsearch, 'major_minor_version': "${major}.${minor}", - 'retry' : ShellRetry, - 'zlib_version' : cloudflareZlibVersion + 'retry' : ShellRetry ] } @@ -302,8 +288,7 @@ void addTransformDockerContextTask(Architecture architecture, DockerBase base) { eachFile { FileCopyDetails details -> if (details.name.equals("Dockerfile")) { filter { String filename -> - String result = filename.replaceAll('^RUN curl.*artifacts-no-kpi.*$', "COPY ${distributionName} /tmp/elasticsearch.tar.gz") - return result.replaceAll('^RUN curl.*cloudflare/zlib.*$', "COPY zlib-${cloudflareZlibVersion}.tar.gz /tmp") + return filename.replaceAll('^RUN curl.*artifacts-no-kpi.*$', "COPY ${distributionName} /tmp/elasticsearch.tar.gz") } } } @@ -317,8 +302,6 @@ void addTransformDockerContextTask(Architecture architecture, DockerBase base) { from configurations.dockerSource } - from configurations.cloudflareZlib - if (base == DockerBase.IRON_BANK) { from (configurations.tini) { rename { _ -> 'tini' } diff --git a/distribution/docker/src/docker/Dockerfile b/distribution/docker/src/docker/Dockerfile index d766357ee24c5..dcb2151298e32 100644 --- a/distribution/docker/src/docker/Dockerfile +++ b/distribution/docker/src/docker/Dockerfile @@ -25,32 +25,6 @@ ARG BASE_IMAGE=ironbank/redhat/ubi/ubi8 ARG BASE_TAG=8.5 <% } %> -################################################################################ -# Build stage 0 `zlib`: -# Compile zlib for the current architecture -################################################################################ - -FROM ${base_image} AS zlib - -<% if (docker_base == 'default' || docker_base == 'cloud') { %> -RUN <%= retry.loop(package_manager, "${package_manager} update && DEBIAN_FRONTEND=noninteractive ${package_manager} install -y curl gcc make") %> -<% } else { %> -RUN <%= retry.loop(package_manager, "${package_manager} install -y curl gcc make tar gzip") %> -<% } %> - -<% -// Fetch the zlib source. Keep this command on one line - it is replaced -// with a `COPY` during local builds. -%> -WORKDIR /tmp -RUN curl --retry 10 -S -L -o zlib-${zlib_version}.tar.gz https://github.com/cloudflare/zlib/archive/refs/tags/v${zlib_version}.tar.gz -RUN echo "7e393976368975446b263ae4143fb404bc33bf3b436e72007700b5b88e5be332cd461cdec42d31a4b6dffdca2368550f01b9fa1165d81c0aa818bbf2b1ac191e zlib-${zlib_version}.tar.gz" \\ - | sha512sum --check - -RUN tar xf zlib-${zlib_version}.tar.gz - -WORKDIR /tmp/zlib-${zlib_version} -RUN ./configure --prefix=/usr/local/cloudflare-zlib && make && make install - ################################################################################ # Build stage 1 `builder`: # Extract Elasticsearch artifact @@ -162,7 +136,6 @@ RUN chmod -R 0555 /opt/plugins ################################################################################ # Build stage 2 (the actual Elasticsearch image): # -# Copy zlib from stage 2 # Copy elasticsearch from stage 1 # Add entrypoint ################################################################################ @@ -224,14 +197,12 @@ WORKDIR /usr/share/elasticsearch COPY --from=builder --chown=0:0 /usr/share/elasticsearch /usr/share/elasticsearch COPY --from=builder --chown=0:0 /bin/tini /bin/tini -COPY --from=zlib --chown=0:0 /usr/local/cloudflare-zlib /usr/local/cloudflare-zlib <% if (docker_base == 'cloud') { %> COPY --from=builder --chown=0:0 /opt /opt <% } %> ENV PATH /usr/share/elasticsearch/bin:\$PATH -ENV ES_ZLIB_PATH /usr/local/cloudflare-zlib/lib COPY ${bin_dir}/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh diff --git a/distribution/src/bin/elasticsearch b/distribution/src/bin/elasticsearch index fbdcbb9acff3d..06279f90f5271 100755 --- a/distribution/src/bin/elasticsearch +++ b/distribution/src/bin/elasticsearch @@ -52,14 +52,6 @@ if [ -z "$LIBFFI_TMPDIR" ]; then export LIBFFI_TMPDIR fi -if [ -n "$ES_ZLIB_PATH" ]; then - if [ ! -d "$ES_ZLIB_PATH" ]; then - echo "zlib path specified in ES_ZLIB_PATH does not exist or is not a directory: $ES_ZLIB_PATH" >&2 - exit 1 - fi - export LD_LIBRARY_PATH="$ES_ZLIB_PATH:$LD_LIBRARY_PATH" -fi - # get keystore password before setting java options to avoid # conflicting GC configurations for the keystore tools unset KEYSTORE_PASSWORD diff --git a/docs/changelog/84680.yaml b/docs/changelog/84680.yaml new file mode 100644 index 0000000000000..f1395b3fbefe5 --- /dev/null +++ b/docs/changelog/84680.yaml @@ -0,0 +1,5 @@ +pr: 84680 +summary: Remove use of Cloudflare zlib +area: Packaging +type: bug +issues: [] diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DockerTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DockerTests.java index dc92789be15ea..eab0eeff91d76 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DockerTests.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/DockerTests.java @@ -413,17 +413,6 @@ public void test050BasicApiTests() throws Exception { runElasticsearchTestsAsElastic(PASSWORD); } - /** - * Check that the JDK uses the Cloudflare zlib, instead of the default one. - */ - public void test060JavaUsesCloudflareZlib() { - waitForElasticsearch(installation, "elastic", PASSWORD); - - final String output = sh.run("bash -c 'pmap -p $(pidof java)'").stdout(); - - assertThat("Expected java to be using cloudflare-zlib", output, containsString("cloudflare-zlib")); - } - /** * Check that the default config can be overridden using a bind mount, and that env vars are respected */