Skip to content

Commit 5512574

Browse files
authored
Deprecation check for No Master Block setting (#38383)
`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.
1 parent d0ac828 commit 5512574

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecks.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.util.Objects;
1919
import java.util.stream.Collectors;
2020

21+
import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING;
22+
2123
public class ClusterDeprecationChecks {
2224

2325
static DeprecationIssue checkShardLimit(ClusterState state) {
@@ -37,6 +39,18 @@ static DeprecationIssue checkShardLimit(ClusterState state) {
3739
return null;
3840
}
3941

42+
static DeprecationIssue checkNoMasterBlock(ClusterState state) {
43+
if (state.metaData().settings().hasValue(NO_MASTER_BLOCK_SETTING.getKey())) {
44+
return new DeprecationIssue(DeprecationIssue.Level.WARNING,
45+
"Master block setting will be renamed",
46+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
47+
"_new_name_for_literal_no_master_block_literal_setting",
48+
"The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " +
49+
"Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0.");
50+
}
51+
return null;
52+
}
53+
4054
static DeprecationIssue checkClusterName(ClusterState state) {
4155
String clusterName = state.getClusterName().value();
4256
if (clusterName.contains(":")) {

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ private DeprecationChecks() {
3535
Collections.unmodifiableList(Arrays.asList(
3636
ClusterDeprecationChecks::checkUserAgentPipelines,
3737
ClusterDeprecationChecks::checkShardLimit,
38+
ClusterDeprecationChecks::checkNoMasterBlock,
3839
ClusterDeprecationChecks::checkClusterName
3940
));
4041

4142
static List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS =
4243
Collections.unmodifiableList(Arrays.asList(
4344
NodeDeprecationChecks::httpEnabledSettingRemoved,
45+
NodeDeprecationChecks::noMasterBlockRenamed,
4446
NodeDeprecationChecks::auditLogPrefixSettingsCheck,
4547
NodeDeprecationChecks::indexThreadPoolCheck,
4648
NodeDeprecationChecks::bulkThreadPoolCheck,

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING;
2626
import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING;
27+
import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING;
2728
import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING;
2829
import static org.elasticsearch.xpack.core.XPackSettings.SECURITY_ENABLED;
2930
import static org.elasticsearch.xpack.core.XPackSettings.TRANSPORT_SSL_ENABLED;
@@ -44,6 +45,18 @@ static DeprecationIssue httpEnabledSettingRemoved(Settings nodeSettings, Plugins
4445
return null;
4546
}
4647

48+
static DeprecationIssue noMasterBlockRenamed(Settings nodeSettings, PluginsAndModules plugins) {
49+
if (nodeSettings.hasValue(NO_MASTER_BLOCK_SETTING.getKey())) {
50+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
51+
"Master block setting renamed",
52+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
53+
"_new_name_for_literal_no_master_block_literal_setting",
54+
"The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " +
55+
"Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0.");
56+
}
57+
return null;
58+
}
59+
4760
static DeprecationIssue auditLogPrefixSettingsCheck(Settings nodeSettings, PluginsAndModules plugins) {
4861
if (nodeSettings.getByPrefix("xpack.security.audit.logfile.prefix").isEmpty() == false) {
4962
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL,

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/ClusterDeprecationChecksTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.List;
2525

2626
import static java.util.Collections.singletonList;
27+
import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING;
2728
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.CLUSTER_SETTINGS_CHECKS;
2829

2930
public class ClusterDeprecationChecksTests extends ESTestCase {
@@ -45,6 +46,25 @@ public void testCheckClusterName() {
4546
assertTrue(noIssues.isEmpty());
4647
}
4748

49+
public void testCheckNoMasterBlock() {
50+
MetaData metaData = MetaData.builder()
51+
.persistentSettings(Settings.builder()
52+
.put(NO_MASTER_BLOCK_SETTING.getKey(), randomFrom("all", "write"))
53+
.build())
54+
.build();
55+
ClusterState state = ClusterState.builder(new ClusterName("test"))
56+
.metaData(metaData)
57+
.build();
58+
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING,
59+
"Master block setting will be renamed",
60+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
61+
"_new_name_for_literal_no_master_block_literal_setting",
62+
"The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " +
63+
"Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0.");
64+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(CLUSTER_SETTINGS_CHECKS, c -> c.apply(state));
65+
assertEquals(singletonList(expected), issues);
66+
}
67+
4868
public void testCheckShardLimit() {
4969
int shardsPerNode = randomIntBetween(2, 10000);
5070
int nodeCount = randomIntBetween(1, 10);

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING;
3131
import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING;
3232
import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING;
33+
import static org.elasticsearch.discovery.DiscoverySettings.NO_MASTER_BLOCK_SETTING;
3334
import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
3435
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.NODE_SETTINGS_CHECKS;
3536

@@ -84,6 +85,17 @@ public void testHttpEnabledCheck() {
8485
assertSettingsAndIssue("http.enabled", Boolean.toString(randomBoolean()), expected);
8586
}
8687

88+
public void testNoMasterBlockRenamed() {
89+
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
90+
"Master block setting renamed",
91+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
92+
"_new_name_for_literal_no_master_block_literal_setting",
93+
"The setting discovery.zen.no_master_block will be renamed to cluster.no_master_block in 7.0. " +
94+
"Please unset discovery.zen.no_master_block and set cluster.no_master_block after upgrading to 7.0.");
95+
96+
assertSettingsAndIssue(NO_MASTER_BLOCK_SETTING.getKey(), randomFrom("all", "write"), expected);
97+
}
98+
8799
public void testAuditLoggingPrefixSettingsCheck() {
88100
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
89101
"Audit log node info settings renamed",

0 commit comments

Comments
 (0)