Skip to content

Commit 68cf596

Browse files
committed
Merge branch 'main' into data-lifecycle-rename
2 parents ae5bba5 + 3db258e commit 68cf596

File tree

562 files changed

+10078
-5104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

562 files changed

+10078
-5104
lines changed

.ci/scripts/packaging-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# opensuse 15 has a missing dep for systemd
44

55
if which zypper > /dev/null ; then
6-
sudo zypper install -y insserv-compat
6+
sudo zypper install -y insserv-compat docker-buildx
77
fi
88

99
if [ -e /etc/sysctl.d/99-gce.conf ]; then

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPluginFuncTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ echo "Running elasticsearch \$0"
179179

180180
file(distProjectFolder, 'src/config/elasticsearch.properties') << "some propes"
181181
file(distProjectFolder, 'src/config/jvm.options') << """
182-
-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,level,pid,tags:filecount=32,filesize=64m
183-
-XX:ErrorFile=logs/hs_err_pid%p.log
184-
-XX:HeapDumpPath=data
182+
-Xlog:gc*,gc+age=trace,safepoint:file=gc.log:utctime,level,pid,tags:filecount=32,filesize=64m
183+
-XX:ErrorFile=hs_err_pid%p.log
184+
# -XX:HeapDumpPath=/heap/dump/path
185185
"""
186186
file(distProjectFolder, 'build.gradle') << """
187187
import org.gradle.api.internal.artifacts.ArtifactAttributes;

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,45 @@
1414
*/
1515
public enum DockerBase {
1616
// "latest" here is intentional, since the image name specifies "9"
17-
DEFAULT("redhat/ubi9-minimal:latest", "", "microdnf"),
17+
DEFAULT("redhat/ubi9-minimal:latest", "", "microdnf", "Dockerfile.default"),
1818

1919
// The Iron Bank base image is UBI (albeit hardened), but we are required to parameterize the Docker build
20-
IRON_BANK("${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}", "-ironbank", "yum"),
20+
IRON_BANK("${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}", "-ironbank", "yum", "Dockerfile"),
2121

2222
// Chainguard based wolfi image with latest jdk
2323
// This is usually updated via renovatebot
2424
// spotless:off
25-
WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:29150cd940cc7f69407d978d5a19c86f4d9e67cf44e4d6ded787a497e8f27c9a",
25+
WOLFI(
26+
"docker.elastic.co/wolfi/chainguard-base:latest@sha256:29150cd940cc7f69407d978d5a19c86f4d9e67cf44e4d6ded787a497e8f27c9a",
2627
"-wolfi",
27-
"apk"
28+
"apk",
29+
"Dockerfile"
30+
),
31+
FIPS(
32+
"docker.elastic.co/wolfi/chainguard-base-fips:sha256-ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7@sha256:ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7",
33+
"-fips",
34+
"apk",
35+
"Dockerfile"
2836
),
29-
FIPS("docker.elastic.co/wolfi/chainguard-base-fips:sha256-ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7@sha256:ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7", "-fips", "apk"),
3037
// spotless:on
3138
// Based on WOLFI above, with more extras. We don't set a base image because
3239
// we programmatically extend from the wolfi image.
33-
CLOUD_ESS(null, "-cloud-ess", "apk");
40+
CLOUD_ESS(null, "-cloud-ess", "apk", "Dockerfile.cloud-ess"),;
3441

3542
private final String image;
3643
private final String suffix;
3744
private final String packageManager;
45+
private final String dockerfile;
3846

3947
DockerBase(String image, String suffix) {
40-
this(image, suffix, "apt-get");
48+
this(image, suffix, "apt-get", "dockerfile");
4149
}
4250

43-
DockerBase(String image, String suffix, String packageManager) {
51+
DockerBase(String image, String suffix, String packageManager, String dockerfile) {
4452
this.image = image;
4553
this.suffix = suffix;
4654
this.packageManager = packageManager;
55+
this.dockerfile = dockerfile;
4756
}
4857

4958
public String getImage() {
@@ -57,4 +66,8 @@ public String getSuffix() {
5766
public String getPackageManager() {
5867
return packageManager;
5968
}
69+
70+
public String getDockerfile() {
71+
return dockerfile;
72+
}
6073
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ private void pullBaseImage(String baseImage) {
170170
maybeConfigureDockerConfig(spec);
171171
spec.executable("docker");
172172
spec.args("pull");
173+
spec.environment("DOCKER_BUILDKIT", "1");
173174
spec.args(baseImage);
174175
});
175176

@@ -205,7 +206,7 @@ public void execute() {
205206
maybeConfigureDockerConfig(spec);
206207

207208
spec.executable("docker");
208-
209+
spec.environment("DOCKER_BUILDKIT", "1");
209210
if (isCrossPlatform) {
210211
spec.args("buildx");
211212
}

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,30 +1435,57 @@ private void tweakJvmOptions(Path configFileRoot) {
14351435
Path jvmOptions = configFileRoot.resolve("jvm.options");
14361436
try {
14371437
String content = new String(Files.readAllBytes(jvmOptions));
1438-
Map<String, String> expansions = jvmOptionExpansions();
1439-
for (String origin : expansions.keySet()) {
1440-
if (content.contains(origin) == false) {
1441-
throw new IOException("template property " + origin + " not found in template.");
1438+
Map<ReplacementKey, String> expansions = jvmOptionExpansions();
1439+
for (var entry : expansions.entrySet()) {
1440+
ReplacementKey replacement = entry.getKey();
1441+
String key = replacement.key();
1442+
if (content.contains(key) == false) {
1443+
key = replacement.fallback();
1444+
if (content.contains(key) == false) {
1445+
throw new IOException("Template property '" + replacement + "' not found in template:\n" + content);
1446+
}
14421447
}
1443-
content = content.replace(origin, expansions.get(origin));
1448+
content = content.replace(key, entry.getValue());
14441449
}
14451450
Files.write(jvmOptions, content.getBytes());
14461451
} catch (IOException ioException) {
14471452
throw new UncheckedIOException(ioException);
14481453
}
14491454
}
14501455

1451-
private Map<String, String> jvmOptionExpansions() {
1452-
Map<String, String> expansions = new HashMap<>();
1456+
private record ReplacementKey(String key, String fallback) {}
1457+
1458+
private Map<ReplacementKey, String> jvmOptionExpansions() {
1459+
Map<ReplacementKey, String> expansions = new HashMap<>();
14531460
Version version = getVersion();
1454-
String heapDumpOrigin = getVersion().onOrAfter("6.3.0") ? "-XX:HeapDumpPath=data" : "-XX:HeapDumpPath=/heap/dump/path";
1455-
expansions.put(heapDumpOrigin, "-XX:HeapDumpPath=" + confPathLogs);
1456-
if (version.onOrAfter("6.2.0")) {
1457-
expansions.put("logs/gc.log", confPathLogs.resolve("gc.log").toString());
1461+
1462+
ReplacementKey heapDumpPathSub;
1463+
if (version.before("8.19.0") && version.onOrAfter("6.3.0")) {
1464+
heapDumpPathSub = new ReplacementKey("-XX:HeapDumpPath=data", null);
1465+
} else {
1466+
// temporarily fall back to the old substitution so both old and new work during backport
1467+
heapDumpPathSub = new ReplacementKey("# -XX:HeapDumpPath=/heap/dump/path", "-XX:HeapDumpPath=data");
14581468
}
1459-
if (getVersion().getMajor() >= 7) {
1460-
expansions.put("-XX:ErrorFile=logs/hs_err_pid%p.log", "-XX:ErrorFile=" + confPathLogs.resolve("hs_err_pid%p.log"));
1469+
expansions.put(heapDumpPathSub, "-XX:HeapDumpPath=" + confPathLogs);
1470+
1471+
ReplacementKey gcLogSub;
1472+
if (version.before("8.19.0") && version.onOrAfter("6.2.0")) {
1473+
gcLogSub = new ReplacementKey("logs/gc.log", null);
1474+
} else {
1475+
// temporarily check the old substitution first so both old and new work during backport
1476+
gcLogSub = new ReplacementKey("logs/gc.log", "gc.log");
14611477
}
1478+
expansions.put(gcLogSub, confPathLogs.resolve("gc.log").toString());
1479+
1480+
ReplacementKey errorFileSub;
1481+
if (version.before("8.19.0") && version.getMajor() >= 7) {
1482+
errorFileSub = new ReplacementKey("-XX:ErrorFile=logs/hs_err_pid%p.log", null);
1483+
} else {
1484+
// temporarily check the old substitution first so both old and new work during backport
1485+
errorFileSub = new ReplacementKey("-XX:ErrorFile=logs/hs_err_pid%p.log", "-XX:ErrorFile=hs_err_pid%p.log");
1486+
}
1487+
expansions.put(errorFileSub, "-XX:ErrorFile=" + confPathLogs.resolve("hs_err_pid%p.log"));
1488+
14621489
return expansions;
14631490
}
14641491

distribution/build.gradle

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ subprojects {
531531
final String packagingPathData = "path.data: /var/lib/elasticsearch"
532532
final String pathLogs = "/var/log/elasticsearch"
533533
final String packagingPathLogs = "path.logs: ${pathLogs}"
534-
final String packagingLoggc = "${pathLogs}/gc.log"
535534

536535
String licenseText
537536
if (isTestDistro) {
@@ -576,23 +575,6 @@ subprojects {
576575
'rpm': packagingPathLogs,
577576
'def': '#path.logs: /path/to/logs'
578577
],
579-
'loggc': [
580-
'deb': packagingLoggc,
581-
'rpm': packagingLoggc,
582-
'def': 'logs/gc.log'
583-
],
584-
585-
'heap.dump.path': [
586-
'deb': "-XX:HeapDumpPath=/var/lib/elasticsearch",
587-
'rpm': "-XX:HeapDumpPath=/var/lib/elasticsearch",
588-
'def': "-XX:HeapDumpPath=data"
589-
],
590-
591-
'error.file': [
592-
'deb': "-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log",
593-
'rpm': "-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log",
594-
'def': "-XX:ErrorFile=logs/hs_err_pid%p.log"
595-
],
596578

597579
'scripts.footer': [
598580
/* Debian needs exit 0 on these scripts so we add it here and preserve

distribution/docker/build.gradle

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ ext.dockerBuildContext = { Architecture architecture, DockerBase base ->
201201
from projectDir.resolve("src/docker/config")
202202
}
203203
}
204-
from(projectDir.resolve("src/docker/Dockerfile")) {
204+
from(projectDir.resolve("src/docker/${base.dockerfile}")) {
205205
expand(varExpansions)
206206
filter SquashNewlinesFilter
207+
rename base.dockerfile, "Dockerfile"
207208
}
208209
}
209210
}
@@ -360,8 +361,7 @@ void addTransformDockerContextTask(Architecture architecture, DockerBase base) {
360361
String distributionFolderName = "elasticsearch-${VersionProperties.elasticsearch}"
361362

362363
from(tarTree("${project.buildDir}/distributions/${archiveName}.tar.gz")) {
363-
364-
if (base != DockerBase.IRON_BANK) {
364+
if (base != DockerBase.IRON_BANK && base != DockerBase.DEFAULT) {
365365
// iron bank always needs a COPY with the tarball file path
366366
eachFile { FileCopyDetails details ->
367367
if (details.name.equals("Dockerfile")) {
@@ -372,6 +372,17 @@ void addTransformDockerContextTask(Architecture architecture, DockerBase base) {
372372
}
373373
}
374374
}
375+
if (base == DockerBase.DEFAULT) {
376+
// iron bank always needs a COPY with the tarball file path
377+
eachFile { FileCopyDetails details ->
378+
if (details.name.equals("Dockerfile")) {
379+
filter { String contents ->
380+
return contents.replaceAll('^RUN *.*artifacts-no-kpi.*$', "COPY $distributionFolderName .")
381+
.replaceAll('^RUN tar -zxf /tmp/elasticsearch.tar.gz --strip-components=1 &&', "RUN ")
382+
}
383+
}
384+
}
385+
}
375386
}
376387
into "${project.buildDir}/docker-context/${archiveName}"
377388

distribution/docker/src/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ LABEL name="Elasticsearch" \\
287287
description="You know, for search."
288288
<% } %>
289289

290-
RUN mkdir /licenses && cp LICENSE.txt /licenses/LICENSE
290+
RUN mkdir /licenses && ln LICENSE.txt /licenses/LICENSE
291291
<% if (docker_base == 'iron_bank') { %>
292292
COPY LICENSE /licenses/LICENSE.addendum
293293
<% } %>

0 commit comments

Comments
 (0)