From cb285e41c2e007bc34b62d1448c0cf16aae91227 Mon Sep 17 00:00:00 2001 From: Nikola Grcevski Date: Tue, 19 Oct 2021 14:19:11 -0400 Subject: [PATCH 1/2] Improve transient settings deprecation message Add the setting name as part of the deprecation response. --- .../deprecation/ClusterDeprecationChecks.java | 7 ++++++- .../ClusterDeprecationChecksTests.java | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java index f3e5ca87eb8b8..07f8cb2cf48aa 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java @@ -10,13 +10,18 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; +import java.util.Locale; +import java.util.stream.Collectors; + public class ClusterDeprecationChecks { static DeprecationIssue checkTransientSettingsExistence(ClusterState state) { if (state.metadata().transientSettings().isEmpty() == false) { return new DeprecationIssue(DeprecationIssue.Level.WARNING, "Transient cluster settings are in the process of being removed.", "https://ela.st/es-deprecation-7-transient-cluster-settings", - "Use persistent settings to define your cluster settings instead.", + String.format(Locale.ROOT, + "Use persistent settings instead of transient settings for the following: [%s]", + state.metadata().transientSettings().names().stream().sorted().collect(Collectors.joining(", "))), false, null); } diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java index abacd55a3acee..54bb32790b8c6 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java @@ -13,29 +13,41 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; +import java.util.Locale; + import static org.hamcrest.Matchers.equalTo; public class ClusterDeprecationChecksTests extends ESTestCase { public void testCheckTransientSettingsExistence() { + Settings persistentSettings = Settings.builder() + .put("xpack.monitoring.collection.enabled", true) + .build(); + Settings transientSettings = Settings.builder() .put("indices.recovery.max_bytes_per_sec", "20mb") + .put("action.auto_create_index", true) + .put("cluster.routing.allocation.enable", "primaries") .build(); Metadata metadataWithTransientSettings = Metadata.builder() + .persistentSettings(persistentSettings) .transientSettings(transientSettings) .build(); ClusterState badState = ClusterState.builder(new ClusterName("test")).metadata(metadataWithTransientSettings).build(); DeprecationIssue issue = ClusterDeprecationChecks.checkTransientSettingsExistence(badState); + String expectedDetails = String.format(Locale.ROOT, + "Use persistent settings instead of transient settings for the following: [%s]", + String.join(", ", "action", "cluster", "indices")); assertThat(issue, equalTo( new DeprecationIssue(DeprecationIssue.Level.WARNING, "Transient cluster settings are in the process of being removed.", "https://ela.st/es-deprecation-7-transient-cluster-settings", - "Use persistent settings to define your cluster settings instead.", + expectedDetails, false, null) )); - Settings persistentSettings = Settings.builder() + persistentSettings = Settings.builder() .put("indices.recovery.max_bytes_per_sec", "20mb") .build(); Metadata metadataWithoutTransientSettings = Metadata.builder() From 0070895030ac0870b48741820d4825224a05a059 Mon Sep 17 00:00:00 2001 From: Nikola Grcevski Date: Tue, 19 Oct 2021 15:16:08 -0400 Subject: [PATCH 2/2] Update message as per docs team's suggestion. --- .../xpack/deprecation/ClusterDeprecationChecks.java | 9 ++------- .../xpack/deprecation/ClusterDeprecationChecksTests.java | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java index 07f8cb2cf48aa..63e3ee50187a7 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java @@ -10,18 +10,13 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; -import java.util.Locale; -import java.util.stream.Collectors; - public class ClusterDeprecationChecks { static DeprecationIssue checkTransientSettingsExistence(ClusterState state) { if (state.metadata().transientSettings().isEmpty() == false) { return new DeprecationIssue(DeprecationIssue.Level.WARNING, - "Transient cluster settings are in the process of being removed.", + "Transient cluster settings are deprecated", "https://ela.st/es-deprecation-7-transient-cluster-settings", - String.format(Locale.ROOT, - "Use persistent settings instead of transient settings for the following: [%s]", - state.metadata().transientSettings().names().stream().sorted().collect(Collectors.joining(", "))), + "Use persistent settings to configure your cluster.", false, null); } diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java index 54bb32790b8c6..730bf691ddc10 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java @@ -13,8 +13,6 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; -import java.util.Locale; - import static org.hamcrest.Matchers.equalTo; public class ClusterDeprecationChecksTests extends ESTestCase { @@ -36,14 +34,11 @@ public void testCheckTransientSettingsExistence() { ClusterState badState = ClusterState.builder(new ClusterName("test")).metadata(metadataWithTransientSettings).build(); DeprecationIssue issue = ClusterDeprecationChecks.checkTransientSettingsExistence(badState); - String expectedDetails = String.format(Locale.ROOT, - "Use persistent settings instead of transient settings for the following: [%s]", - String.join(", ", "action", "cluster", "indices")); assertThat(issue, equalTo( new DeprecationIssue(DeprecationIssue.Level.WARNING, - "Transient cluster settings are in the process of being removed.", + "Transient cluster settings are deprecated", "https://ela.st/es-deprecation-7-transient-cluster-settings", - expectedDetails, + "Use persistent settings to configure your cluster.", false, null) ));