From e88e5aed8be8af618e4442b4e7c27a79be4d9745 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 8 Oct 2020 10:57:55 -0400 Subject: [PATCH 1/7] Add deprecation warning for removed setting The setting es.xcontent.strict_duplicate_detection was removed in 7.0 (see #34588). It was an undocumented setting, but enough users relied on it that its absence is causing problems during upgrades. This commit adds a message to the deprecation log if this setting is present at startup. --- .../packaging/test/ConfigurationTests.java | 17 +++++++++++++++++ .../org/elasticsearch/bootstrap/Bootstrap.java | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java index 28e7fdad74032..93147f2a8a1e4 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java @@ -24,8 +24,14 @@ import org.elasticsearch.packaging.util.Platforms; import org.junit.Before; +import java.nio.file.Files; +import java.util.List; + +import static java.nio.file.StandardOpenOption.APPEND; +import static java.nio.file.StandardOpenOption.CREATE; import static org.elasticsearch.packaging.util.FileUtils.append; import static org.elasticsearch.packaging.util.ServerUtils.makeRequest; +import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assume.assumeFalse; @@ -40,6 +46,17 @@ public void test10Install() throws Exception { install(); } + public void test50StrictDuplicateDetectionDeprecationWarning() throws Exception { + withCustomConfig(tempConf -> { + final List jvmOptions = org.elasticsearch.common.collect.List.of("-Des.xcontent.strict_duplicate_detection=false"); + Files.write(tempConf.resolve("jvm.options"), jvmOptions, CREATE, APPEND); + startElasticsearch(); + stopElasticsearch(); + }); + assertThat(FileUtils.slurp(installation.logs.resolve("elasticsearch_deprecation.log")), + containsString("The Java option es.xcontent.strict_duplicate_detection is set")); + } + public void test60HostnameSubstitution() throws Exception { String hostnameKey = Platforms.WINDOWS ? "COMPUTERNAME" : "HOSTNAME"; sh.getEnv().put(hostnameKey, "mytesthost"); diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index f99650ab67cec..d54f78d75edde 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -363,6 +363,14 @@ static void init( System.getProperty("java.home")); DeprecationLogger.getLogger(Bootstrap.class).deprecate("java_version_11_required", message); } + if (System.getProperties().containsKey("es.xcontent.strict_duplicate_detection")) { + final String message = String.format( + Locale.ROOT, + "The Java option es.xcontent.strict_duplicate_detection is set to [%s]; " + + "this option is deprecated and non-functional and should be removed from Java configuration.", + System.getProperty("es.xcontent.strict_duplicate_detection")); + DeprecationLogger.getLogger(Bootstrap.class).deprecate("strict_duplicate_detection_setting_removed", message); + } if (environment.pidFile() != null) { try { PidFile.create(environment.pidFile(), true); From bffeb3d34b4f48064257b3d966095ee7e4d86161 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 8 Oct 2020 13:04:32 -0400 Subject: [PATCH 2/7] Spotless formatting --- .../elasticsearch/packaging/test/ConfigurationTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java index 93147f2a8a1e4..57b5d9c5b7e80 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java @@ -53,8 +53,10 @@ public void test50StrictDuplicateDetectionDeprecationWarning() throws Exception startElasticsearch(); stopElasticsearch(); }); - assertThat(FileUtils.slurp(installation.logs.resolve("elasticsearch_deprecation.log")), - containsString("The Java option es.xcontent.strict_duplicate_detection is set")); + assertThat( + FileUtils.slurp(installation.logs.resolve("elasticsearch_deprecation.log")), + containsString("The Java option es.xcontent.strict_duplicate_detection is set") + ); } public void test60HostnameSubstitution() throws Exception { From 7f077298bcb7c2ef51e4d3d9338fbacb2acb9636 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 8 Oct 2020 13:42:22 -0400 Subject: [PATCH 3/7] Avoid forbidden API --- server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index d54f78d75edde..eac29581d66d6 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -363,7 +363,7 @@ static void init( System.getProperty("java.home")); DeprecationLogger.getLogger(Bootstrap.class).deprecate("java_version_11_required", message); } - if (System.getProperties().containsKey("es.xcontent.strict_duplicate_detection")) { + if (BootstrapInfo.getSystemProperties().get("es.xcontent.strict_duplicate_detection") != null) { final String message = String.format( Locale.ROOT, "The Java option es.xcontent.strict_duplicate_detection is set to [%s]; " + From 7b85113806d611249ada3ba0e2fcc953b9e6306c Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 8 Oct 2020 17:12:13 -0400 Subject: [PATCH 4/7] Reset between custom config tests --- .../packaging/test/ConfigurationTests.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java index 57b5d9c5b7e80..009465479ed03 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java @@ -22,6 +22,7 @@ import org.apache.http.client.fluent.Request; import org.elasticsearch.packaging.util.FileUtils; import org.elasticsearch.packaging.util.Platforms; +import org.junit.After; import org.junit.Before; import java.nio.file.Files; @@ -38,12 +39,14 @@ public class ConfigurationTests extends PackagingTestCase { @Before - public void filterDistros() { + public void filterDistrosAndInstall() throws Exception{ assumeFalse("no docker", distribution.isDocker()); + install(); } - public void test10Install() throws Exception { - install(); + @After + public void cleanInstall() throws Exception { + cleanup(); } public void test50StrictDuplicateDetectionDeprecationWarning() throws Exception { @@ -60,6 +63,9 @@ public void test50StrictDuplicateDetectionDeprecationWarning() throws Exception } public void test60HostnameSubstitution() throws Exception { + cleanup(); + install(); + String hostnameKey = Platforms.WINDOWS ? "COMPUTERNAME" : "HOSTNAME"; sh.getEnv().put(hostnameKey, "mytesthost"); withCustomConfig(confPath -> { From 263dc7c01571640a85216912713629aee1fc7552 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Thu, 8 Oct 2020 17:17:43 -0400 Subject: [PATCH 5/7] Spotless apply --- .../org/elasticsearch/packaging/test/ConfigurationTests.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java index 009465479ed03..ee9f89831a974 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java @@ -39,7 +39,7 @@ public class ConfigurationTests extends PackagingTestCase { @Before - public void filterDistrosAndInstall() throws Exception{ + public void filterDistrosAndInstall() throws Exception { assumeFalse("no docker", distribution.isDocker()); install(); } @@ -63,9 +63,6 @@ public void test50StrictDuplicateDetectionDeprecationWarning() throws Exception } public void test60HostnameSubstitution() throws Exception { - cleanup(); - install(); - String hostnameKey = Platforms.WINDOWS ? "COMPUTERNAME" : "HOSTNAME"; sh.getEnv().put(hostnameKey, "mytesthost"); withCustomConfig(confPath -> { From 4eb31d92c75b955bd8b05aa50a11396901f085b9 Mon Sep 17 00:00:00 2001 From: William Brafford Date: Tue, 13 Oct 2020 09:10:40 -0400 Subject: [PATCH 6/7] Access system properties consistently --- server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index eac29581d66d6..985e514ba56a8 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -368,7 +368,7 @@ static void init( Locale.ROOT, "The Java option es.xcontent.strict_duplicate_detection is set to [%s]; " + "this option is deprecated and non-functional and should be removed from Java configuration.", - System.getProperty("es.xcontent.strict_duplicate_detection")); + BootstrapInfo.getSystemProperties().get("es.xcontent.strict_duplicate_detection")); DeprecationLogger.getLogger(Bootstrap.class).deprecate("strict_duplicate_detection_setting_removed", message); } if (environment.pidFile() != null) { From e582ba33f23f69a6daabdc5a7bf09b4812ffe50a Mon Sep 17 00:00:00 2001 From: William Brafford Date: Tue, 13 Oct 2020 12:05:54 -0400 Subject: [PATCH 7/7] Revert changes to ConfigurationTests setup --- .../elasticsearch/packaging/test/ConfigurationTests.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java index ee9f89831a974..57b5d9c5b7e80 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/ConfigurationTests.java @@ -22,7 +22,6 @@ import org.apache.http.client.fluent.Request; import org.elasticsearch.packaging.util.FileUtils; import org.elasticsearch.packaging.util.Platforms; -import org.junit.After; import org.junit.Before; import java.nio.file.Files; @@ -39,14 +38,12 @@ public class ConfigurationTests extends PackagingTestCase { @Before - public void filterDistrosAndInstall() throws Exception { + public void filterDistros() { assumeFalse("no docker", distribution.isDocker()); - install(); } - @After - public void cleanInstall() throws Exception { - cleanup(); + public void test10Install() throws Exception { + install(); } public void test50StrictDuplicateDetectionDeprecationWarning() throws Exception {