From d6b71e66a922547f6d3c33be627dfe6b046a9563 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Wed, 8 Sep 2021 12:32:52 +0100 Subject: [PATCH 1/3] Fix shell retry generator for shells other than bash --- .../elasticsearch/gradle/internal/docker/ShellRetry.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/ShellRetry.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/ShellRetry.java index 5286a3af24619..e3193f7aea5d0 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/ShellRetry.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/ShellRetry.java @@ -8,6 +8,9 @@ package org.elasticsearch.gradle.internal.docker; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + /** * The methods in this class take a shell command and wrap it in retry logic, so that our * Docker builds can be more robust in the face of transient errors e.g. network issues. @@ -20,7 +23,11 @@ static String loop(String name, String command) { static String loop(String name, String command, int indentSize, String exitKeyword) { String indent = " ".repeat(indentSize); - StringBuilder commandWithRetry = new StringBuilder("for iter in {1..10}; do \n"); + // bash understands the `{1..10}` syntax, but other shells don't e.g. the default in Alpine Linux. + // We therefore use an explicit sequence. + String retrySequence = IntStream.rangeClosed(1, 10).mapToObj(String::valueOf).collect(Collectors.joining(" ")); + + StringBuilder commandWithRetry = new StringBuilder("for iter in " + retrySequence + "; do \n"); commandWithRetry.append(indent).append(" ").append(command).append(" && \n"); commandWithRetry.append(indent).append(" exit_code=0 && break || \n"); commandWithRetry.append(indent); From 325e4da455b9fd7973f907522737303585f31b4b Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Wed, 8 Sep 2021 12:48:56 +0100 Subject: [PATCH 2/3] Upgrade curl in Docker image --- distribution/docker/src/docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distribution/docker/src/docker/Dockerfile b/distribution/docker/src/docker/Dockerfile index 0266e9aca9c93..a69ce582cf725 100644 --- a/distribution/docker/src/docker/Dockerfile +++ b/distribution/docker/src/docker/Dockerfile @@ -76,7 +76,7 @@ RUN chmod 0555 /bin/tini ################################################################################ FROM alpine:3.13 AS curl -ENV VERSION 7.71.0 +ENV VERSION 7.78.0 ENV TARBALL_URL https://curl.haxx.se/download/curl-\${VERSION}.tar.xz ENV TARBALL_PATH curl-\${VERSION}.tar.xz @@ -104,7 +104,7 @@ RUN gpg --import --always-trust "curl-gpg.pub" && \\ RUN set -e ; \\ tar xfJ "\${TARBALL_PATH}" ; \\ cd "curl-\${VERSION}" ; \\ - if ! ./configure --disable-shared --with-ca-fallback --with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt ; then \\ + if ! ./configure --with-openssl --disable-shared --with-ca-fallback --with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt ; then \\ [[ -e config.log ]] && cat config.log ; \\ exit 1 ; \\ fi ; \\ From 1498524a75813eb1bc46a80131ff3e8be6421caf Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Fri, 10 Sep 2021 11:53:35 +0100 Subject: [PATCH 3/3] Revert curl upgrade as the binary couldn't execute --- distribution/docker/build.gradle | 4 ++++ distribution/docker/src/docker/Dockerfile | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 3b83bd1438415..dc9e4544791c6 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -221,6 +221,10 @@ tasks.named("composePull").configure { enabled = false } +tasks.named("composeUp").configure { + dependsOn tasks.named("preProcessFixture") +} + void addBuildDockerContextTask(Architecture architecture, DockerBase base) { String configDirectory = base == DockerBase.IRON_BANK ? 'scripts' : 'config' String arch = architecture == Architecture.AARCH64 ? '-aarch64' : '' diff --git a/distribution/docker/src/docker/Dockerfile b/distribution/docker/src/docker/Dockerfile index a69ce582cf725..0266e9aca9c93 100644 --- a/distribution/docker/src/docker/Dockerfile +++ b/distribution/docker/src/docker/Dockerfile @@ -76,7 +76,7 @@ RUN chmod 0555 /bin/tini ################################################################################ FROM alpine:3.13 AS curl -ENV VERSION 7.78.0 +ENV VERSION 7.71.0 ENV TARBALL_URL https://curl.haxx.se/download/curl-\${VERSION}.tar.xz ENV TARBALL_PATH curl-\${VERSION}.tar.xz @@ -104,7 +104,7 @@ RUN gpg --import --always-trust "curl-gpg.pub" && \\ RUN set -e ; \\ tar xfJ "\${TARBALL_PATH}" ; \\ cd "curl-\${VERSION}" ; \\ - if ! ./configure --with-openssl --disable-shared --with-ca-fallback --with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt ; then \\ + if ! ./configure --disable-shared --with-ca-fallback --with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt ; then \\ [[ -e config.log ]] && cat config.log ; \\ exit 1 ; \\ fi ; \\