Skip to content

Commit 3339be8

Browse files
committed
[8.17] Revert Replace cloud-ess docker image with wolfi-ess (#114413)
1 parent 181908c commit 3339be8

File tree

15 files changed

+129
-62
lines changed

15 files changed

+129
-62
lines changed

.buildkite/pipelines/pull-request/packaging-tests-unix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ steps:
55
steps:
66
- label: "{{matrix.image}} / docker / packaging-tests-unix"
77
key: "packaging-tests-unix-docker"
8-
command: ./.ci/scripts/packaging-test.sh destructiveDistroTest.docker-cloud-ess
8+
command: ./.ci/scripts/packaging-test.sh destructiveDistroTest.docker
99
timeout_in_minutes: 300
1010
matrix:
1111
setup:

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DockerBase.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public enum DockerBase {
2121
// The Iron Bank base image is UBI (albeit hardened), but we are required to parameterize the Docker build
2222
IRON_BANK("${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}", "-ironbank", "yum"),
2323

24+
// Based on CLOUD above, with more extras. We don't set a base image because
25+
// we programmatically extend from the Cloud image.
26+
CLOUD_ESS(null, "-cloud-ess", "apt-get"),
27+
2428
// Chainguard based wolfi image with latest jdk
2529
// This is usually updated via renovatebot
2630
// spotless:off
@@ -31,8 +35,8 @@ public enum DockerBase {
3135
// spotless:on
3236

3337
// Based on WOLFI above, with more extras. We don't set a base image because
34-
// we programmatically extend from the wolfi image.
35-
CLOUD_ESS(null, "-cloud-ess", "apk");
38+
// we programmatically extend from the Wolfi image.
39+
WOLFI_ESS(null, "-wolfi-ess", "apk");
3640

3741
private final String image;
3842
private final String suffix;

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ private static String distributionProjectName(ElasticsearchDistribution distribu
185185
if (distribution.getType() == InternalElasticsearchDistributionTypes.DOCKER_WOLFI) {
186186
return projectName + "wolfi-docker" + archString + "-export";
187187
}
188+
if (distribution.getType() == InternalElasticsearchDistributionTypes.DOCKER_WOLFI_ESS) {
189+
return projectName + "wolfi-ess-docker" + archString + "-export";
190+
}
188191
return projectName + distribution.getType().getName();
189192
}
190193

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.gradle.internal.distribution;
11+
12+
import org.elasticsearch.gradle.ElasticsearchDistributionType;
13+
14+
public class DockerWolfiEssElasticsearchDistributionType implements ElasticsearchDistributionType {
15+
16+
DockerWolfiEssElasticsearchDistributionType() {}
17+
18+
@Override
19+
public String getName() {
20+
return "dockerWolfiEss";
21+
}
22+
23+
@Override
24+
public boolean isDocker() {
25+
return true;
26+
}
27+
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/distribution/InternalElasticsearchDistributionTypes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class InternalElasticsearchDistributionTypes {
2121
public static ElasticsearchDistributionType DOCKER_IRONBANK = new DockerIronBankElasticsearchDistributionType();
2222
public static ElasticsearchDistributionType DOCKER_CLOUD_ESS = new DockerCloudEssElasticsearchDistributionType();
2323
public static ElasticsearchDistributionType DOCKER_WOLFI = new DockerWolfiElasticsearchDistributionType();
24+
public static ElasticsearchDistributionType DOCKER_WOLFI_ESS = new DockerWolfiEssElasticsearchDistributionType();
2425

2526
public static List<ElasticsearchDistributionType> ALL_INTERNAL = List.of(
2627
DEB,
@@ -29,6 +30,7 @@ public class InternalElasticsearchDistributionTypes {
2930
DOCKER_UBI,
3031
DOCKER_IRONBANK,
3132
DOCKER_CLOUD_ESS,
32-
DOCKER_WOLFI
33+
DOCKER_WOLFI,
34+
DOCKER_WOLFI_ESS
3335
);
3436
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/DistroTestPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_IRONBANK;
5454
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_UBI;
5555
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_WOLFI;
56+
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_WOLFI_ESS;
5657
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.RPM;
5758
import static org.elasticsearch.gradle.internal.util.ParamsUtils.loadBuildParams;
5859

@@ -152,6 +153,7 @@ private static Map<ElasticsearchDistributionType, TaskProvider<?>> lifecycleTask
152153
lifecyleTasks.put(DOCKER_IRONBANK, project.getTasks().register(taskPrefix + ".docker-ironbank"));
153154
lifecyleTasks.put(DOCKER_CLOUD_ESS, project.getTasks().register(taskPrefix + ".docker-cloud-ess"));
154155
lifecyleTasks.put(DOCKER_WOLFI, project.getTasks().register(taskPrefix + ".docker-wolfi"));
156+
lifecyleTasks.put(DOCKER_WOLFI_ESS, project.getTasks().register(taskPrefix + ".docker-wolfi-ess"));
155157
lifecyleTasks.put(ARCHIVE, project.getTasks().register(taskPrefix + ".archives"));
156158
lifecyleTasks.put(DEB, project.getTasks().register(taskPrefix + ".packages"));
157159
lifecyleTasks.put(RPM, lifecyleTasks.get(DEB));

distribution/docker/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ the [DockerBase] enum.
77
* UBI - the same as the default image, but based upon [RedHat's UBI
88
images][ubi], specifically their minimal flavour.
99
* Wolfi - the same as the default image, but based upon [Wolfi](https://github.com/wolfi-dev)
10-
* Cloud ESS - this directly extends the Wolfi image, and adds all ES plugins
10+
* Wolfi ESS - this directly extends the Wolfi image, and adds all ES plugins
1111
that the ES build generates in an archive directory. It also sets an
1212
environment variable that points at this directory. This allows plugins to
1313
be installed from the archive instead of the internet, speeding up
@@ -23,13 +23,20 @@ the [DockerBase] enum.
2323
software (FOSS) and Commercial off-the-shelf (COTS). In practice, this is
2424
another UBI build, this time on the regular UBI image, with extra
2525
hardening. See below for more details.
26+
2627
* Cloud - this is mostly the same as the default image, with some notable differences:
2728
* `filebeat` and `metricbeat` are included
2829
* `wget` is included
2930
* The `ENTRYPOINT` is just `/bin/tini`, and the `CMD` is
3031
`/app/elasticsearch.sh`. In normal use this file would be bind-mounted
3132
in, but the image ships a stub version of this file so that the image
3233
can still be tested.
34+
* Cloud ESS - this directly extends the Cloud image, and adds all ES plugins
35+
that the ES build generates in an archive directory. It also sets an
36+
environment variable that points at this directory. This allows plugins to
37+
be installed from the archive instead of the internet, speeding up
38+
deployment times.
39+
3340
The long-term goal is for both Cloud images to be retired in favour of the
3441
default image.
3542

distribution/docker/build.gradle

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ private static List<String> generateTags(DockerBase base, Architecture architect
366366
String image = "elasticsearch${base.suffix}"
367367

368368
String namespace = 'elasticsearch'
369-
if (base == base == DockerBase.CLOUD_ESS) {
369+
if (base == DockerBase.CLOUD_ESS || base == DockerBase.WOLFI_ESS) {
370370
namespace += '-ci'
371371
}
372372

@@ -431,8 +431,7 @@ void addBuildDockerImageTask(Architecture architecture, DockerBase base) {
431431
}
432432
}
433433

434-
void addBuildEssDockerImageTask(Architecture architecture) {
435-
DockerBase dockerBase = DockerBase.CLOUD_ESS
434+
void addBuildEssDockerImageTask(Architecture architecture, DockerBase dockerBase) {
436435
String arch = architecture == Architecture.AARCH64 ? '-aarch64' : ''
437436
String contextDir = "${project.buildDir}/docker-context/elasticsearch${dockerBase.suffix}-${VersionProperties.elasticsearch}-docker-build-context${arch}"
438437

@@ -446,20 +445,22 @@ void addBuildEssDockerImageTask(Architecture architecture) {
446445
from configurations.allPlugins
447446
}
448447

449-
// If we're performing a release build, but `build.id` hasn't been set, we can
450-
// infer that we're not at the Docker building stage of the build, and therefore
451-
// we should skip the beats part of the build.
452-
String buildId = providers.systemProperty('build.id').getOrNull()
453-
boolean includeBeats = VersionProperties.isElasticsearchSnapshot() == true || buildId != null || useDra
448+
if (dockerBase == DockerBase.WOLFI_ESS) {
449+
// If we're performing a release build, but `build.id` hasn't been set, we can
450+
// infer that we're not at the Docker building stage of the build, and therefore
451+
// we should skip the beats part of the build.
452+
String buildId = providers.systemProperty('build.id').getOrNull()
453+
boolean includeBeats = VersionProperties.isElasticsearchSnapshot() == true || buildId != null || useDra
454454

455-
if (includeBeats) {
456-
from configurations.getByName("filebeat_${architecture.classifier}")
457-
from configurations.getByName("metricbeat_${architecture.classifier}")
455+
if (includeBeats) {
456+
from configurations.getByName("filebeat_${architecture.classifier}")
457+
from configurations.getByName("metricbeat_${architecture.classifier}")
458+
}
459+
// For some reason, the artifact name can differ depending on what repository we used.
460+
rename ~/((?:file|metric)beat)-.*\.tar\.gz$/, "\$1-${VersionProperties.elasticsearch}.tar.gz"
458461
}
459-
// For some reason, the artifact name can differ depending on what repository we used.
460-
rename ~/((?:file|metric)beat)-.*\.tar\.gz$/, "\$1-${VersionProperties.elasticsearch}.tar.gz"
461462

462-
String baseSuffix = DockerBase.WOLFI.suffix
463+
String baseSuffix = dockerBase == DockerBase.CLOUD_ESS ? DockerBase.CLOUD.suffix : DockerBase.WOLFI.suffix
463464
from(projectDir.resolve("src/docker/Dockerfile.ess")) {
464465
expand(
465466
[
@@ -477,7 +478,7 @@ void addBuildEssDockerImageTask(Architecture architecture) {
477478
final TaskProvider<DockerBuildTask> buildDockerImageTask =
478479
tasks.register(taskName("build", architecture, dockerBase, "DockerImage"), DockerBuildTask) {
479480

480-
DockerBase base = DockerBase.WOLFI
481+
DockerBase base = dockerBase == DockerBase.CLOUD_ESS ? DockerBase.CLOUD : DockerBase.WOLFI
481482

482483
TaskProvider<DockerBuildTask> buildBaseTask = tasks.named(taskName("build", architecture, base, "DockerImage"))
483484
inputs.files(buildBaseTask)
@@ -503,15 +504,16 @@ void addBuildEssDockerImageTask(Architecture architecture) {
503504

504505
for (final Architecture architecture : Architecture.values()) {
505506
for (final DockerBase base : DockerBase.values()) {
506-
if (base == DockerBase.CLOUD_ESS) {
507+
if (base == DockerBase.CLOUD_ESS || base == DockerBase.WOLFI_ESS) {
507508
continue
508509
}
509510
addBuildDockerContextTask(architecture, base)
510511
addTransformDockerContextTask(architecture, base)
511512
addBuildDockerImageTask(architecture, base)
512513
}
513514

514-
addBuildEssDockerImageTask(architecture)
515+
addBuildEssDockerImageTask(architecture, DockerBase.CLOUD_ESS)
516+
addBuildEssDockerImageTask(architecture, DockerBase.WOLFI_ESS)
515517
}
516518

517519
def exportDockerImages = tasks.register("exportDockerImages")
@@ -542,7 +544,8 @@ subprojects { Project subProject ->
542544
(base == DockerBase.IRON_BANK ? 'ironbank.tar' :
543545
(base == DockerBase.CLOUD_ESS ? 'cloud-ess.tar' :
544546
(base == DockerBase.WOLFI ? 'wolfi.tar' :
545-
'docker.tar')))
547+
(base == DockerBase.WOLFI_ESS ? 'wolfi-ess.tar' :
548+
'docker.tar'))));
546549
final String artifactName = "elasticsearch${arch}${base.suffix}_test"
547550

548551
final String exportTaskName = taskName("export", architecture, base, 'DockerImage')

distribution/docker/src/docker/Dockerfile.ess

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,34 @@ FROM ${base_image} AS builder
22

33
USER root
44

5-
# Add plugins infrastructure
6-
RUN mkdir -p /opt/plugins/archive
7-
RUN chmod -R 0555 /opt/plugins
8-
9-
COPY filebeat-${version}.tar.gz metricbeat-${version}.tar.gz /tmp/
10-
RUN set -eux ; \\
11-
for beat in filebeat metricbeat ; do \\
12-
if [ ! -s /tmp/\$beat-${version}.tar.gz ]; then \\
13-
echo "/tmp/\$beat-${version}.tar.gz is empty - cannot uncompress" 2>&1 ; \\
14-
exit 1 ; \\
15-
fi ; \\
16-
if ! tar tf /tmp/\$beat-${version}.tar.gz >/dev/null; then \\
17-
echo "/tmp/\$beat-${version}.tar.gz is corrupt - cannot uncompress" 2>&1 ; \\
18-
exit 1 ; \\
19-
fi ; \\
20-
mkdir -p /opt/\$beat ; \\
21-
tar xf /tmp/\$beat-${version}.tar.gz -C /opt/\$beat --strip-components=1 ; \\
22-
done
5+
<% if (docker_base == "wolfi_ess") { %>
6+
# Add plugins infrastructure
7+
RUN mkdir -p /opt/plugins/archive
8+
RUN chmod -R 0555 /opt/plugins
9+
10+
COPY filebeat-${version}.tar.gz metricbeat-${version}.tar.gz /tmp/
11+
RUN set -eux ; \\
12+
for beat in filebeat metricbeat ; do \\
13+
if [ ! -s /tmp/\$beat-${version}.tar.gz ]; then \\
14+
echo "/tmp/\$beat-${version}.tar.gz is empty - cannot uncompress" 2>&1 ; \\
15+
exit 1 ; \\
16+
fi ; \\
17+
if ! tar tf /tmp/\$beat-${version}.tar.gz >/dev/null; then \\
18+
echo "/tmp/\$beat-${version}.tar.gz is corrupt - cannot uncompress" 2>&1 ; \\
19+
exit 1 ; \\
20+
fi ; \\
21+
mkdir -p /opt/\$beat ; \\
22+
tar xf /tmp/\$beat-${version}.tar.gz -C /opt/\$beat --strip-components=1 ; \\
23+
done
24+
<% } %>
2325

2426
COPY plugins/*.zip /opt/plugins/archive/
2527

2628
RUN chown 1000:1000 /opt/plugins/archive/*
2729
RUN chmod 0444 /opt/plugins/archive/*
2830

2931
FROM ${base_image}
32+
<% if (docker_base == "wolfi_ess") { %>
3033
USER root
3134

3235
RUN <%= retry.loop("apk", "export DEBIAN_FRONTEND=noninteractive && apk update && apk update && apk add --no-cache wget") %>
@@ -41,4 +44,8 @@ RUN mkdir /app && \\
4144

4245
COPY --from=builder --chown=0:0 /opt /opt
4346
USER 1000:0
47+
<% } else { %>
48+
COPY --from=builder /opt/plugins /opt/plugins
49+
<% } %>
50+
4451
ENV ES_PLUGIN_ARCHIVE_DIR /opt/plugins/archive

qa/packaging/src/test/java/org/elasticsearch/packaging/test/DockerTests.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
* <li>The default image with a custom, small base image</li>
100100
* <li>A UBI-based image</li>
101101
* <li>Another UBI image for Iron Bank</li>
102-
* <li>A WOLFI-based image</li>
103102
* <li>Images for Cloud</li>
104103
* </ul>
105104
*/
@@ -169,7 +168,10 @@ public void test012SecurityCanBeDisabled() throws Exception {
169168
* Checks that no plugins are initially active.
170169
*/
171170
public void test020PluginsListWithNoPlugins() {
172-
assumeTrue("Only applies to non-Cloud images", distribution().packaging != Packaging.DOCKER_CLOUD_ESS);
171+
assumeTrue(
172+
"Only applies to non-Cloud images",
173+
distribution().packaging != Packaging.DOCKER_CLOUD_ESS && distribution().packaging != Packaging.DOCKER_WOLFI_ESS
174+
);
173175

174176
final Installation.Executables bin = installation.executables();
175177
final Result r = sh.run(bin.pluginTool + " list");
@@ -199,14 +201,15 @@ public void test021InstallPlugin() {
199201
* Checks that ESS images can install plugins from the local archive.
200202
*/
201203
public void test022InstallPluginsFromLocalArchive() {
202-
assumeTrue("Only ESS images have a local archive", distribution().packaging == Packaging.DOCKER_CLOUD_ESS);
204+
assumeTrue(
205+
"Only ESS images have a local archive",
206+
distribution().packaging == Packaging.DOCKER_CLOUD_ESS || distribution().packaging == Packaging.DOCKER_WOLFI_ESS
207+
);
203208

204209
final String plugin = "analysis-icu";
205210
final Installation.Executables bin = installation.executables();
206211

207-
listPluginArchive().forEach(System.out::println);
208212
assertThat("Expected " + plugin + " to not be installed", listPlugins(), not(hasItems(plugin)));
209-
assertThat("Expected " + plugin + " available in archive", listPluginArchive(), hasSize(16));
210213

211214
// Stuff the proxy settings with garbage, so any attempt to go out to the internet would fail
212215
sh.getEnv()
@@ -254,7 +257,10 @@ public void test023InstallPluginUsingConfigFile() {
254257
* Checks that ESS images can manage plugins from the local archive by deploying a plugins config file.
255258
*/
256259
public void test024InstallPluginFromArchiveUsingConfigFile() {
257-
assumeTrue("Only ESS image has a plugin archive", distribution().packaging == Packaging.DOCKER_CLOUD_ESS);
260+
assumeTrue(
261+
"Only ESS image has a plugin archive",
262+
distribution().packaging == Packaging.DOCKER_CLOUD_ESS || distribution().packaging == Packaging.DOCKER_WOLFI_ESS
263+
);
258264

259265
final String filename = "elasticsearch-plugins.yml";
260266
append(tempDir.resolve(filename), """
@@ -386,7 +392,7 @@ public void test040JavaUsesTheOsProvidedKeystore() {
386392
if (distribution.packaging == Packaging.DOCKER_UBI || distribution.packaging == Packaging.DOCKER_IRON_BANK) {
387393
// In these images, the `cacerts` file ought to be a symlink here
388394
assertThat(path, equalTo("/etc/pki/ca-trust/extracted/java/cacerts"));
389-
} else if (distribution.packaging == Packaging.DOCKER_WOLFI || distribution.packaging == Packaging.DOCKER_CLOUD_ESS) {
395+
} else if (distribution.packaging == Packaging.DOCKER_WOLFI || distribution.packaging == Packaging.DOCKER_WOLFI_ESS) {
390396
// In these images, the `cacerts` file ought to be a symlink here
391397
assertThat(path, equalTo("/etc/ssl/certs/java/cacerts"));
392398
} else {
@@ -1113,8 +1119,8 @@ public void test170DefaultShellIsBash() {
11131119
*/
11141120
public void test171AdditionalCliOptionsAreForwarded() throws Exception {
11151121
assumeTrue(
1116-
"Does not apply to Cloud ESS images, because they don't use the default entrypoint",
1117-
distribution().packaging != Packaging.DOCKER_CLOUD_ESS
1122+
"Does not apply to Cloud and wolfi ess images, because they don't use the default entrypoint",
1123+
distribution().packaging != Packaging.DOCKER_CLOUD_ESS && distribution().packaging != Packaging.DOCKER_WOLFI_ESS
11181124
);
11191125

11201126
runContainer(distribution(), builder().runArgs("bin/elasticsearch", "-Ecluster.name=kimchy").envVar("ELASTIC_PASSWORD", PASSWORD));
@@ -1201,7 +1207,7 @@ public void test310IronBankImageHasNoAdditionalLabels() throws Exception {
12011207
* Check that the Cloud image contains the required Beats
12021208
*/
12031209
public void test400CloudImageBundlesBeats() {
1204-
assumeTrue(distribution.packaging == Packaging.DOCKER_CLOUD_ESS);
1210+
assumeTrue(distribution.packaging == Packaging.DOCKER_CLOUD_ESS || distribution.packaging == Packaging.DOCKER_WOLFI_ESS);
12051211

12061212
final List<String> contents = listContents("/opt");
12071213
assertThat("Expected beats in /opt", contents, hasItems("filebeat", "metricbeat"));
@@ -1219,10 +1225,6 @@ private List<String> listPlugins() {
12191225
return sh.run(bin.pluginTool + " list").stdout().lines().collect(Collectors.toList());
12201226
}
12211227

1222-
private List<String> listPluginArchive() {
1223-
return sh.run("ls -lh /opt/plugins/archive").stdout().lines().collect(Collectors.toList());
1224-
}
1225-
12261228
/**
12271229
* Check that readiness listener works
12281230
*/

0 commit comments

Comments
 (0)