Skip to content

Commit 997e64d

Browse files
authored
Merge branch '9.0' into build/jdk24_rc_default
2 parents e06e287 + fcf33cc commit 997e64d

File tree

30 files changed

+280
-302
lines changed

30 files changed

+280
-302
lines changed

.buildkite/pipelines/periodic-fwc.template.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ steps:
77
image: family/elasticsearch-ubuntu-2004
88
machineType: n1-standard-32
99
buildDirectory: /dev/shm/bk
10-
preemptible: true
1110
matrix:
1211
setup:
1312
FWC_VERSION: $FWC_LIST
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# This file is auto-generated. See .buildkite/pipelines/periodic-fwc.template.yml
22
steps:
3-
- label: "{{matrix.FWC_VERSION}} / fwc"
4-
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
3+
- label: $FWC_VERSION / fwc
4+
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
55
timeout_in_minutes: 300
66
agents:
77
provider: gcp
88
image: family/elasticsearch-ubuntu-2004
99
machineType: n1-standard-32
1010
buildDirectory: /dev/shm/bk
11-
preemptible: true
1211
matrix:
1312
setup:
1413
FWC_VERSION: []
1514
env:
16-
FWC_VERSION: "{{matrix.FWC_VERSION}}"
15+
FWC_VERSION: $FWC_VERSION

build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ develocity {
133133
}
134134
} else {
135135
tag 'LOCAL'
136+
if (providers.systemProperty('idea.active').present) {
137+
tag 'IDEA'
138+
}
136139
}
137140
}
138141
}

build-tools-internal/src/main/groovy/elasticsearch.ide.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
174174

175175
// this path is produced by the extractLibs task above
176176
String testLibraryPath = TestUtil.getTestLibraryPath("${elasticsearchProject.left()}/libs/native/libraries/build/platform")
177-
177+
def enableIdeaCC = providers.gradleProperty("org.elasticsearch.idea-configuration-cache").getOrElse("true").toBoolean()
178178
idea {
179179
project {
180180
vcs = 'Git'
@@ -204,6 +204,11 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
204204
}
205205
}
206206
runConfigurations {
207+
defaults(org.jetbrains.gradle.ext.Gradle) {
208+
scriptParameters = enableIdeaCC ? [
209+
'--configuration-cache'
210+
].join(' ') : ''
211+
}
207212
defaults(JUnit) {
208213
vmParameters = [
209214
'-ea',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private SourceSet addSourceSet(
139139
compileOptions.getRelease().set(javaVersion);
140140
});
141141
if (isMainSourceSet) {
142-
project.getTasks().create(sourceSet.getJavadocTaskName(), Javadoc.class, javadocTask -> {
142+
project.getTasks().register(sourceSet.getJavadocTaskName(), Javadoc.class, javadocTask -> {
143143
javadocTask.getJavadocTool().set(javaToolchains.javadocToolFor(spec -> {
144144
spec.getLanguageVersion().set(JavaLanguageVersion.of(javaVersion));
145145
}));

distribution/tools/java-version-checker/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apply plugin: 'elasticsearch.build'
22

3-
compileJava {
3+
tasks.named("compileJava").configure {
44
options.release = 8
55
}
66

docs/changelog/123610.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123610
2+
summary: Disable concurrency when `top_hits` sorts on anything but `_score`
3+
area: "Aggregations"
4+
type: bug
5+
issues: []

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ org.gradle.dependency.verification.console=verbose
1919

2020
# allow user to specify toolchain via the RUNTIME_JAVA_HOME environment variable
2121
org.gradle.java.installations.fromEnv=RUNTIME_JAVA_HOME
22+
23+
# if configuration cache enabled then enable parallel support too
24+
org.gradle.configuration-cache.parallel=true

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/entitlements/FilesEntitlement.java

Lines changed: 33 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,8 @@ static FileData ofRelativePath(Path relativePath, BaseDir baseDir, Mode mode) {
9191
return new RelativePathFileData(relativePath, baseDir, mode, null, false);
9292
}
9393

94-
static FileData ofPathSetting(String setting, Mode mode, boolean ignoreUrl) {
95-
return new PathSettingFileData(setting, mode, ignoreUrl, null, false);
96-
}
97-
98-
static FileData ofRelativePathSetting(String setting, BaseDir baseDir, Mode mode, boolean ignoreUrl) {
99-
return new RelativePathSettingFileData(setting, baseDir, mode, ignoreUrl, null, false);
94+
static FileData ofPathSetting(String setting, BaseDir baseDir, Mode mode, boolean ignoreUrl) {
95+
return new PathSettingFileData(setting, baseDir, mode, ignoreUrl, null, false);
10096
}
10197

10298
/**
@@ -225,71 +221,39 @@ public FileData withPlatform(Platform platform) {
225221
}
226222
}
227223

228-
private record PathSettingFileData(String setting, Mode mode, boolean ignoreUrl, Platform platform, boolean exclusive)
224+
private record PathSettingFileData(String setting, BaseDir baseDir, Mode mode, boolean ignoreUrl, Platform platform, boolean exclusive)
229225
implements
230-
FileData {
226+
RelativeFileData {
231227

232228
@Override
233229
public PathSettingFileData withExclusive(boolean exclusive) {
234-
return new PathSettingFileData(setting, mode, ignoreUrl, platform, exclusive);
235-
}
236-
237-
@Override
238-
public Stream<Path> resolvePaths(PathLookup pathLookup) {
239-
return resolvePathSettings(pathLookup, setting, ignoreUrl);
240-
}
241-
242-
@Override
243-
public FileData withPlatform(Platform platform) {
244-
if (platform == platform()) {
245-
return this;
246-
}
247-
return new PathSettingFileData(setting, mode, ignoreUrl, platform, exclusive);
248-
}
249-
}
250-
251-
private record RelativePathSettingFileData(
252-
String setting,
253-
BaseDir baseDir,
254-
Mode mode,
255-
boolean ignoreUrl,
256-
Platform platform,
257-
boolean exclusive
258-
) implements FileData, RelativeFileData {
259-
260-
@Override
261-
public RelativePathSettingFileData withExclusive(boolean exclusive) {
262-
return new RelativePathSettingFileData(setting, baseDir, mode, ignoreUrl, platform, exclusive);
230+
return new PathSettingFileData(setting, baseDir, mode, ignoreUrl, platform, exclusive);
263231
}
264232

265233
@Override
266234
public Stream<Path> resolveRelativePaths(PathLookup pathLookup) {
267-
return resolvePathSettings(pathLookup, setting, ignoreUrl);
235+
Stream<String> result;
236+
if (setting.contains("*")) {
237+
result = pathLookup.settingGlobResolver().apply(setting);
238+
} else {
239+
String path = pathLookup.settingResolver().apply(setting);
240+
result = path == null ? Stream.of() : Stream.of(path);
241+
}
242+
if (ignoreUrl) {
243+
result = result.filter(s -> s.toLowerCase(Locale.ROOT).startsWith("https://") == false);
244+
}
245+
return result.map(pathLookup.configDir()::resolve);
268246
}
269247

270248
@Override
271249
public FileData withPlatform(Platform platform) {
272250
if (platform == platform()) {
273251
return this;
274252
}
275-
return new RelativePathSettingFileData(setting, baseDir, mode, ignoreUrl, platform, exclusive);
253+
return new PathSettingFileData(setting, baseDir, mode, ignoreUrl, platform, exclusive);
276254
}
277255
}
278256

279-
private static Stream<Path> resolvePathSettings(PathLookup pathLookup, String setting, boolean ignoreUrl) {
280-
Stream<String> result;
281-
if (setting.contains("*")) {
282-
result = pathLookup.settingGlobResolver().apply(setting);
283-
} else {
284-
String path = pathLookup.settingResolver().apply(setting);
285-
result = path == null ? Stream.of() : Stream.of(path);
286-
}
287-
if (ignoreUrl) {
288-
result = result.filter(s -> s.toLowerCase(Locale.ROOT).startsWith("https://") == false);
289-
}
290-
return result.map(Path::of);
291-
}
292-
293257
private static Mode parseMode(String mode) {
294258
if (mode.equals("read")) {
295259
return Mode.READ;
@@ -371,7 +335,7 @@ public static FilesEntitlement build(List<Object> paths) {
371335
String relativePathAsString = checkString.apply(file, "relative_path");
372336
String relativeTo = checkString.apply(file, "relative_to");
373337
String pathSetting = checkString.apply(file, "path_setting");
374-
String relativePathSetting = checkString.apply(file, "relative_path_setting");
338+
String settingBaseDirAsString = checkString.apply(file, "basedir_if_relative");
375339
String modeAsString = checkString.apply(file, "mode");
376340
String platformAsString = checkString.apply(file, "platform");
377341
Boolean ignoreUrlAsStringBoolean = checkBoolean.apply(file, "ignore_url");
@@ -382,11 +346,10 @@ public static FilesEntitlement build(List<Object> paths) {
382346
if (file.isEmpty() == false) {
383347
throw new PolicyValidationException("unknown key(s) [" + file + "] in a listed file for files entitlement");
384348
}
385-
int foundKeys = (pathAsString != null ? 1 : 0) + (relativePathAsString != null ? 1 : 0) + (pathSetting != null ? 1 : 0)
386-
+ (relativePathSetting != null ? 1 : 0);
349+
int foundKeys = (pathAsString != null ? 1 : 0) + (relativePathAsString != null ? 1 : 0) + (pathSetting != null ? 1 : 0);
387350
if (foundKeys != 1) {
388351
throw new PolicyValidationException(
389-
"a files entitlement entry must contain one of " + "[path, relative_path, path_setting, relative_path_setting]"
352+
"a files entitlement entry must contain one of " + "[path, relative_path, path_setting]"
390353
);
391354
}
392355

@@ -399,20 +362,23 @@ public static FilesEntitlement build(List<Object> paths) {
399362
platform = parsePlatform(platformAsString);
400363
}
401364

402-
BaseDir baseDir = null;
403-
if (relativeTo != null) {
404-
baseDir = parseBaseDir(relativeTo);
365+
if (relativeTo != null && relativePathAsString == null) {
366+
throw new PolicyValidationException("'relative_to' may only be used with 'relative_path'");
405367
}
406368

407-
if (ignoreUrlAsStringBoolean != null && (relativePathAsString != null || pathAsString != null)) {
408-
throw new PolicyValidationException("'ignore_url' may only be used with `path_setting` or `relative_path_setting`");
369+
if (ignoreUrlAsStringBoolean != null && pathSetting == null) {
370+
throw new PolicyValidationException("'ignore_url' may only be used with 'path_setting'");
371+
}
372+
if (settingBaseDirAsString != null && pathSetting == null) {
373+
throw new PolicyValidationException("'basedir_if_relative' may only be used with 'path_setting'");
409374
}
410375

411376
final FileData fileData;
412377
if (relativePathAsString != null) {
413-
if (baseDir == null) {
378+
if (relativeTo == null) {
414379
throw new PolicyValidationException("files entitlement with a 'relative_path' must specify 'relative_to'");
415380
}
381+
BaseDir baseDir = parseBaseDir(relativeTo);
416382
Path relativePath = Path.of(relativePathAsString);
417383
if (FileData.isAbsolutePath(relativePathAsString)) {
418384
throw new PolicyValidationException("'relative_path' [" + relativePathAsString + "] must be relative");
@@ -425,12 +391,11 @@ public static FilesEntitlement build(List<Object> paths) {
425391
}
426392
fileData = FileData.ofPath(path, mode);
427393
} else if (pathSetting != null) {
428-
fileData = FileData.ofPathSetting(pathSetting, mode, ignoreUrlAsString);
429-
} else if (relativePathSetting != null) {
430-
if (baseDir == null) {
431-
throw new PolicyValidationException("files entitlement with a 'relative_path_setting' must specify 'relative_to'");
394+
if (settingBaseDirAsString == null) {
395+
throw new PolicyValidationException("files entitlement with a 'path_setting' must specify 'basedir_if_relative'");
432396
}
433-
fileData = FileData.ofRelativePathSetting(relativePathSetting, baseDir, mode, ignoreUrlAsString);
397+
BaseDir baseDir = parseBaseDir(settingBaseDirAsString);
398+
fileData = FileData.ofPathSetting(pathSetting, baseDir, mode, ignoreUrlAsString);
434399
} else {
435400
throw new AssertionError("File entry validation error");
436401
}

libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyParserFailureTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void testEntitlementMutuallyExclusiveParameters() {
7575
assertEquals(
7676
"[2:5] policy parsing error for [test-failure-policy.yaml] in scope [entitlement-module-name] "
7777
+ "for entitlement type [files]: a files entitlement entry must contain one of "
78-
+ "[path, relative_path, path_setting, relative_path_setting]",
78+
+ "[path, relative_path, path_setting]",
7979
ppe.getMessage()
8080
);
8181
}
@@ -89,7 +89,7 @@ public void testEntitlementAtLeastOneParameter() {
8989
assertEquals(
9090
"[2:5] policy parsing error for [test-failure-policy.yaml] in scope [entitlement-module-name] "
9191
+ "for entitlement type [files]: a files entitlement entry must contain one of "
92-
+ "[path, relative_path, path_setting, relative_path_setting]",
92+
+ "[path, relative_path, path_setting]",
9393
ppe.getMessage()
9494
);
9595
}

0 commit comments

Comments
 (0)