Skip to content

Commit 7e8ddb3

Browse files
Merge branch 'main' into esql_grid_aggs
2 parents eaf9417 + 4c0c9b6 commit 7e8ddb3

File tree

42 files changed

+840
-150
lines changed

Some content is hidden

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

42 files changed

+840
-150
lines changed

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

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

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

2222
// Chainguard based wolfi image with latest jdk
23-
// This is usually updated via renovatebot
24-
// spotless:off
2523
WOLFI(
26-
"docker.elastic.co/wolfi/chainguard-base:latest@sha256:29150cd940cc7f69407d978d5a19c86f4d9e67cf44e4d6ded787a497e8f27c9a",
24+
null,
2725
"-wolfi",
2826
"apk",
29-
"Dockerfile"
27+
"dockerfiles/wolfi/Dockerfile"
3028
),
31-
// spotless:on
3229
// Based on WOLFI above, with more extras. We don't set a base image because
3330
// we programmatically extend from the wolfi image.
3431
CLOUD_ESS(null, "-cloud-ess", "apk", "Dockerfile.ess"),
3532

3633
CLOUD_ESS_FIPS(
37-
"docker.elastic.co/wolfi/chainguard-base-fips:sha256-ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7@sha256:ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7",
34+
null,
3835
"-cloud-ess-fips",
3936
"apk",
40-
"Dockerfile.ess-fips"
37+
"dockerfiles/cloud_ess_fips/Dockerfile"
4138
);
4239

4340
private final String image;

distribution/docker/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,10 @@ void addBuildDockerImageTask(Architecture architecture, DockerBase base) {
482482

483483
baseImages = [baseImage]
484484
buildArgs = buildArgsMap
485-
} else {
485+
} else if(base.image != null) {
486486
baseImages = [base.image]
487+
} else {
488+
baseImages = []
487489
}
488490

489491
Provider<DockerSupportService> serviceProvider = GradleUtils.getBuildService(

distribution/docker/src/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<% if (docker_base == 'iron_bank') { %>
2323
ARG BASE_REGISTRY=registry1.dso.mil
2424
ARG BASE_IMAGE=ironbank/redhat/ubi/ubi9
25-
ARG BASE_TAG=9.5
25+
ARG BASE_TAG=9.6
2626
<% } %>
2727
2828
################################################################################

distribution/docker/src/docker/Dockerfile.ess-fips renamed to distribution/docker/src/docker/dockerfiles/cloud_ess_fips/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# Extract Elasticsearch artifact
2525
################################################################################
2626
27-
FROM ${base_image} AS builder
27+
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7 AS builder
2828
2929
# Install required packages to extract the Elasticsearch distribution
3030
RUN <%= retry.loop(package_manager, "export DEBIAN_FRONTEND=noninteractive && ${package_manager} update && ${package_manager} update && ${package_manager} add --no-cache curl") %>
@@ -103,7 +103,7 @@ WORKDIR /usr/share/elasticsearch/config
103103
# Add entrypoint
104104
################################################################################
105105

106-
FROM ${base_image}
106+
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:ebfc3f1d7dba992231747a2e05ad1b859843e81b5e676ad342859d7cf9e425a7
107107

108108
RUN <%= retry.loop(package_manager,
109109
"export DEBIAN_FRONTEND=noninteractive && \n" +
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
################################################################################
2+
# This Dockerfile was generated from the template at distribution/src/docker/Dockerfile
3+
#
4+
# Beginning of multi stage Dockerfile
5+
################################################################################
6+
7+
<% /*
8+
This file is passed through Groovy's SimpleTemplateEngine, so dollars and backslashes
9+
have to be escaped in order for them to appear in the final Dockerfile. You
10+
can also comment out blocks, like this one. See:
11+
12+
https://docs.groovy-lang.org/latest/html/api/groovy/text/SimpleTemplateEngine.html
13+
14+
We use control-flow tags in this file to conditionally render the content. The
15+
layout/presentation here has been adjusted so that it looks reasonable when rendered,
16+
at the slight expense of how it looks here.
17+
18+
Note that this file is also filtered to squash together newlines, so we can
19+
add as many newlines here as necessary to improve legibility.
20+
*/ %>
21+
22+
################################################################################
23+
# Build stage 1 `builder`:
24+
# Extract Elasticsearch artifact
25+
################################################################################
26+
27+
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:29150cd940cc7f69407d978d5a19c86f4d9e67cf44e4d6ded787a497e8f27c9a AS builder
28+
29+
# Install required packages to extract the Elasticsearch distribution
30+
RUN <%= retry.loop(package_manager, "export DEBIAN_FRONTEND=noninteractive && ${package_manager} update && ${package_manager} update && ${package_manager} add --no-cache curl") %>
31+
32+
# `tini` is a tiny but valid init for containers. This is used to cleanly
33+
# control how ES and any child processes are shut down.
34+
# For wolfi we pick it from the blessed wolfi package registry.
35+
#
36+
# The tini GitHub page gives instructions for verifying the binary using
37+
# gpg, but the keyservers are slow to return the key and this can fail the
38+
# build. Instead, we check the binary against the published checksum.
39+
40+
RUN mkdir /usr/share/elasticsearch
41+
WORKDIR /usr/share/elasticsearch
42+
43+
44+
# Fetch the appropriate Elasticsearch distribution for this architecture.
45+
# Keep this command on one line - it is replaced with a `COPY` during local builds.
46+
# It uses the `arch` shell command to fetch the correct distro for the build machine,
47+
RUN curl --retry 10 -S -L --output /tmp/elasticsearch.tar.gz https://artifacts-no-kpi.elastic.co/downloads/elasticsearch/elasticsearch-${version}-linux-\${arch}.tar.gz
48+
49+
RUN tar -zxf /tmp/elasticsearch.tar.gz --strip-components=1
50+
51+
# The distribution includes a `config` directory, no need to create it
52+
COPY ${config_dir}/elasticsearch.yml config/
53+
COPY ${config_dir}/log4j2.properties config/log4j2.docker.properties
54+
55+
# 1. Configure the distribution for Docker
56+
# 2. Create required directory
57+
# 3. Move the distribution's default logging config aside
58+
# 4. Move the generated docker logging config so that it is the default
59+
# 5. Reset permissions on all directories
60+
# 6. Reset permissions on all files
61+
# 7. Make CLI tools executable
62+
# 8. Make some directories writable. `bin` must be writable because
63+
# plugins can install their own CLI utilities.
64+
# 9. Make some files writable
65+
RUN sed -i -e 's/ES_DISTRIBUTION_TYPE=tar/ES_DISTRIBUTION_TYPE=docker/' bin/elasticsearch-env && \\
66+
mkdir data && \\
67+
mv config/log4j2.properties config/log4j2.file.properties && \\
68+
mv config/log4j2.docker.properties config/log4j2.properties && \\
69+
find . -type d -exec chmod 0555 {} + && \\
70+
find . -type f -exec chmod 0444 {} + && \\
71+
chmod 0555 bin/* jdk/bin/* jdk/lib/jspawnhelper modules/x-pack-ml/platform/linux-*/bin/* && \\
72+
chmod 0775 bin config config/jvm.options.d data logs plugins && \\
73+
find config -type f -exec chmod 0664 {} +
74+
75+
################################################################################
76+
# Build stage 2 (the actual Elasticsearch image):
77+
#
78+
# Copy elasticsearch from stage 1
79+
# Add entrypoint
80+
################################################################################
81+
82+
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:29150cd940cc7f69407d978d5a19c86f4d9e67cf44e4d6ded787a497e8f27c9a
83+
84+
RUN <%= retry.loop(package_manager,
85+
"export DEBIAN_FRONTEND=noninteractive && \n" +
86+
" ${package_manager} update && \n" +
87+
" ${package_manager} upgrade && \n" +
88+
" ${package_manager} add --no-cache \n" +
89+
" bash java-cacerts curl libstdc++ libsystemd netcat-openbsd p11-kit p11-kit-trust posix-libc-utils shadow tini unzip zip zstd && \n" +
90+
" rm -rf /var/cache/apk/* "
91+
) %>
92+
93+
# Set Bash as the default shell for future commands
94+
SHELL ["/bin/bash", "-c"]
95+
96+
# Optionally set Bash as the default shell in the container at runtime
97+
CMD ["/bin/bash"]
98+
99+
RUN groupadd -g 1000 elasticsearch && \
100+
adduser -G elasticsearch -u 1000 elasticsearch -D --home /usr/share/elasticsearch elasticsearch && \
101+
adduser elasticsearch root && \
102+
chown -R 0:0 /usr/share/elasticsearch
103+
104+
ENV ELASTIC_CONTAINER=true
105+
106+
WORKDIR /usr/share/elasticsearch
107+
108+
COPY --from=builder --chown=0:0 /usr/share/elasticsearch /usr/share/elasticsearch
109+
110+
ENV PATH=/usr/share/elasticsearch/bin:\$PATH
111+
ENV SHELL=/bin/bash
112+
COPY ${bin_dir}/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
113+
114+
# 1. Sync the user and group permissions of /etc/passwd
115+
# 2. Set correct permissions of the entrypoint
116+
# 3. Ensure that there are no files with setuid or setgid, in order to mitigate "stackclash" attacks.
117+
# We've already run this in previous layers so it ought to be a no-op.
118+
# 4. Replace OpenJDK's built-in CA certificate keystore with the one from the OS
119+
# vendor. The latter is superior in several ways.
120+
# REF: https://github.com/elastic/elasticsearch-docker/issues/171
121+
# 5. Tighten up permissions on the ES home dir (the permissions of the contents are handled earlier)
122+
# 6. You can't install plugins that include configuration when running as `elasticsearch` and the `config`
123+
# dir is owned by `root`, because the installed tries to manipulate the permissions on the plugin's
124+
# config directory.
125+
RUN chmod g=u /etc/passwd && \\
126+
chmod 0555 /usr/local/bin/docker-entrypoint.sh && \\
127+
find / -xdev -perm -4000 -exec chmod ug-s {} + && \\
128+
chmod 0775 /usr/share/elasticsearch && \\
129+
chown elasticsearch bin config config/jvm.options.d data logs plugins
130+
131+
RUN ln -sf /etc/ssl/certs/java/cacerts /usr/share/elasticsearch/jdk/lib/security/cacerts
132+
133+
EXPOSE 9200 9300
134+
135+
136+
LABEL org.label-schema.build-date="${build_date}" \\
137+
org.label-schema.license="${license}" \\
138+
org.label-schema.name="Elasticsearch" \\
139+
org.label-schema.schema-version="1.0" \\
140+
org.label-schema.url="https://www.elastic.co/products/elasticsearch" \\
141+
org.label-schema.usage="https://www.elastic.co/guide/en/elasticsearch/reference/index.html" \\
142+
org.label-schema.vcs-ref="${git_revision}" \\
143+
org.label-schema.vcs-url="https://github.com/elastic/elasticsearch" \\
144+
org.label-schema.vendor="Elastic" \\
145+
org.label-schema.version="${version}" \\
146+
org.opencontainers.image.created="${build_date}" \\
147+
org.opencontainers.image.documentation="https://www.elastic.co/guide/en/elasticsearch/reference/index.html" \\
148+
org.opencontainers.image.licenses="${license}" \\
149+
org.opencontainers.image.revision="${git_revision}" \\
150+
org.opencontainers.image.source="https://github.com/elastic/elasticsearch" \\
151+
org.opencontainers.image.title="Elasticsearch" \\
152+
org.opencontainers.image.url="https://www.elastic.co/products/elasticsearch" \\
153+
org.opencontainers.image.vendor="Elastic" \\
154+
org.opencontainers.image.version="${version}"
155+
156+
LABEL name="Elasticsearch" \\
157+
maintainer="[email protected]" \\
158+
vendor="Elastic" \\
159+
version="${version}" \\
160+
release="1" \\
161+
summary="Elasticsearch" \\
162+
description="You know, for search."
163+
164+
RUN mkdir /licenses && ln LICENSE.txt /licenses/LICENSE
165+
166+
# Our actual entrypoint is `tini`, a minimal but functional init program. It
167+
# calls the entrypoint we provide, while correctly forwarding signals.
168+
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
169+
# Dummy overridable parameter parsed by entrypoint
170+
CMD ["eswrapper"]
171+
172+
USER 1000:0
173+
174+
################################################################################
175+
# End of multi-stage Dockerfile
176+
################################################################################

docs/changelog/128043.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pr: 128043
2+
summary: Make S3 custom query parameter optional
3+
area: Snapshot/Restore
4+
type: breaking
5+
issues: []
6+
breaking:
7+
title: Make S3 custom query parameter optional
8+
area: Cluster and node setting
9+
details: >-
10+
Earlier versions of Elasticsearch would record the purpose of each S3 API
11+
call using the `?x-purpose=` custom query parameter. This isn't believed to
12+
be necessary outside of the ECH/ECE/ECK/... managed services, and it adds
13+
rather a lot to the request logs, so with this change we make the feature
14+
optional and disabled by default.
15+
impact: >-
16+
If you wish to reinstate the old behaviour on a S3 repository, set
17+
`s3.client.${CLIENT_NAME}.add_purpose_custom_query_parameter` to `true`
18+
for the relevant client.
19+
notable: false

docs/changelog/128063.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128063
2+
summary: More efficient sort in `tryRelocateShard`
3+
area: Allocation
4+
type: enhancement
5+
issues: []

docs/changelog/128111.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128111
2+
summary: Fix union types in CCS
3+
area: ES|QL
4+
type: bug
5+
issues: []

modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepositoryPlugin.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
package org.elasticsearch.repositories.azure;
1111

1212
import org.apache.lucene.util.SetOnce;
13+
import org.elasticsearch.cluster.node.DiscoveryNode;
1314
import org.elasticsearch.cluster.service.ClusterService;
1415
import org.elasticsearch.common.settings.Setting;
1516
import org.elasticsearch.common.settings.Settings;
1617
import org.elasticsearch.common.util.BigArrays;
18+
import org.elasticsearch.common.util.concurrent.EsExecutors;
1719
import org.elasticsearch.core.TimeValue;
1820
import org.elasticsearch.env.Environment;
1921
import org.elasticsearch.indices.recovery.RecoverySettings;
@@ -24,6 +26,7 @@
2426
import org.elasticsearch.repositories.Repository;
2527
import org.elasticsearch.threadpool.ExecutorBuilder;
2628
import org.elasticsearch.threadpool.ScalingExecutorBuilder;
29+
import org.elasticsearch.threadpool.ThreadPool;
2730
import org.elasticsearch.xcontent.NamedXContentRegistry;
2831

2932
import java.util.Arrays;
@@ -78,6 +81,7 @@ public Map<String, Repository.Factory> getRepositories(
7881
public Collection<?> createComponents(PluginServices services) {
7982
AzureClientProvider azureClientProvider = AzureClientProvider.create(services.threadPool(), settings);
8083
azureStoreService.set(createAzureStorageService(settings, azureClientProvider));
84+
assert assertRepositoryAzureMaxThreads(settings, services.threadPool());
8185
return List.of(azureClientProvider);
8286
}
8387

@@ -107,12 +111,18 @@ public List<Setting<?>> getSettings() {
107111
}
108112

109113
@Override
110-
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settingsToUse) {
111-
return List.of(executorBuilder(), nettyEventLoopExecutorBuilder(settingsToUse));
114+
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
115+
return List.of(executorBuilder(settings), nettyEventLoopExecutorBuilder(settings));
112116
}
113117

114-
public static ExecutorBuilder<?> executorBuilder() {
115-
return new ScalingExecutorBuilder(REPOSITORY_THREAD_POOL_NAME, 0, 5, TimeValue.timeValueSeconds(30L), false);
118+
public static ExecutorBuilder<?> executorBuilder(Settings settings) {
119+
int repositoryAzureMax = 5;
120+
if (DiscoveryNode.isStateless(settings)) {
121+
// REPOSITORY_THREAD_POOL_NAME is shared between snapshot and translogs/segments upload logic in serverless. In order to avoid
122+
// snapshots to slow down other uploads due to rate limiting, we allow more threads in serverless.
123+
repositoryAzureMax += ThreadPool.getMaxSnapshotThreadPoolSize(EsExecutors.allocatedProcessors(settings));
124+
}
125+
return new ScalingExecutorBuilder(REPOSITORY_THREAD_POOL_NAME, 0, repositoryAzureMax, TimeValue.timeValueSeconds(30L), false);
116126
}
117127

118128
public static ExecutorBuilder<?> nettyEventLoopExecutorBuilder(Settings settings) {
@@ -128,4 +138,19 @@ public void reload(Settings settingsToLoad) {
128138
assert storageService != null;
129139
storageService.refreshSettings(clientsSettings);
130140
}
141+
142+
private static boolean assertRepositoryAzureMaxThreads(Settings settings, ThreadPool threadPool) {
143+
if (DiscoveryNode.isStateless(settings)) {
144+
var repositoryAzureMax = threadPool.info(REPOSITORY_THREAD_POOL_NAME).getMax();
145+
var snapshotMax = ThreadPool.getMaxSnapshotThreadPoolSize(EsExecutors.allocatedProcessors(settings));
146+
assert snapshotMax < repositoryAzureMax
147+
: "thread pool ["
148+
+ REPOSITORY_THREAD_POOL_NAME
149+
+ "] should be large enough to allow all "
150+
+ snapshotMax
151+
+ " snapshot threads to run at once, but got: "
152+
+ repositoryAzureMax;
153+
}
154+
return true;
155+
}
131156
}

0 commit comments

Comments
 (0)