Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(":")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ private DeprecationChecks() {
Collections.unmodifiableList(Arrays.asList(
ClusterDeprecationChecks::checkUserAgentPipelines,
ClusterDeprecationChecks::checkShardLimit,
ClusterDeprecationChecks::checkNoMasterBlock,
ClusterDeprecationChecks::checkClusterName
));

static List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS =
Collections.unmodifiableList(Arrays.asList(
NodeDeprecationChecks::httpEnabledSettingRemoved,
NodeDeprecationChecks::noMasterBlockRenamed,
NodeDeprecationChecks::auditLogPrefixSettingsCheck,
NodeDeprecationChecks::indexThreadPoolCheck,
NodeDeprecationChecks::bulkThreadPoolCheck,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<DeprecationIssue> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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",
Expand Down