Skip to content

Commit d78724a

Browse files
authored
Merge branch 'main' into online_shard_split
2 parents 7f2da9b + 14faf38 commit d78724a

File tree

273 files changed

+4375
-539
lines changed

Some content is hidden

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

273 files changed

+4375
-539
lines changed

.github/workflows/assemble.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
name: Gradle Assemble
2-
on: [pull_request]
2+
on:
3+
pull_request:
4+
# Skip this check unless files that could plausibly impact a
5+
# distribution have changed.
6+
paths:
7+
- 'distribution/**'
8+
- 'buildSrc/**'
9+
- '**/*.gradle'
10+
- 'gradle/**'
11+
- '.github/workflows/assemble.yml'
312

413
jobs:
514
assemble:
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Nightly Gradle Precommit
2+
on:
3+
schedule:
4+
- cron: '0 6 * * *' # Daily at 6:00 AM UTC
5+
6+
jobs:
7+
# The precommit tasks are run on every PR as a part of `check`. This
8+
# nightly workflow exists to ensure OpenSearch remains buildable on
9+
# all supported platforms, but runs on a scheduled basis to reduce the
10+
# overhead on all pull requests.
11+
nightly-precommit:
12+
if: github.repository == 'opensearch-project/OpenSearch'
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
java: [ 21, 25 ]
17+
os: [ubuntu-latest, windows-latest, macos-15, macos-15-intel, ubuntu-24.04-arm]
18+
include:
19+
- java: 21
20+
os: 'windows-2025'
21+
experimental: true
22+
steps:
23+
- uses: actions/checkout@v6
24+
- name: Set up JDK ${{ matrix.java }}
25+
uses: actions/setup-java@v5
26+
with:
27+
java-version: ${{ matrix.java }}
28+
distribution: temurin
29+
cache: gradle
30+
- name: Run Gradle (precommit)
31+
continue-on-error: ${{ matrix.experimental }}
32+
shell: bash
33+
run: |
34+
./gradlew javadoc precommit --parallel
35+
36+
open-issue-on-failure:
37+
if: failure() && github.event_name == 'schedule'
38+
needs: precommit
39+
runs-on: ubuntu-latest
40+
permissions:
41+
issues: write
42+
steps:
43+
- uses: actions/github-script@v7
44+
with:
45+
script: |
46+
const title = 'Nightly precommit failed';
47+
const { data: existing_issues } = await github.rest.issues.listForRepo({
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
state: 'open',
51+
labels: 'autocut,CI',
52+
per_page: 100
53+
});
54+
const existing = existing_issues.find(i => i.title === title);
55+
if (existing) {
56+
await github.rest.issues.createComment({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
issue_number: existing.number,
60+
body: `Another nightly failure.\n\n[View run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`
61+
});
62+
console.log('Commented on existing issue.');
63+
return;
64+
}
65+
const body = `The nightly precommit workflow failed.\n\n[View run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`;
66+
await github.rest.issues.create({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
title,
70+
body,
71+
labels: ['autocut', 'CI']
72+
});

.github/workflows/precommit.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ testfixtures_shared/
6868

6969
# build files generated
7070
doc-tools/missing-doclet/bin/
71+
/sandbox/plugins/engine-datafusion/target/

CHANGELOG.md

Lines changed: 3 additions & 1 deletion

buildSrc/src/integTest/groovy/org/opensearch/gradle/fixtures/AbstractGradleFuncTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ abstract class AbstractGradleFuncTest extends Specification {
4545

4646
File settingsFile
4747
File buildFile
48+
File testKitDir
4849

4950
def setup() {
5051
settingsFile = testProjectDir.newFile('settings.gradle')
5152
settingsFile << "rootProject.name = 'hello-world'\n"
5253
buildFile = testProjectDir.newFile('build.gradle')
54+
testKitDir = testProjectDir.newFolder('.gradle-test-kit')
5355
}
5456

5557
GradleRunner gradleRunner(String... arguments) {
@@ -62,6 +64,7 @@ abstract class AbstractGradleFuncTest extends Specification {
6264
.withProjectDir(projectDir)
6365
.withArguments(arguments)
6466
.withPluginClasspath()
67+
.withTestKitDir(testKitDir)
6568
.forwardOutput()
6669
}
6770

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ json_smart = "2.5.2"
3737
# when updating the JNA version, also update the version in buildSrc/build.gradle
3838
jna = "5.16.0"
3939

40-
netty = "4.2.10.Final"
40+
netty = "4.2.12.Final"
4141
joda = "2.12.7"
4242
roaringbitmap = "1.3.0"
4343

libs/common/src/main/java/org/opensearch/common/CheckedTriFunction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
package org.opensearch.common;
1010

11+
import org.opensearch.common.annotation.PublicApi;
12+
1113
/**
1214
* A {@link TriFunction}-like interface which allows throwing checked exceptions.
1315
*
1416
* @opensearch.internal
1517
*/
18+
@PublicApi(since = "2.9.0")
1619
@FunctionalInterface
1720
public interface CheckedTriFunction<S, T, U, R, E extends Exception> {
1821
R apply(S s, T t, U u) throws E;

libs/core/src/main/java/org/opensearch/Version.java

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.opensearch.common.SuppressForbidden;
3636
import org.opensearch.common.annotation.PublicApi;
3737
import org.opensearch.core.Assertions;
38+
import org.opensearch.core.common.Strings;
3839
import org.opensearch.core.xcontent.ToXContentFragment;
3940
import org.opensearch.core.xcontent.XContentBuilder;
4041

@@ -56,6 +57,37 @@
5657
*/
5758
@PublicApi(since = "1.0.0")
5859
public class Version implements Comparable<Version>, ToXContentFragment {
60+
/**
61+
* Exception thrown when an unsupported version ID is encountered.
62+
*/
63+
public static class UnsupportedVersionException extends RuntimeException {
64+
private final String versionString;
65+
66+
private UnsupportedVersionException(int versionId) {
67+
super(String.format(Locale.ROOT, "Unsupported version [%s]", legacyFriendlyIdToString(versionId)));
68+
this.versionString = legacyFriendlyIdToString(versionId);
69+
}
70+
71+
public String getVersionString() {
72+
return versionString;
73+
}
74+
}
75+
76+
private static String legacyFriendlyIdToString(int versionId) {
77+
String prefix;
78+
if ((versionId & MASK) != 0) {
79+
versionId = versionId ^ MASK;
80+
prefix = "";
81+
} else {
82+
prefix = "ES ";
83+
}
84+
int major = (versionId / MAJOR_SHIFT) % VERSION_SHIFT;
85+
int minor = (versionId / MINOR_SHIFT) % VERSION_SHIFT;
86+
int revision = (versionId / REVISION_SHIFT) % VERSION_SHIFT;
87+
88+
return prefix + major + "." + minor + "." + revision;
89+
}
90+
5991
private static final int VERSION_SHIFT = 100; // Two digits per version part
6092
private static final int REVISION_SHIFT = VERSION_SHIFT;
6193
private static final int MINOR_SHIFT = VERSION_SHIFT * VERSION_SHIFT;
@@ -212,7 +244,7 @@ public class Version implements Comparable<Version>, ToXContentFragment {
212244

213245
public static Version fromId(int id) {
214246
if (id != 0 && (id & MASK) == 0) {
215-
throw new IllegalArgumentException("Version id " + id + " must contain OpenSearch mask");
247+
throw new UnsupportedVersionException(id);
216248
}
217249
final Version known = idToVersion.get(id);
218250
if (known != null) {
@@ -269,7 +301,7 @@ public static Version max(Version version1, Version version2) {
269301
* Returns the version given its string representation, current version if the argument is null or empty
270302
*/
271303
public static Version fromString(String version) {
272-
if (stringHasLength(version) == false) { // TODO replace with Strings.hasLength after refactoring Strings to core lib
304+
if (Strings.hasLength(version) == false) {
273305
return Version.CURRENT;
274306
}
275307
final Version cached = stringToVersion.get(version);
@@ -599,11 +631,4 @@ public static List<Version> getDeclaredVersions(final Class<?> versionClass) {
599631
return versions;
600632
}
601633

602-
/**
603-
* Check that the given String is neither <code>null</code> nor of length 0.
604-
* Note: Will return <code>true</code> for a String that purely consists of whitespace.
605-
*/
606-
public static boolean stringHasLength(String str) {
607-
return (str != null && str.length() > 0);
608-
}
609634
}

libs/core/src/main/java/org/opensearch/semver/SemverRange.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.opensearch.Version;
1212
import org.opensearch.common.Nullable;
1313
import org.opensearch.common.annotation.PublicApi;
14+
import org.opensearch.core.common.Strings;
1415
import org.opensearch.core.xcontent.ToXContentFragment;
1516
import org.opensearch.core.xcontent.XContentBuilder;
1617
import org.opensearch.semver.expr.Caret;
@@ -80,7 +81,7 @@ public static SemverRange fromString(final String range) {
8081

8182
RangeOperator rangeOperator = RangeOperator.fromRange(range);
8283
String version = range.replaceFirst(rangeOperator.asEscapedString(), "");
83-
if (!Version.stringHasLength(version)) {
84+
if (!Strings.hasLength(version)) {
8485
throw new IllegalArgumentException("Version cannot be empty");
8586
}
8687
return new SemverRange(Version.fromString(version), rangeOperator);

0 commit comments

Comments
 (0)