Skip to content

Commit b64fe63

Browse files
authored
Merge branch 'main' into entitlements/nio-path
2 parents 0100715 + fb75dc4 commit b64fe63

File tree

7 files changed

+47
-27
lines changed

7 files changed

+47
-27
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
9393
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:smoke-test-security-with-mustache");
9494
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:xpack-prefix-rest-compat");
9595
map.put(LegacyRestTestBasePlugin.class, ":modules:ingest-geoip:qa:file-based-update");
96-
map.put(LegacyRestTestBasePlugin.class, ":plugins:discovery-ec2:qa:amazon-ec2");
9796
map.put(LegacyRestTestBasePlugin.class, ":plugins:discovery-gce:qa:gce");
9897
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-basic-license");
9998
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-full-license");

libs/entitlement/src/main/java/org/elasticsearch/entitlement/bootstrap/EntitlementBootstrap.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public record BootstrapArgs(
3838
Function<Class<?>, String> pluginResolver,
3939
Path[] dataDirs,
4040
Path configDir,
41-
Path tempDir
41+
Path tempDir,
42+
Path logsDir
4243
) {
4344
public BootstrapArgs {
4445
requireNonNull(pluginPolicies);
@@ -64,22 +65,24 @@ public static BootstrapArgs bootstrapArgs() {
6465
*
6566
* @param pluginPolicies a map holding policies for plugins (and modules), by plugin (or module) name.
6667
* @param pluginResolver a functor to map a Java Class to the plugin it belongs to (the plugin name).
67-
* @param dataDirs data directories for Elasticsearch
68-
* @param configDir the config directory for Elasticsearch
69-
* @param tempDir the temp directory for Elasticsearch
68+
* @param dataDirs data directories for Elasticsearch
69+
* @param configDir the config directory for Elasticsearch
70+
* @param tempDir the temp directory for Elasticsearch
71+
* @param logsDir the log directory for Elasticsearch
7072
*/
7173
public static void bootstrap(
7274
Map<String, Policy> pluginPolicies,
7375
Function<Class<?>, String> pluginResolver,
7476
Path[] dataDirs,
7577
Path configDir,
76-
Path tempDir
78+
Path tempDir,
79+
Path logsDir
7780
) {
7881
logger.debug("Loading entitlement agent");
7982
if (EntitlementBootstrap.bootstrapArgs != null) {
8083
throw new IllegalStateException("plugin data is already set");
8184
}
82-
EntitlementBootstrap.bootstrapArgs = new BootstrapArgs(pluginPolicies, pluginResolver, dataDirs, configDir, tempDir);
85+
EntitlementBootstrap.bootstrapArgs = new BootstrapArgs(pluginPolicies, pluginResolver, dataDirs, configDir, tempDir, logsDir);
8386
exportInitializationToAgent();
8487
loadAgent(findAgentJar());
8588
selfTest();

libs/entitlement/src/main/java/org/elasticsearch/entitlement/initialization/EntitlementInitialization.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ private static PolicyManager createPolicyManager() {
134134
EntitlementBootstrap.BootstrapArgs bootstrapArgs = EntitlementBootstrap.bootstrapArgs();
135135
Map<String, Policy> pluginPolicies = bootstrapArgs.pluginPolicies();
136136
var pathLookup = new PathLookup(bootstrapArgs.configDir(), bootstrapArgs.dataDirs(), bootstrapArgs.tempDir());
137+
Path logsDir = EntitlementBootstrap.bootstrapArgs().logsDir();
137138

138139
// TODO(ES-10031): Decide what goes in the elasticsearch default policy and extend it
139140
var serverPolicy = new Policy(
@@ -155,7 +156,25 @@ private static PolicyManager createPolicyManager() {
155156
Stream.concat(
156157
Stream.of(
157158
FileData.ofPath(bootstrapArgs.tempDir(), READ_WRITE),
158-
FileData.ofPath(bootstrapArgs.configDir(), READ)
159+
FileData.ofPath(bootstrapArgs.configDir(), READ),
160+
FileData.ofPath(bootstrapArgs.logsDir(), READ_WRITE),
161+
// OS release on Linux
162+
FileData.ofPath(Path.of("/etc/os-release"), READ),
163+
FileData.ofPath(Path.of("/etc/system-release"), READ),
164+
FileData.ofPath(Path.of("/usr/lib/os-release"), READ),
165+
// read max virtual memory areas
166+
FileData.ofPath(Path.of("/proc/sys/vm/max_map_count"), READ),
167+
FileData.ofPath(Path.of("/proc/meminfo"), READ),
168+
// load averages on Linux
169+
FileData.ofPath(Path.of("/proc/loadavg"), READ),
170+
// control group stats on Linux. cgroup v2 stats are in an unpredicable
171+
// location under `/sys/fs/cgroup`, so unfortunately we have to allow
172+
// read access to the entire directory hierarchy.
173+
FileData.ofPath(Path.of("/proc/self/cgroup"), READ),
174+
FileData.ofPath(Path.of("/sys/fs/cgroup/"), READ),
175+
// // io stats on Linux
176+
FileData.ofPath(Path.of("/proc/self/mountinfo"), READ),
177+
FileData.ofPath(Path.of("/proc/diskstats"), READ)
159178
),
160179
Arrays.stream(bootstrapArgs.dataDirs()).map(d -> FileData.ofPath(d, READ))
161180
).toList()

muted-tests.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,6 @@ tests:
338338
- class: org.elasticsearch.entitlement.runtime.policy.PolicyParserFailureTests
339339
method: testEntitlementAbsolutePathWhenRelative
340340
issue: https://github.com/elastic/elasticsearch/issues/122666
341-
- class: org.elasticsearch.entitlement.qa.EntitlementsAllowedNonModularIT
342-
issue: https://github.com/elastic/elasticsearch/issues/122568
343-
- class: org.elasticsearch.entitlement.qa.EntitlementsDeniedIT
344-
issue: https://github.com/elastic/elasticsearch/issues/122566
345-
- class: org.elasticsearch.entitlement.qa.EntitlementsDeniedNonModularIT
346-
issue: https://github.com/elastic/elasticsearch/issues/122569
347-
- class: org.elasticsearch.entitlement.qa.EntitlementsAllowedIT
348-
issue: https://github.com/elastic/elasticsearch/issues/122680
349341
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
350342
method: test {yaml=reference/snapshot-restore/apis/get-snapshot-api/line_408}
351343
issue: https://github.com/elastic/elasticsearch/issues/122681

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ static TransportVersion def(int id) {
174174
public static final TransportVersion TIMEOUT_GET_PARAM_FOR_RESOLVE_CLUSTER = def(8_838_0_00);
175175
public static final TransportVersion INFERENCE_REQUEST_ADAPTIVE_RATE_LIMITING = def(8_839_0_00);
176176
public static final TransportVersion ML_INFERENCE_IBM_WATSONX_RERANK_ADDED = def(8_840_0_00);
177-
public static final TransportVersion COHERE_BIT_EMBEDDING_TYPE_SUPPORT_ADDED_BACKPORT_8_X = def(8_840_0_01);
178-
public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_X = def(8_840_0_02);
179-
public static final TransportVersion ESQL_RETRY_ON_SHARD_LEVEL_FAILURE_BACKPORT_8_19 = def(8_840_0_03);
180-
public static final TransportVersion ESQL_SUPPORT_PARTIAL_RESULTS_BACKPORT_8_19 = def(8_840_0_04);
181-
public static final TransportVersion ELASTICSEARCH_9_0 = def(9_000_0_00);
177+
public static final TransportVersion INITIAL_ELASTICSEARCH_8_19 = def(8_841_0_00);
178+
public static final TransportVersion COHERE_BIT_EMBEDDING_TYPE_SUPPORT_ADDED_BACKPORT_8_X = def(8_841_0_01);
179+
public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_X = def(8_841_0_02);
180+
public static final TransportVersion ESQL_RETRY_ON_SHARD_LEVEL_FAILURE_BACKPORT_8_19 = def(8_841_0_03);
181+
public static final TransportVersion ESQL_SUPPORT_PARTIAL_RESULTS_BACKPORT_8_19 = def(8_841_0_04);
182+
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0 = def(9_000_0_00);
182183
public static final TransportVersion REMOVE_SNAPSHOT_FAILURES_90 = def(9_000_0_01);
183184
public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED_90 = def(9_000_0_02);
184185
public static final TransportVersion REMOVE_DESIRED_NODE_VERSION_90 = def(9_000_0_03);
@@ -195,6 +196,7 @@ static TransportVersion def(int id) {
195196
public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR = def(9_009_0_00);
196197
public static final TransportVersion SLM_UNHEALTHY_IF_NO_SNAPSHOT_WITHIN = def(9_010_0_00);
197198
public static final TransportVersion ESQL_SUPPORT_PARTIAL_RESULTS = def(9_011_0_00);
199+
public static final TransportVersion REMOVE_REPOSITORY_CONFLICT_MESSAGE = def(9_012_0_00);
198200

199201
/*
200202
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ private static void initPhase2(Bootstrap bootstrap) throws IOException {
247247
pluginsResolver::resolveClassToPluginName,
248248
nodeEnv.dataDirs(),
249249
nodeEnv.configDir(),
250-
nodeEnv.tmpDir()
250+
nodeEnv.tmpDir(),
251+
nodeEnv.logsDir()
251252
);
252253
} else {
253254
assert RuntimeVersionFeature.isSecurityManagerAvailable();

server/src/main/java/org/elasticsearch/repositories/RepositoryConflictException.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
package org.elasticsearch.repositories;
1111

12+
import org.elasticsearch.TransportVersions;
1213
import org.elasticsearch.common.io.stream.StreamInput;
1314
import org.elasticsearch.common.io.stream.StreamOutput;
14-
import org.elasticsearch.core.UpdateForV9;
1515
import org.elasticsearch.rest.RestStatus;
1616

1717
import java.io.IOException;
@@ -29,16 +29,20 @@ public RestStatus status() {
2929
return RestStatus.CONFLICT;
3030
}
3131

32-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // drop unneeded string from wire format
3332
public RepositoryConflictException(StreamInput in) throws IOException {
3433
super(in);
35-
in.readString();
34+
if (in.getTransportVersion().before(TransportVersions.REMOVE_REPOSITORY_CONFLICT_MESSAGE)) {
35+
// Deprecated `backwardCompatibleMessage` field
36+
in.readString();
37+
}
3638
}
3739

3840
@Override
39-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // drop unneeded string from wire format
4041
protected void writeTo(StreamOutput out, Writer<Throwable> nestedExceptionsWriter) throws IOException {
4142
super.writeTo(out, nestedExceptionsWriter);
42-
out.writeString("");
43+
if (out.getTransportVersion().before(TransportVersions.REMOVE_REPOSITORY_CONFLICT_MESSAGE)) {
44+
// Deprecated `backwardCompatibleMessage` field
45+
out.writeString("");
46+
}
4347
}
4448
}

0 commit comments

Comments
 (0)