Skip to content

Commit f1f5ee0

Browse files
authored
Replace cloud-ess docker image with wolfi-ess (#114413)
* Replace cloud-ess docker image with wolfi-ess We just replaced the existing implementation of cloud-ess with what was wolfi-ess which is a wolfi based ess image. The cloud image itself will be removed in a future commit it was not used anywhere * Switch to test cloud docker image instead of default docker in packaging pr tests. This adds way more coverage than the default docker image which is also barely touched
1 parent 2155f1b commit f1f5ee0

File tree

16 files changed

+62
-136
lines changed

16 files changed

+62
-136
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
8+
command: ./.ci/scripts/packaging-test.sh destructiveDistroTest.docker-cloud-ess
99
timeout_in_minutes: 300
1010
matrix:
1111
setup:

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ public enum DockerBase {
2424
// Base image with extras for Cloud
2525
CLOUD("ubuntu:20.04", "-cloud", "apt-get"),
2626

27-
// Based on CLOUD above, with more extras. We don't set a base image because
28-
// we programmatically extend from the Cloud image.
29-
CLOUD_ESS(null, "-cloud-ess", "apt-get"),
30-
3127
// Chainguard based wolfi image with latest jdk
3228
// This is usually updated via renovatebot
3329
// spotless:off
@@ -36,10 +32,9 @@ public enum DockerBase {
3632
"apk"
3733
),
3834
// spotless:on
39-
4035
// Based on WOLFI above, with more extras. We don't set a base image because
41-
// we programmatically extend from the Wolfi image.
42-
WOLFI_ESS(null, "-wolfi-ess", "apk");
36+
// we programmatically extend from the wolfi image.
37+
CLOUD_ESS(null, "-cloud-ess", "apk");
4338

4439
private final String image;
4540
private final String suffix;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ private static String distributionProjectName(ElasticsearchDistribution distribu
181181
if (distribution.getType() == InternalElasticsearchDistributionTypes.DOCKER_WOLFI) {
182182
return projectName + "wolfi-docker" + archString + "-export";
183183
}
184-
if (distribution.getType() == InternalElasticsearchDistributionTypes.DOCKER_WOLFI_ESS) {
185-
return projectName + "wolfi-ess-docker" + archString + "-export";
186-
}
187184
return projectName + distribution.getType().getName();
188185
}
189186

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

Lines changed: 0 additions & 27 deletions
This file was deleted.

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public class InternalElasticsearchDistributionTypes {
2222
public static ElasticsearchDistributionType DOCKER_CLOUD = new DockerCloudElasticsearchDistributionType();
2323
public static ElasticsearchDistributionType DOCKER_CLOUD_ESS = new DockerCloudEssElasticsearchDistributionType();
2424
public static ElasticsearchDistributionType DOCKER_WOLFI = new DockerWolfiElasticsearchDistributionType();
25-
public static ElasticsearchDistributionType DOCKER_WOLFI_ESS = new DockerWolfiEssElasticsearchDistributionType();
2625

2726
public static List<ElasticsearchDistributionType> ALL_INTERNAL = List.of(
2827
DEB,
@@ -32,7 +31,6 @@ public class InternalElasticsearchDistributionTypes {
3231
DOCKER_IRONBANK,
3332
DOCKER_CLOUD,
3433
DOCKER_CLOUD_ESS,
35-
DOCKER_WOLFI,
36-
DOCKER_WOLFI_ESS
34+
DOCKER_WOLFI
3735
);
3836
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_IRONBANK;
5555
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_UBI;
5656
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_WOLFI;
57-
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.DOCKER_WOLFI_ESS;
5857
import static org.elasticsearch.gradle.internal.distribution.InternalElasticsearchDistributionTypes.RPM;
5958

6059
/**
@@ -153,7 +152,6 @@ private static Map<ElasticsearchDistributionType, TaskProvider<?>> lifecycleTask
153152
lifecyleTasks.put(DOCKER_CLOUD, project.getTasks().register(taskPrefix + ".docker-cloud"));
154153
lifecyleTasks.put(DOCKER_CLOUD_ESS, project.getTasks().register(taskPrefix + ".docker-cloud-ess"));
155154
lifecyleTasks.put(DOCKER_WOLFI, project.getTasks().register(taskPrefix + ".docker-wolfi"));
156-
lifecyleTasks.put(DOCKER_WOLFI_ESS, project.getTasks().register(taskPrefix + ".docker-wolfi-ess"));
157155
lifecyleTasks.put(ARCHIVE, project.getTasks().register(taskPrefix + ".archives"));
158156
lifecyleTasks.put(DEB, project.getTasks().register(taskPrefix + ".packages"));
159157
lifecyleTasks.put(RPM, lifecyleTasks.get(DEB));

distribution/docker/README.md

Lines changed: 1 addition & 8 deletions
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-
* Wolfi ESS - this directly extends the Wolfi image, and adds all ES plugins
10+
* Cloud 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,20 +23,13 @@ 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-
2726
* Cloud - this is mostly the same as the default image, with some notable differences:
2827
* `filebeat` and `metricbeat` are included
2928
* `wget` is included
3029
* The `ENTRYPOINT` is just `/bin/tini`, and the `CMD` is
3130
`/app/elasticsearch.sh`. In normal use this file would be bind-mounted
3231
in, but the image ships a stub version of this file so that the image
3332
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-
4033
The long-term goal is for both Cloud images to be retired in favour of the
4134
default image.
4235

distribution/docker/build.gradle

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

383383
String namespace = 'elasticsearch'
384-
if (base == DockerBase.CLOUD || base == DockerBase.CLOUD_ESS || base == DockerBase.WOLFI_ESS) {
384+
if (base == DockerBase.CLOUD || base == DockerBase.CLOUD_ESS) {
385385
namespace += '-ci'
386386
}
387387

@@ -446,7 +446,8 @@ void addBuildDockerImageTask(Architecture architecture, DockerBase base) {
446446
}
447447
}
448448

449-
void addBuildEssDockerImageTask(Architecture architecture, DockerBase dockerBase) {
449+
void addBuildEssDockerImageTask(Architecture architecture) {
450+
DockerBase dockerBase = DockerBase.CLOUD_ESS
450451
String arch = architecture == Architecture.AARCH64 ? '-aarch64' : ''
451452
String contextDir = "${project.buildDir}/docker-context/elasticsearch${dockerBase.suffix}-${VersionProperties.elasticsearch}-docker-build-context${arch}"
452453

@@ -460,22 +461,20 @@ void addBuildEssDockerImageTask(Architecture architecture, DockerBase dockerBase
460461
from configurations.allPlugins
461462
}
462463

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

470-
if (includeBeats) {
471-
from configurations.getByName("filebeat_${architecture.classifier}")
472-
from configurations.getByName("metricbeat_${architecture.classifier}")
473-
}
474-
// For some reason, the artifact name can differ depending on what repository we used.
475-
rename ~/((?:file|metric)beat)-.*\.tar\.gz$/, "\$1-${VersionProperties.elasticsearch}.tar.gz"
470+
if (includeBeats) {
471+
from configurations.getByName("filebeat_${architecture.classifier}")
472+
from configurations.getByName("metricbeat_${architecture.classifier}")
476473
}
474+
// For some reason, the artifact name can differ depending on what repository we used.
475+
rename ~/((?:file|metric)beat)-.*\.tar\.gz$/, "\$1-${VersionProperties.elasticsearch}.tar.gz"
477476

478-
String baseSuffix = dockerBase == DockerBase.CLOUD_ESS ? DockerBase.CLOUD.suffix : DockerBase.WOLFI.suffix
477+
String baseSuffix = DockerBase.WOLFI.suffix
479478
from(projectDir.resolve("src/docker/Dockerfile.ess")) {
480479
expand(
481480
[
@@ -493,7 +492,7 @@ void addBuildEssDockerImageTask(Architecture architecture, DockerBase dockerBase
493492
final TaskProvider<DockerBuildTask> buildDockerImageTask =
494493
tasks.register(taskName("build", architecture, dockerBase, "DockerImage"), DockerBuildTask) {
495494

496-
DockerBase base = dockerBase == DockerBase.CLOUD_ESS ? DockerBase.CLOUD : DockerBase.WOLFI
495+
DockerBase base = DockerBase.WOLFI
497496

498497
TaskProvider<DockerBuildTask> buildBaseTask = tasks.named(taskName("build", architecture, base, "DockerImage"))
499498
inputs.files(buildBaseTask)
@@ -519,16 +518,15 @@ void addBuildEssDockerImageTask(Architecture architecture, DockerBase dockerBase
519518

520519
for (final Architecture architecture : Architecture.values()) {
521520
for (final DockerBase base : DockerBase.values()) {
522-
if (base == DockerBase.CLOUD_ESS || base == DockerBase.WOLFI_ESS) {
521+
if (base == DockerBase.CLOUD_ESS) {
523522
continue
524523
}
525524
addBuildDockerContextTask(architecture, base)
526525
addTransformDockerContextTask(architecture, base)
527526
addBuildDockerImageTask(architecture, base)
528527
}
529528

530-
addBuildEssDockerImageTask(architecture, DockerBase.CLOUD_ESS)
531-
addBuildEssDockerImageTask(architecture, DockerBase.WOLFI_ESS)
529+
addBuildEssDockerImageTask(architecture)
532530
}
533531

534532
def exportDockerImages = tasks.register("exportDockerImages")
@@ -564,8 +562,7 @@ subprojects { Project subProject ->
564562
(base == DockerBase.CLOUD ? 'cloud.tar' :
565563
(base == DockerBase.CLOUD_ESS ? 'cloud-ess.tar' :
566564
(base == DockerBase.WOLFI ? 'wolfi.tar' :
567-
(base == DockerBase.WOLFI_ESS ? 'wolfi-ess.tar' :
568-
'docker.tar')))))
565+
'docker.tar'))))
569566
final String artifactName = "elasticsearch${arch}${base.suffix}_test"
570567

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

distribution/docker/src/docker/Dockerfile.ess

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

33
USER root
44

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-
<% } %>
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
2523

2624
COPY plugins/*.zip /opt/plugins/archive/
2725

2826
RUN chown 1000:1000 /opt/plugins/archive/*
2927
RUN chmod 0444 /opt/plugins/archive/*
3028

3129
FROM ${base_image}
32-
<% if (docker_base == "wolfi_ess") { %>
3330
USER root
3431

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

4542
COPY --from=builder --chown=0:0 /opt /opt
4643
USER 1000:0
47-
<% } else { %>
48-
COPY --from=builder /opt/plugins /opt/plugins
49-
<% } %>
50-
5144
ENV ES_PLUGIN_ARCHIVE_DIR /opt/plugins/archive

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

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
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>
102103
* <li>Images for Cloud</li>
103104
* </ul>
104105
*/
@@ -170,9 +171,7 @@ public void test012SecurityCanBeDisabled() throws Exception {
170171
public void test020PluginsListWithNoPlugins() {
171172
assumeTrue(
172173
"Only applies to non-Cloud images",
173-
distribution.packaging != Packaging.DOCKER_CLOUD
174-
&& distribution().packaging != Packaging.DOCKER_CLOUD_ESS
175-
&& distribution().packaging != Packaging.DOCKER_WOLFI_ESS
174+
distribution.packaging != Packaging.DOCKER_CLOUD && distribution().packaging != Packaging.DOCKER_CLOUD_ESS
176175
);
177176

178177
final Installation.Executables bin = installation.executables();
@@ -203,15 +202,14 @@ public void test021InstallPlugin() {
203202
* Checks that ESS images can install plugins from the local archive.
204203
*/
205204
public void test022InstallPluginsFromLocalArchive() {
206-
assumeTrue(
207-
"Only ESS images have a local archive",
208-
distribution().packaging == Packaging.DOCKER_CLOUD_ESS || distribution().packaging == Packaging.DOCKER_WOLFI_ESS
209-
);
205+
assumeTrue("Only ESS images have a local archive", distribution().packaging == Packaging.DOCKER_CLOUD_ESS);
210206

211207
final String plugin = "analysis-icu";
212208
final Installation.Executables bin = installation.executables();
213209

210+
listPluginArchive().forEach(System.out::println);
214211
assertThat("Expected " + plugin + " to not be installed", listPlugins(), not(hasItems(plugin)));
212+
assertThat("Expected " + plugin + " available in archive", listPluginArchive(), hasSize(16));
215213

216214
// Stuff the proxy settings with garbage, so any attempt to go out to the internet would fail
217215
sh.getEnv()
@@ -259,10 +257,7 @@ public void test023InstallPluginUsingConfigFile() {
259257
* Checks that ESS images can manage plugins from the local archive by deploying a plugins config file.
260258
*/
261259
public void test024InstallPluginFromArchiveUsingConfigFile() {
262-
assumeTrue(
263-
"Only ESS image has a plugin archive",
264-
distribution().packaging == Packaging.DOCKER_CLOUD_ESS || distribution().packaging == Packaging.DOCKER_WOLFI_ESS
265-
);
260+
assumeTrue("Only ESS image has a plugin archive", distribution().packaging == Packaging.DOCKER_CLOUD_ESS);
266261

267262
final String filename = "elasticsearch-plugins.yml";
268263
append(tempDir.resolve(filename), """
@@ -394,7 +389,7 @@ public void test040JavaUsesTheOsProvidedKeystore() {
394389
if (distribution.packaging == Packaging.DOCKER_UBI || distribution.packaging == Packaging.DOCKER_IRON_BANK) {
395390
// In these images, the `cacerts` file ought to be a symlink here
396391
assertThat(path, equalTo("/etc/pki/ca-trust/extracted/java/cacerts"));
397-
} else if (distribution.packaging == Packaging.DOCKER_WOLFI || distribution.packaging == Packaging.DOCKER_WOLFI_ESS) {
392+
} else if (distribution.packaging == Packaging.DOCKER_WOLFI || distribution.packaging == Packaging.DOCKER_CLOUD_ESS) {
398393
// In these images, the `cacerts` file ought to be a symlink here
399394
assertThat(path, equalTo("/etc/ssl/certs/java/cacerts"));
400395
} else {
@@ -1121,10 +1116,8 @@ public void test170DefaultShellIsBash() {
11211116
*/
11221117
public void test171AdditionalCliOptionsAreForwarded() throws Exception {
11231118
assumeTrue(
1124-
"Does not apply to Cloud and wolfi ess images, because they don't use the default entrypoint",
1125-
distribution.packaging != Packaging.DOCKER_CLOUD
1126-
&& distribution().packaging != Packaging.DOCKER_CLOUD_ESS
1127-
&& distribution().packaging != Packaging.DOCKER_WOLFI_ESS
1119+
"Does not apply to Cloud and Cloud ESS images, because they don't use the default entrypoint",
1120+
distribution.packaging != Packaging.DOCKER_CLOUD && distribution().packaging != Packaging.DOCKER_CLOUD_ESS
11281121
);
11291122

11301123
runContainer(distribution(), builder().runArgs("bin/elasticsearch", "-Ecluster.name=kimchy").envVar("ELASTIC_PASSWORD", PASSWORD));
@@ -1211,11 +1204,7 @@ public void test310IronBankImageHasNoAdditionalLabels() throws Exception {
12111204
* Check that the Cloud image contains the required Beats
12121205
*/
12131206
public void test400CloudImageBundlesBeats() {
1214-
assumeTrue(
1215-
distribution.packaging == Packaging.DOCKER_CLOUD
1216-
|| distribution.packaging == Packaging.DOCKER_CLOUD_ESS
1217-
|| distribution.packaging == Packaging.DOCKER_WOLFI_ESS
1218-
);
1207+
assumeTrue(distribution.packaging == Packaging.DOCKER_CLOUD || distribution.packaging == Packaging.DOCKER_CLOUD_ESS);
12191208

12201209
final List<String> contents = listContents("/opt");
12211210
assertThat("Expected beats in /opt", contents, hasItems("filebeat", "metricbeat"));
@@ -1233,6 +1222,10 @@ private List<String> listPlugins() {
12331222
return sh.run(bin.pluginTool + " list").stdout().lines().collect(Collectors.toList());
12341223
}
12351224

1225+
private List<String> listPluginArchive() {
1226+
return sh.run("ls -lh /opt/plugins/archive").stdout().lines().collect(Collectors.toList());
1227+
}
1228+
12361229
/**
12371230
* Check that readiness listener works
12381231
*/

0 commit comments

Comments
 (0)