Skip to content

Commit 221570e

Browse files
committed
Switch bundled jdk back to Oracle JDK (#63288) (#63290)
We switched to adoptopenjdk from oracle jdk to rely on the notarization found in adoptopnejdk on MacOS. However, that notarization still had issues, and we currently do our own notarization of the entire distribution, including the jdk. The recent bump to jdk 15 has revealed openjdk to be lax in maintaining support for older systems. Since the notarization is no longer an issue, this PR moves the bundled jdk back to Oracle, in order to continue supporting those older systems affected by adoptopenjdk 15. relates #62709
1 parent 4391438 commit 221570e

File tree

10 files changed

+10
-98
lines changed

10 files changed

+10
-98
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/info/BuildParams.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class BuildParams {
4949
private static Integer defaultParallel;
5050
private static Boolean isSnapshotBuild;
5151
private static BwcVersions bwcVersions;
52-
private static Boolean isBundledJdkSupported;
5352

5453
/**
5554
* Initialize global build parameters. This method accepts and a initialization function which in turn accepts a
@@ -135,10 +134,6 @@ public static boolean isSnapshotBuild() {
135134
return value(BuildParams.isSnapshotBuild);
136135
}
137136

138-
public static boolean isBundledJdkSupported() {
139-
return value(BuildParams.isBundledJdkSupported);
140-
}
141-
142137
private static <T> T value(T object) {
143138
if (object == null) {
144139
String callingMethod = Thread.currentThread().getStackTrace()[2].getMethodName();
@@ -251,9 +246,5 @@ public void setIsSnapshotBuild(final boolean isSnapshotBuild) {
251246
public void setBwcVersions(BwcVersions bwcVersions) {
252247
BuildParams.bwcVersions = requireNonNull(bwcVersions);
253248
}
254-
255-
public void setIsBundledJdkSupported(boolean isBundledJdkSupported) {
256-
BuildParams.isBundledJdkSupported = isBundledJdkSupported;
257-
}
258249
}
259250
}

buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.elasticsearch.gradle.info;
2020

2121
import org.apache.commons.io.IOUtils;
22-
import org.apache.tools.ant.taskdefs.condition.Os;
2322
import org.elasticsearch.gradle.BwcVersions;
2423
import org.elasticsearch.gradle.OS;
2524
import org.elasticsearch.gradle.util.Util;
@@ -121,7 +120,6 @@ public void apply(Project project) {
121120
params.setDefaultParallel(findDefaultParallel(project));
122121
params.setInFipsJvm(Util.getBooleanProperty("tests.fips.enabled", false));
123122
params.setIsSnapshotBuild(Util.getBooleanProperty("build.snapshot", true));
124-
params.setIsBundledJdkSupported(findIfBundledJdkSupported(project));
125123
if (isInternal) {
126124
params.setBwcVersions(resolveBwcVersions(rootDir));
127125
}
@@ -279,32 +277,6 @@ private static String findJavaHome(String version) {
279277
return versionedJavaHome;
280278
}
281279

282-
private static boolean findIfBundledJdkSupported(Project project) {
283-
if (_isBundledJdkSupported == null) {
284-
if (Os.isFamily(Os.FAMILY_UNIX) == false || Os.isFamily(Os.FAMILY_MAC)) {
285-
_isBundledJdkSupported = true;
286-
} else {
287-
// check if glibc version can support java 15+
288-
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
289-
project.exec(spec -> {
290-
spec.setCommandLine("getconf", "GNU_LIBC_VERSION");
291-
spec.setStandardOutput(stdout);
292-
});
293-
String version = stdout.toString().trim();
294-
final int[] glibcVersion;
295-
try {
296-
String[] parts = version.split(" ")[1].split("\\.");
297-
glibcVersion = new int[] { Integer.parseInt(parts[0]), Integer.parseInt(parts[1]) };
298-
} catch (Exception e) {
299-
throw new IllegalStateException("Could not parse glibc version from " + version, e);
300-
}
301-
// as of java 15, java requires GLIBC 2.14+
302-
_isBundledJdkSupported = glibcVersion[0] == 2 && glibcVersion[1] >= 14 || glibcVersion[0] > 2;
303-
}
304-
}
305-
return _isBundledJdkSupported;
306-
}
307-
308280
private static String getJavaHomeEnvVarName(String version) {
309281
return "JAVA" + version + "_HOME";
310282
}

buildSrc/src/main/java/org/elasticsearch/gradle/test/DistroTestPlugin.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public class DistroTestPlugin implements Plugin<Project> {
7373
private static final String DISTRIBUTION_SYSPROP = "tests.distribution";
7474
private static final String BWC_DISTRIBUTION_SYSPROP = "tests.bwc-distribution";
7575
private static final String EXAMPLE_PLUGIN_SYSPROP = "tests.example-plugin";
76-
private static final String IS_BUNDLED_JDK_SUPPORTED = "tests.is_bundled_jdk_supported";
7776

7877
@Override
7978
public void apply(Project project) {
@@ -157,11 +156,11 @@ public void apply(Project project) {
157156
}
158157
}
159158

160-
project.getTasks()
161-
.withType(
162-
Test.class,
163-
t -> addSysprop(t, IS_BUNDLED_JDK_SUPPORTED, () -> Boolean.toString(BuildParams.isBundledJdkSupported()))
164-
);
159+
// setup jdks used by no-jdk tests, and by gradle executing
160+
TaskProvider<Copy> linuxGradleJdk = createJdk(project, "gradle", GRADLE_JDK_VENDOR, GRADLE_JDK_VERSION, "linux", "x64");
161+
TaskProvider<Copy> linuxSystemJdk = createJdk(project, "system", SYSTEM_JDK_VENDOR, SYSTEM_JDK_VERSION, "linux", "x64");
162+
TaskProvider<Copy> windowsGradleJdk = createJdk(project, "gradle", GRADLE_JDK_VENDOR, GRADLE_JDK_VERSION, "windows", "x64");
163+
TaskProvider<Copy> windowsSystemJdk = createJdk(project, "system", SYSTEM_JDK_VENDOR, SYSTEM_JDK_VERSION, "windows", "x64");
165164

166165
project.subprojects(vmProject -> {
167166
vmProject.getPluginManager().apply(VagrantBasePlugin.class);

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,7 @@ private Map<String, String> getESEnvironment() {
757757

758758
private java.util.Optional<String> getRequiredJavaHome() {
759759
// If we are testing the current version of Elasticsearch, use the configured runtime Java
760-
if (getTestDistribution() == TestDistribution.INTEG_TEST
761-
|| getVersion().equals(VersionProperties.getElasticsearchVersion())
762-
|| BuildParams.isBundledJdkSupported() == false) {
760+
if (getTestDistribution() == TestDistribution.INTEG_TEST || getVersion().equals(VersionProperties.getElasticsearchVersion())) {
763761
return java.util.Optional.of(BuildParams.getRuntimeJavaHome()).map(File::getAbsolutePath);
764762
} else if (getVersion().before("7.0.0")) {
765763
return java.util.Optional.of(bwcJdk.getJavaHomePath().toString());

buildSrc/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
elasticsearch = 7.9.3
22
lucene = 8.6.2
33

4-
bundled_jdk_vendor = adoptopenjdk
5-
bundled_jdk = 15+36
4+
bundled_jdk_vendor = openjdk
5+
bundled_jdk = 15+36@779bf45e88a44cbd9ea6621d33e33db1
66

77
checkstyle = 8.20
88

distribution/src/bin/elasticsearch-env

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,43 +35,6 @@ ES_HOME=`dirname "$ES_HOME"`
3535
# now set the classpath
3636
ES_CLASSPATH="$ES_HOME/lib/*"
3737

38-
39-
# On systems that are built upon glibc, We need to check the version of
40-
# glibc because Elasticsearch bundles JDK 15, which requires glibc >= 2.14
41-
check_glibc_version() {
42-
local GETCONF="$( getconf GNU_LIBC_VERSION 2>/dev/null )"
43-
if [[ $? -ne 0 ]]; then
44-
# Must be on a POSIX system that isn't using glibc.
45-
return 0
46-
fi
47-
48-
local GLIBC_VERSION="$( echo "$GETCONF" | cut -d' ' -f2 )"
49-
local MAJOR="$( echo $GLIBC_VERSION | cut -d. -f1 )"
50-
local MINOR="$( echo $GLIBC_VERSION | cut -d. -f2 )"
51-
52-
local STATUS=pass
53-
54-
if [[ "$MAJOR" -lt 2 ]]; then
55-
STATUS=fail
56-
elif [[ "$MAJOR" -eq 2 && "$MINOR" -lt 14 ]]; then
57-
STATUS=fail
58-
fi
59-
60-
if [[ "$STATUS" == "fail" ]]; then
61-
cat >&2 <<EOF
62-
63-
ERROR: The JDK bundled with Elasticsearch requires glibc >= 2.14, but
64-
you have version $GLIBC_VERSION. Please set the JAVA_HOME environment variable
65-
to point to a working JDK installation. For more information, see:
66-
67-
https://www.elastic.co/support/matrix#matrix_jvm
68-
69-
EOF
70-
exit 1
71-
fi
72-
}
73-
74-
7538
# now set the path to java
7639
if [ ! -z "$JAVA_HOME" ]; then
7740
JAVA="$JAVA_HOME/bin/java"
@@ -81,7 +44,6 @@ else
8144
# macOS has a different structure
8245
JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
8346
else
84-
check_glibc_version
8547
JAVA="$ES_HOME/jdk/bin/java"
8648
fi
8749
JAVA_TYPE="bundled jdk"

gradle/runtime-jdk-provision.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (BuildParams.getIsRuntimeJavaHomeSet()) {
1313
}
1414
}
1515
}
16-
} else if (BuildParams.isBundledJdkSupported()) {
16+
} else {
1717
jdks {
1818
provisioned_runtime {
1919
vendor = VersionProperties.bundledJdkVendor

qa/os/src/test/java/org/elasticsearch/packaging/test/ArchiveTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public void test20PluginsListWithNoPlugins() throws Exception {
7272
}
7373

7474
public void test30MissingBundledJdk() throws Exception {
75-
assumeTrue(Platforms.IS_BUNDLED_JDK_SUPPORTED);
7675
final Installation.Executables bin = installation.executables();
7776
sh.getEnv().remove("JAVA_HOME");
7877

qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ public Distribution(Path path) {
4646

4747
this.platform = filename.contains("windows") ? Platform.WINDOWS : Platform.LINUX;
4848
this.flavor = filename.contains("oss") ? Flavor.OSS : Flavor.DEFAULT;
49-
// even if a bundled jdk exists in the distribution, it is not supported on some legacy platforms.
50-
// the distribution here acts like the bundled jdk doesn't exist because many tests use this flag
51-
// to determine whether to test certain aspects of the bundled jdk behavior
52-
this.hasJdk = filename.contains("no-jdk") == false && Platforms.IS_BUNDLED_JDK_SUPPORTED;
49+
this.hasJdk = filename.contains("no-jdk") == false;
5350
String version = filename.split("-", 3)[1];
5451
if (filename.contains("-SNAPSHOT")) {
5552
version += "-SNAPSHOT";

qa/os/src/test/java/org/elasticsearch/packaging/util/Platforms.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.elasticsearch.packaging.util;
2121

22-
import org.elasticsearch.common.Booleans;
23-
2422
import java.nio.file.Paths;
2523

2624
import static org.elasticsearch.packaging.util.FileUtils.slurp;
@@ -32,10 +30,6 @@ public class Platforms {
3230
public static final boolean DARWIN = OS_NAME.startsWith("Mac OS X");
3331
public static final PlatformAction NO_ACTION = () -> {};
3432

35-
public static final boolean IS_BUNDLED_JDK_SUPPORTED = Booleans.parseBoolean(
36-
System.getProperty("tests.is_bundled_jdk_supported", "true")
37-
);
38-
3933
public static String getOsRelease() {
4034
if (LINUX) {
4135
return slurp(Paths.get("/etc/os-release"));

0 commit comments

Comments
 (0)