Deprecate the no-jdk distributions (#64275)

This commit adds logging to indicate that the no-jdk distributions are
deprecated and will be removed in a future release.
This commit is contained in:
Jason Tedor 2020-10-28 10:31:03 -04:00
parent 72009a9edd
commit 5d42c2b06e
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
4 changed files with 35 additions and 8 deletions

View File

@ -92,6 +92,10 @@ ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
ES_DISTRIBUTION_TYPE=${es.distribution.type}
ES_BUNDLED_JDK=${es.bundled_jdk}
if [[ "$ES_BUNDLED_JDK" == "false" ]]; then
echo "warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release" >&2
fi
if [[ "$ES_DISTRIBUTION_TYPE" == "docker" ]]; then
# Allow environment variables to be set by creating a file with the
# contents, and setting an environment variable with the suffix _FILE to

View File

@ -29,6 +29,10 @@ set ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
set ES_DISTRIBUTION_TYPE=${es.distribution.type}
set ES_BUNDLED_JDK=${es.bundled_jdk}
if "%ES_BUNDLED_JDK%" == "false" (
echo "warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release" >&2
)
cd /d "%ES_HOME%"
rem now set the path to java, pass "nojava" arg to skip setting JAVA_HOME and JAVA

View File

@ -73,6 +73,7 @@ import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.lease.Releasables;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.HeaderWarning;
import org.elasticsearch.common.logging.NodeAndClusterIdStateListener;
import org.elasticsearch.common.network.NetworkAddress;
@ -266,10 +267,15 @@ public class Node implements Closeable {
private final Lifecycle lifecycle = new Lifecycle();
/**
* Logger initialized in the ctor because if it were initialized statically
* then it wouldn't get the node name.
* This logger instance is an instance field as opposed to a static field. This ensures that the field is not
* initialized until an instance of Node is constructed, which is sure to happen after the logging infrastructure
* has been initialized to include the hostname. If this field were static, then it would be initialized when the
* class initializer runs. Alas, this happens too early, before logging is initialized as this class is referred to
* in InternalSettingsPreparer#finalizeSettings, which runs when creating the Environment, before logging is
* initialized.
*/
private final Logger logger;
private final Logger logger = LogManager.getLogger(Node.class);
private final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Node.class);
private final Injector injector;
private final Environment environment;
private final NodeEnvironment nodeEnvironment;
@ -293,7 +299,6 @@ public class Node implements Closeable {
*/
protected Node(final Environment initialEnvironment,
Collection<Class<? extends Plugin>> classpathPlugins, boolean forbidPrivateIndexSettings) {
logger = LogManager.getLogger(Node.class);
final List<Closeable> resourcesToClose = new ArrayList<>(); // register everything we need to release in the case of an error
boolean success = false;
try {
@ -320,6 +325,9 @@ public class Node implements Closeable {
logger.info("JVM home [{}], using bundled JDK [{}]", System.getProperty("java.home"), jvmInfo.getUsingBundledJdk());
} else {
logger.info("JVM home [{}]", System.getProperty("java.home"));
deprecationLogger.deprecate(
"no-jdk",
"no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release");
}
logger.info("JVM arguments {}", Arrays.toString(jvmInfo.getInputArguments()));
if (Build.CURRENT.isProductionRelease() == false) {

View File

@ -100,6 +100,7 @@ import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.index.analysis.TokenizerFactory;
import org.elasticsearch.indices.analysis.AnalysisModule;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.plugins.AnalysisPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.script.MockScriptEngine;
@ -415,10 +416,20 @@ public abstract class ESTestCase extends LuceneTestCase {
//appropriate test
try {
final List<String> warnings = threadContext.getResponseHeaders().get("Warning");
if (warnings != null && enableJodaDeprecationWarningsCheck() == false) {
List<String> filteredWarnings = filterJodaDeprecationWarnings(warnings);
assertThat( filteredWarnings, empty());
if (warnings != null) {
List<String> filteredWarnings = new ArrayList<>(warnings);
if (enableJodaDeprecationWarningsCheck() == false) {
filteredWarnings = filterJodaDeprecationWarnings(filteredWarnings);
}
if (JvmInfo.jvmInfo().getBundledJdk() == false) {
// unit tests do not run with the bundled JDK, if there are warnings we need to filter the no-jdk deprecation warning
filteredWarnings = filteredWarnings
.stream()
.filter(k -> k.contains(
"no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release") == false)
.collect(Collectors.toList());
}
assertThat("unexpected warning headers", filteredWarnings, empty());
} else {
assertNull("unexpected warning headers", warnings);
}