From 8dfbe928b6c15d7ad5b27a605f52c1d80a6c628e Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Mon, 4 Feb 2019 17:15:55 -0700 Subject: [PATCH 1/3] Deprecation check for No Master Block setting `discovery.zen.no_master_block` is deprecated in favor of `cluster.no_master_block` in 7.0, but is a dynamic setting so we need both node- and cluster-level checks for it. --- .../deprecation/ClusterDeprecationChecks.java | 13 +++++++++++++ .../xpack/deprecation/DeprecationChecks.java | 2 ++ .../deprecation/NodeDeprecationChecks.java | 12 ++++++++++++ .../ClusterDeprecationChecksTests.java | 19 +++++++++++++++++++ .../NodeDeprecationChecksTests.java | 11 +++++++++++ 5 files changed, 57 insertions(+) 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 28ff1b2673f70..84b0620cedebd 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,6 +10,8 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; +import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING; + public class ClusterDeprecationChecks { static DeprecationIssue checkShardLimit(ClusterState state) { @@ -29,6 +31,17 @@ static DeprecationIssue checkShardLimit(ClusterState state) { return null; } + static DeprecationIssue checkNoMasterBlock(ClusterState state) { + if (state.metaData().settings().hasValue(NO_MASTER_BLOCK_SETTING.getKey())) { + return new DeprecationIssue(DeprecationIssue.Level.WARNING, + "Master block setting renamed", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "_new_name_for_literal_no_maaster_block_literal_setting", + "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + } + return null; + } + static DeprecationIssue checkClusterName(ClusterState state) { String clusterName = state.getClusterName().value(); if (clusterName.contains(":")) { diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java index 6a22f694771dc..44164f02ecfd2 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java @@ -34,12 +34,14 @@ private DeprecationChecks() { static List> CLUSTER_SETTINGS_CHECKS = Collections.unmodifiableList(Arrays.asList( ClusterDeprecationChecks::checkShardLimit, + ClusterDeprecationChecks::checkNoMasterBlock, ClusterDeprecationChecks::checkClusterName )); static List> NODE_SETTINGS_CHECKS = Collections.unmodifiableList(Arrays.asList( NodeDeprecationChecks::httpEnabledSettingRemoved, + NodeDeprecationChecks::noMasterBlockRenamed, NodeDeprecationChecks::auditLogPrefixSettingsCheck, NodeDeprecationChecks::indexThreadPoolCheck, NodeDeprecationChecks::bulkThreadPoolCheck, diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index c88345466962a..f18b0fc0322e3 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -14,6 +14,7 @@ import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING; +import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING; import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; /** @@ -32,6 +33,17 @@ static DeprecationIssue httpEnabledSettingRemoved(Settings nodeSettings, Plugins return null; } + static DeprecationIssue noMasterBlockRenamed(Settings nodeSettings, PluginsAndModules plugins) { + if (nodeSettings.hasValue(NO_MASTER_BLOCK_SETTING.getKey())) { + return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, + "Master block setting renamed", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "_new_name_for_literal_no_maaster_block_literal_setting", + "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + } + return null; + } + static DeprecationIssue auditLogPrefixSettingsCheck(Settings nodeSettings, PluginsAndModules plugins) { if (nodeSettings.getByPrefix("xpack.security.audit.logfile.prefix").isEmpty() == false) { return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, 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 f2d407b024e1a..8822afe4ef8e9 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 @@ -20,6 +20,7 @@ import java.util.List; import static java.util.Collections.singletonList; +import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING; import static org.elasticsearch.xpack.deprecation.DeprecationChecks.CLUSTER_SETTINGS_CHECKS; public class ClusterDeprecationChecksTests extends ESTestCase { @@ -41,6 +42,24 @@ public void testCheckClusterName() { assertTrue(noIssues.isEmpty()); } + public void testCheckNoMasterBlock() { + MetaData metaData = MetaData.builder() + .persistentSettings(Settings.builder() + .put(NO_MASTER_BLOCK_SETTING.getKey(), randomFrom("all", "write")) + .build()) + .build(); + ClusterState state = ClusterState.builder(new ClusterName("test")) + .metaData(metaData) + .build(); + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, + "Master block setting renamed", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "_new_name_for_literal_no_maaster_block_literal_setting", + "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + List issues = DeprecationChecks.filterChecks(CLUSTER_SETTINGS_CHECKS, c -> c.apply(state)); + assertEquals(singletonList(expected), issues); + } + public void testCheckShardLimit() { int shardsPerNode = randomIntBetween(2, 10000); int nodeCount = randomIntBetween(1, 10); diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java index 915edbbfb71bc..db4c9ddb0663a 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -29,6 +29,7 @@ import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING; import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING; +import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING; import static org.elasticsearch.node.Node.NODE_NAME_SETTING; import static org.elasticsearch.xpack.deprecation.DeprecationChecks.NODE_SETTINGS_CHECKS; @@ -74,6 +75,16 @@ public void testHttpEnabledCheck() { assertSettingsAndIssue("http.enabled", Boolean.toString(randomBoolean()), expected); } + public void testNoMasterBlockRenamed() { + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL, + "Master block setting renamed", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "_new_name_for_literal_no_maaster_block_literal_setting", + "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + + assertSettingsAndIssue(NO_MASTER_BLOCK_SETTING.getKey(), randomFrom("all", "write"), expected); + } + public void testAuditLoggingPrefixSettingsCheck() { DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL, "Audit log node info settings renamed", From e70ae538d329e82c84162b677c90aea7bf3c14e0 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Tue, 5 Feb 2019 10:00:27 -0700 Subject: [PATCH 2/3] Review feedback --- .../xpack/deprecation/ClusterDeprecationChecks.java | 7 ++++--- .../xpack/deprecation/ClusterDeprecationChecksTests.java | 7 ++++--- 2 files changed, 8 insertions(+), 6 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 b797831b82cac..8142622b1f0ba 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 @@ -42,10 +42,11 @@ static DeprecationIssue checkShardLimit(ClusterState state) { static DeprecationIssue checkNoMasterBlock(ClusterState state) { if (state.metaData().settings().hasValue(NO_MASTER_BLOCK_SETTING.getKey())) { return new DeprecationIssue(DeprecationIssue.Level.WARNING, - "Master block setting renamed", + "Master block setting will be renamed", "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + - "_new_name_for_literal_no_maaster_block_literal_setting", - "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + "_new_name_for_literal_no_master_block_literal_setting", + "The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " + + "Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0."); } return 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 afc07ebfdab3a..007c3edd0a85e 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 @@ -56,10 +56,11 @@ public void testCheckNoMasterBlock() { .metaData(metaData) .build(); DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, - "Master block setting renamed", + "Master block setting will be renamed", "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + - "_new_name_for_literal_no_maaster_block_literal_setting", - "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + "_new_name_for_literal_no_master_block_literal_setting", + "The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " + + "Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0."); List issues = DeprecationChecks.filterChecks(CLUSTER_SETTINGS_CHECKS, c -> c.apply(state)); assertEquals(singletonList(expected), issues); } From 83916ff25f87a52aa76c536223c6c129ad7b2fe6 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Tue, 5 Feb 2019 10:15:46 -0700 Subject: [PATCH 3/3] Review feedback for Node checks --- .../xpack/deprecation/NodeDeprecationChecks.java | 5 +++-- .../xpack/deprecation/NodeDeprecationChecksTests.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index 75646b3b2bc37..0ba932b5094dd 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -50,8 +50,9 @@ static DeprecationIssue noMasterBlockRenamed(Settings nodeSettings, PluginsAndMo return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, "Master block setting renamed", "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + - "_new_name_for_literal_no_maaster_block_literal_setting", - "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + "_new_name_for_literal_no_master_block_literal_setting", + "The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " + + "Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0."); } return null; } diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java index 401fd798ae25b..35d7a11799664 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -89,8 +89,9 @@ public void testNoMasterBlockRenamed() { DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL, "Master block setting renamed", "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + - "_new_name_for_literal_no_maaster_block_literal_setting", - "The settings discovery.zen.no_master_block has been renamed to cluster.no_master_block"); + "_new_name_for_literal_no_master_block_literal_setting", + "The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " + + "Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0."); assertSettingsAndIssue(NO_MASTER_BLOCK_SETTING.getKey(), randomFrom("all", "write"), expected); }