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
This commit is contained in:
Ryan Ernst 2020-10-05 16:31:10 -07:00 committed by GitHub
parent e91936512a
commit 25f8a3ba42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 5 additions and 99 deletions

View File

@ -49,7 +49,6 @@ public class BuildParams {
private static Integer defaultParallel;
private static Boolean isSnapshotBuild;
private static BwcVersions bwcVersions;
private static Boolean isBundledJdkSupported;
/**
* Initialize global build parameters. This method accepts and a initialization function which in turn accepts a
@ -135,10 +134,6 @@ public class BuildParams {
return value(BuildParams.isSnapshotBuild);
}
public static boolean isBundledJdkSupported() {
return value(BuildParams.isBundledJdkSupported);
}
private static <T> T value(T object) {
if (object == null) {
String callingMethod = Thread.currentThread().getStackTrace()[2].getMethodName();
@ -251,9 +246,5 @@ public class BuildParams {
public void setBwcVersions(BwcVersions bwcVersions) {
BuildParams.bwcVersions = requireNonNull(bwcVersions);
}
public void setIsBundledJdkSupported(boolean isBundledJdkSupported) {
BuildParams.isBundledJdkSupported = isBundledJdkSupported;
}
}
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.gradle.info;
import org.apache.commons.io.IOUtils;
import org.apache.tools.ant.taskdefs.condition.Os;
import org.elasticsearch.gradle.BwcVersions;
import org.elasticsearch.gradle.OS;
import org.elasticsearch.gradle.util.Util;
@ -121,7 +120,6 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
params.setDefaultParallel(findDefaultParallel(project));
params.setInFipsJvm(Util.getBooleanProperty("tests.fips.enabled", false));
params.setIsSnapshotBuild(Util.getBooleanProperty("build.snapshot", true));
params.setIsBundledJdkSupported(findIfBundledJdkSupported(project));
if (isInternal) {
params.setBwcVersions(resolveBwcVersions(rootDir));
}
@ -279,32 +277,6 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
return versionedJavaHome;
}
private static boolean findIfBundledJdkSupported(Project project) {
if (_isBundledJdkSupported == null) {
if (Os.isFamily(Os.FAMILY_UNIX) == false || Os.isFamily(Os.FAMILY_MAC)) {
_isBundledJdkSupported = true;
} else {
// check if glibc version can support java 15+
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
project.exec(spec -> {
spec.setCommandLine("getconf", "GNU_LIBC_VERSION");
spec.setStandardOutput(stdout);
});
String version = stdout.toString().trim();
final int[] glibcVersion;
try {
String[] parts = version.split(" ")[1].split("\\.");
glibcVersion = new int[] { Integer.parseInt(parts[0]), Integer.parseInt(parts[1]) };
} catch (Exception e) {
throw new IllegalStateException("Could not parse glibc version from " + version, e);
}
// as of java 15, java requires GLIBC 2.14+
_isBundledJdkSupported = glibcVersion[0] == 2 && glibcVersion[1] >= 14 || glibcVersion[0] > 2;
}
}
return _isBundledJdkSupported;
}
private static String getJavaHomeEnvVarName(String version) {
return "JAVA" + version + "_HOME";
}

View File

@ -77,7 +77,6 @@ public class DistroTestPlugin implements Plugin<Project> {
private static final String DISTRIBUTION_SYSPROP = "tests.distribution";
private static final String BWC_DISTRIBUTION_SYSPROP = "tests.bwc-distribution";
private static final String EXAMPLE_PLUGIN_SYSPROP = "tests.example-plugin";
private static final String IS_BUNDLED_JDK_SUPPORTED = "tests.is_bundled_jdk_supported";
@Override
public void apply(Project project) {
@ -162,12 +161,6 @@ public class DistroTestPlugin implements Plugin<Project> {
}
}
project.getTasks()
.withType(
Test.class,
t -> addSysprop(t, IS_BUNDLED_JDK_SUPPORTED, () -> Boolean.toString(BuildParams.isBundledJdkSupported()))
);
// setup jdks used by no-jdk tests, and by gradle executing
TaskProvider<Copy> linuxGradleJdk = createJdk(project, "gradle", GRADLE_JDK_VENDOR, GRADLE_JDK_VERSION, "linux", "x64");
TaskProvider<Copy> linuxSystemJdk = createJdk(project, "system", SYSTEM_JDK_VENDOR, SYSTEM_JDK_VERSION, "linux", "x64");

View File

@ -788,9 +788,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
private java.util.Optional<String> getRequiredJavaHome() {
// If we are testing the current version of Elasticsearch, use the configured runtime Java
if (getTestDistribution() == TestDistribution.INTEG_TEST
|| getVersion().equals(VersionProperties.getElasticsearchVersion())
|| BuildParams.isBundledJdkSupported() == false) {
if (getTestDistribution() == TestDistribution.INTEG_TEST || getVersion().equals(VersionProperties.getElasticsearchVersion())) {
return java.util.Optional.of(BuildParams.getRuntimeJavaHome()).map(File::getAbsolutePath);
} else if (getVersion().before("7.0.0")) {
return java.util.Optional.of(bwcJdk.getJavaHomePath().toString());

View File

@ -1,8 +1,8 @@
elasticsearch = 7.10.0
lucene = 8.7.0-snapshot-77396dbf339
bundled_jdk_vendor = adoptopenjdk
bundled_jdk = 15+36
bundled_jdk_vendor = openjdk
bundled_jdk = 15+36@779bf45e88a44cbd9ea6621d33e33db1
checkstyle = 8.20

View File

@ -35,43 +35,6 @@ ES_HOME=`dirname "$ES_HOME"`
# now set the classpath
ES_CLASSPATH="$ES_HOME/lib/*"
# On systems that are built upon glibc, We need to check the version of
# glibc because Elasticsearch bundles JDK 15, which requires glibc >= 2.14
check_glibc_version() {
local GETCONF="$( getconf GNU_LIBC_VERSION 2>/dev/null )"
if [[ $? -ne 0 ]]; then
# Must be on a POSIX system that isn't using glibc.
return 0
fi
local GLIBC_VERSION="$( echo "$GETCONF" | cut -d' ' -f2 )"
local MAJOR="$( echo $GLIBC_VERSION | cut -d. -f1 )"
local MINOR="$( echo $GLIBC_VERSION | cut -d. -f2 )"
local STATUS=pass
if [[ "$MAJOR" -lt 2 ]]; then
STATUS=fail
elif [[ "$MAJOR" -eq 2 && "$MINOR" -lt 14 ]]; then
STATUS=fail
fi
if [[ "$STATUS" == "fail" ]]; then
cat >&2 <<EOF
ERROR: The JDK bundled with Elasticsearch requires glibc >= 2.14, but
you have version $GLIBC_VERSION. Please set the JAVA_HOME environment variable
to point to a working JDK installation. For more information, see:
https://www.elastic.co/support/matrix#matrix_jvm
EOF
exit 1
fi
}
# now set the path to java
if [ ! -z "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME/bin/java"
@ -81,7 +44,6 @@ else
# macOS has a different structure
JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
else
check_glibc_version
JAVA="$ES_HOME/jdk/bin/java"
fi
JAVA_TYPE="bundled jdk"

View File

@ -13,7 +13,7 @@ if (BuildParams.getIsRuntimeJavaHomeSet()) {
}
}
}
} else if (BuildParams.isBundledJdkSupported()) {
} else {
jdks {
provisioned_runtime {
vendor = VersionProperties.bundledJdkVendor

View File

@ -72,7 +72,6 @@ public class ArchiveTests extends PackagingTestCase {
}
public void test30MissingBundledJdk() throws Exception {
assumeTrue(Platforms.IS_BUNDLED_JDK_SUPPORTED);
final Installation.Executables bin = installation.executables();
sh.getEnv().remove("JAVA_HOME");

View File

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

View File

@ -19,8 +19,6 @@
package org.elasticsearch.packaging.util;
import org.elasticsearch.common.Booleans;
import java.nio.file.Paths;
import static org.elasticsearch.packaging.util.FileUtils.slurp;
@ -32,10 +30,6 @@ public class Platforms {
public static final boolean DARWIN = OS_NAME.startsWith("Mac OS X");
public static final PlatformAction NO_ACTION = () -> {};
public static final boolean IS_BUNDLED_JDK_SUPPORTED = Booleans.parseBoolean(
System.getProperty("tests.is_bundled_jdk_supported", "true")
);
public static String getOsRelease() {
if (LINUX) {
return slurp(Paths.get("/etc/os-release"));