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 60ba41c06fb5f..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 @@ -18,6 +18,8 @@ import java.util.Objects; import java.util.stream.Collectors; +import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING; + public class ClusterDeprecationChecks { static DeprecationIssue checkShardLimit(ClusterState state) { @@ -37,6 +39,18 @@ 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 will be renamed", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "_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; + } + 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 6434c8103f7cb..42e0abfcdb2bf 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 @@ -35,12 +35,14 @@ private DeprecationChecks() { Collections.unmodifiableList(Arrays.asList( ClusterDeprecationChecks::checkUserAgentPipelines, 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 780391e4a4244..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 @@ -24,6 +24,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; import static org.elasticsearch.xpack.core.XPackSettings.SECURITY_ENABLED; import static org.elasticsearch.xpack.core.XPackSettings.TRANSPORT_SSL_ENABLED; @@ -44,6 +45,18 @@ 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_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; + } + 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 09bc2b991fa8a..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 @@ -24,6 +24,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 { @@ -45,6 +46,25 @@ 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 will be renamed", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "_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); + } + 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 88da4e5252f96..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 @@ -30,6 +30,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; @@ -84,6 +85,17 @@ 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_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); + } + public void testAuditLoggingPrefixSettingsCheck() { DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL, "Audit log node info settings renamed",