Skip to content

Commit fe116d8

Browse files
authored
Merge branch '9.1' into backport/9.1/pr-131132
2 parents 59ff6af + c237cd2 commit fe116d8

File tree

117 files changed

+1305
-403
lines changed

Some content is hidden

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

117 files changed

+1305
-403
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/QueryPlanningBenchmark.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ public class QueryPlanningBenchmark {
7070
private EsqlParser defaultParser;
7171
private Analyzer manyFieldsAnalyzer;
7272
private LogicalPlanOptimizer defaultOptimizer;
73+
private Configuration config;
7374

7475
@Setup
7576
public void setup() {
76-
77-
var config = new Configuration(
77+
this.config = new Configuration(
7878
DateUtils.UTC,
7979
Locale.US,
8080
null,
@@ -116,7 +116,7 @@ public void setup() {
116116
}
117117

118118
private LogicalPlan plan(EsqlParser parser, Analyzer analyzer, LogicalPlanOptimizer optimizer, String query) {
119-
var parsed = parser.createStatement(query, new QueryParams(), telemetry);
119+
var parsed = parser.createStatement(query, new QueryParams(), telemetry, config);
120120
var analyzed = analyzer.analyze(parsed);
121121
var optimized = optimizer.optimize(analyzed);
122122
return optimized;

docs/changelog/130849.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 130849
2+
summary: Fix behavior for `_index` LIKE for ESQL
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 129511

docs/changelog/131015.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 131015
2+
summary: Move streams status actions to cluster:monitor group
3+
area: Data streams
4+
type: bug
5+
issues: []

docs/changelog/131081.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 131081
2+
summary: Fix knn search error when dimensions are not set
3+
area: Vector Search
4+
type: bug
5+
issues:
6+
- 129550

docs/changelog/131113.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 131113
2+
summary: Including `max_tokens` through the Service API for Anthropic
3+
area: Machine Learning
4+
type: bug
5+
issues: []

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static PolicyManager createPolicyManager(
161161
PathLookup pathLookup,
162162
Policy serverPolicyPatch,
163163
Function<Class<?>, PolicyManager.PolicyScope> scopeResolver,
164-
Map<String, Collection<Path>> pluginSourcePaths
164+
Map<String, Collection<Path>> pluginSourcePathsResolver
165165
) {
166166
FilesEntitlementsValidation.validate(pluginPolicies, pathLookup);
167167

@@ -170,7 +170,7 @@ private static PolicyManager createPolicyManager(
170170
HardcodedEntitlements.agentEntitlements(),
171171
pluginPolicies,
172172
scopeResolver,
173-
pluginSourcePaths,
173+
pluginSourcePathsResolver::get,
174174
pathLookup
175175
);
176176
}

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PathLookup.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99

1010
package org.elasticsearch.entitlement.runtime.policy;
1111

12+
import org.elasticsearch.core.PathUtils;
13+
1214
import java.nio.file.Path;
1315
import java.util.stream.Stream;
1416

1517
/**
1618
* Resolves paths for known directories checked by entitlements.
1719
*/
1820
public interface PathLookup {
21+
Class<?> DEFAULT_FILESYSTEM_CLASS = PathUtils.getDefaultFileSystem().getClass();
22+
1923
enum BaseDir {
2024
USER_HOME,
2125
CONFIG,
@@ -37,4 +41,6 @@ enum BaseDir {
3741
* paths of the given {@code baseDir}.
3842
*/
3943
Stream<Path> resolveSettingPaths(BaseDir baseDir, String settingName);
44+
45+
boolean isPathOnDefaultFilesystem(Path path);
4046
}

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PathLookupImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,9 @@ public Stream<Path> resolveSettingPaths(BaseDir baseDir, String settingName) {
7575
.toList();
7676
return getBaseDirPaths(baseDir).flatMap(path -> relativePaths.stream().map(path::resolve));
7777
}
78+
79+
@Override
80+
public boolean isPathOnDefaultFilesystem(Path path) {
81+
return path.getFileSystem().getClass() == DEFAULT_FILESYSTEM_CLASS;
82+
}
7883
}

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyCheckerImpl.java

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

1010
package org.elasticsearch.entitlement.runtime.policy;
1111

12-
import org.elasticsearch.core.PathUtils;
1312
import org.elasticsearch.core.Strings;
1413
import org.elasticsearch.core.SuppressForbidden;
1514
import org.elasticsearch.entitlement.instrumentation.InstrumentationService;
@@ -58,7 +57,7 @@
5857
*/
5958
@SuppressForbidden(reason = "Explicitly checking APIs that are forbidden")
6059
public class PolicyCheckerImpl implements PolicyChecker {
61-
static final Class<?> DEFAULT_FILESYSTEM_CLASS = PathUtils.getDefaultFileSystem().getClass();
60+
6261
protected final Set<Package> suppressFailureLogPackages;
6362
/**
6463
* Frames originating from this module are ignored in the permission logic.
@@ -81,15 +80,14 @@ public PolicyCheckerImpl(
8180
this.pathLookup = pathLookup;
8281
}
8382

84-
private static boolean isPathOnDefaultFilesystem(Path path) {
85-
var pathFileSystemClass = path.getFileSystem().getClass();
86-
if (path.getFileSystem().getClass() != DEFAULT_FILESYSTEM_CLASS) {
83+
private boolean isPathOnDefaultFilesystem(Path path) {
84+
if (pathLookup.isPathOnDefaultFilesystem(path) == false) {
8785
PolicyManager.generalLogger.trace(
8886
() -> Strings.format(
8987
"File entitlement trivially allowed: path [%s] is for a different FileSystem class [%s], default is [%s]",
9088
path.toString(),
91-
pathFileSystemClass.getName(),
92-
DEFAULT_FILESYSTEM_CLASS.getName()
89+
path.getFileSystem().getClass().getName(),
90+
PathLookup.DEFAULT_FILESYSTEM_CLASS.getName()
9391
)
9492
);
9593
return false;
@@ -217,7 +215,7 @@ public void checkFileRead(Class<?> callerClass, Path path) {
217215

218216
@Override
219217
public void checkFileRead(Class<?> callerClass, Path path, boolean followLinks) throws NoSuchFileException {
220-
if (PolicyCheckerImpl.isPathOnDefaultFilesystem(path) == false) {
218+
if (isPathOnDefaultFilesystem(path) == false) {
221219
return;
222220
}
223221
var requestingClass = requestingClass(callerClass);
@@ -265,7 +263,7 @@ public void checkFileWrite(Class<?> callerClass, File file) {
265263

266264
@Override
267265
public void checkFileWrite(Class<?> callerClass, Path path) {
268-
if (PolicyCheckerImpl.isPathOnDefaultFilesystem(path) == false) {
266+
if (isPathOnDefaultFilesystem(path) == false) {
269267
return;
270268
}
271269
var requestingClass = requestingClass(callerClass);

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/PolicyManager.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
import java.nio.file.Paths;
2323
import java.util.ArrayList;
2424
import java.util.Collection;
25+
import java.util.Collections;
2526
import java.util.HashSet;
2627
import java.util.List;
2728
import java.util.Map;
29+
import java.util.Objects;
2830
import java.util.Set;
2931
import java.util.concurrent.ConcurrentHashMap;
3032
import java.util.function.Function;
@@ -217,7 +219,7 @@ private static Set<Module> findSystemLayerModules() {
217219
.filter(m -> SYSTEM_LAYER_MODULES.contains(m) == false)
218220
.collect(Collectors.toUnmodifiableSet());
219221

220-
private final Map<String, Collection<Path>> pluginSourcePaths;
222+
private final Function<String, Collection<Path>> pluginSourcePathsResolver;
221223

222224
/**
223225
* Paths that are only allowed for a single module. Used to generate
@@ -231,7 +233,7 @@ public PolicyManager(
231233
List<Entitlement> apmAgentEntitlements,
232234
Map<String, Policy> pluginPolicies,
233235
Function<Class<?>, PolicyScope> scopeResolver,
234-
Map<String, Collection<Path>> pluginSourcePaths,
236+
Function<String, Collection<Path>> pluginSourcePathsResolver,
235237
PathLookup pathLookup
236238
) {
237239
this.serverEntitlements = buildScopeEntitlementsMap(requireNonNull(serverPolicy));
@@ -240,7 +242,7 @@ public PolicyManager(
240242
.stream()
241243
.collect(toUnmodifiableMap(Map.Entry::getKey, e -> buildScopeEntitlementsMap(e.getValue())));
242244
this.scopeResolver = scopeResolver;
243-
this.pluginSourcePaths = pluginSourcePaths;
245+
this.pluginSourcePathsResolver = pluginSourcePathsResolver;
244246
this.pathLookup = requireNonNull(pathLookup);
245247

246248
List<ExclusiveFileEntitlement> exclusiveFileEntitlements = new ArrayList<>();
@@ -334,7 +336,10 @@ protected final ModuleEntitlements computeEntitlements(Class<?> requestingClass)
334336
default -> {
335337
assert policyScope.kind() == PLUGIN;
336338
var pluginEntitlements = pluginsEntitlements.get(componentName);
337-
Collection<Path> componentPaths = pluginSourcePaths.getOrDefault(componentName, List.of());
339+
Collection<Path> componentPaths = Objects.requireNonNullElse(
340+
pluginSourcePathsResolver.apply(componentName),
341+
Collections.emptyList()
342+
);
338343
if (pluginEntitlements == null) {
339344
return defaultEntitlements(componentName, componentPaths, moduleName);
340345
} else {

0 commit comments

Comments
 (0)