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 93057e92b9a21..91a88dbcbd866 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 @@ -97,6 +97,7 @@ private DeprecationChecks() { NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial, NodeDeprecationChecks::checkSearchRemoteSettings, NodeDeprecationChecks::checkMonitoringExporterPassword, + NodeDeprecationChecks::checkDelayClusterStateRecoverySettings, NodeDeprecationChecks::checkFixedAutoQueueSizeThreadpool, NodeDeprecationChecks::checkJoinTimeoutSetting, NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting, 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 876d4f3fa7b27..4ffe30bbac4c3 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 @@ -25,6 +25,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; +import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.jdk.JavaVersion; import org.elasticsearch.license.License; import org.elasticsearch.license.XPackLicenseState; @@ -665,6 +666,36 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f ); } + static DeprecationIssue checkDelayClusterStateRecoverySettings(final Settings settings, + final PluginsAndModules pluginsAndModules, + final ClusterState clusterState, + final XPackLicenseState licenseState) { + List> deprecatedSettings = new ArrayList<>(); + deprecatedSettings.add(GatewayService.EXPECTED_NODES_SETTING); + deprecatedSettings.add(GatewayService.EXPECTED_MASTER_NODES_SETTING); + deprecatedSettings.add(GatewayService.RECOVER_AFTER_NODES_SETTING); + deprecatedSettings.add(GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING); + List> existingSettings = + deprecatedSettings.stream().filter(deprecatedSetting -> deprecatedSetting.exists(settings)).collect(Collectors.toList()); + if (existingSettings.isEmpty()) { + return null; + } + final String settingNames = existingSettings.stream().map(Setting::getKey).collect(Collectors.joining(",")); + final String message = String.format( + Locale.ROOT, + "cannot use properties related to delaying cluster state recovery after a majority of master nodes have joined because " + + "they have been deprecated and will be removed in the next major version", + settingNames + ); + final String details = String.format( + Locale.ROOT, + "cannot use properties [%s] because they have been deprecated and will be removed in the next major version", + settingNames + ); + final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes"; + return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null); + } + static DeprecationIssue checkFixedAutoQueueSizeThreadpool(final Settings settings, final PluginsAndModules pluginsAndModules, final ClusterState clusterState, @@ -769,9 +800,9 @@ static DeprecationIssue checkRolesCacheTTLSizeSetting(final Settings settings, } static DeprecationIssue checkMaxLocalStorageNodesSetting(final Settings settings, - final PluginsAndModules pluginsAndModules, - final ClusterState clusterState, - final XPackLicenseState licenseState) { + final PluginsAndModules pluginsAndModules, + final ClusterState clusterState, + final XPackLicenseState licenseState) { return checkRemovedSetting(settings, NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING, "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_node_changes", 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 3663802deb048..61de485cf4450 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 @@ -23,6 +23,7 @@ import org.elasticsearch.core.Set; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; +import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.jdk.JavaVersion; import org.elasticsearch.license.License; import org.elasticsearch.license.XPackLicenseState; @@ -961,6 +962,32 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() { assertThat(issues, empty()); } + public void testCheckDelayClusterStateRecoverySettings() { + Settings settings = Settings.builder() + .put(GatewayService.EXPECTED_NODES_SETTING.getKey(), randomIntBetween(2, 10)) + .put(GatewayService.EXPECTED_MASTER_NODES_SETTING.getKey(), randomIntBetween(2, 10)) + .put(GatewayService.RECOVER_AFTER_NODES_SETTING.getKey(), randomIntBetween(2, 10)) + .put(GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING.getKey(), randomIntBetween(2, 10)) + .build(); + final ClusterState clusterState = ClusterState.EMPTY_STATE; + final DeprecationIssue expectedIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL, + "cannot use properties related to delaying cluster state recovery after a majority of master nodes have joined because they " + + "have been deprecated and will be removed in the next major version", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes", + "cannot use properties [gateway.expected_nodes,gateway.expected_master_nodes,gateway.recover_after_nodes,gateway" + + ".recover_after_master_nodes] because they have been deprecated and will be removed in the next major version", + false, null + ); + final XPackLicenseState licenseState = mock(XPackLicenseState.class); + when(licenseState.getOperationMode()) + .thenReturn(randomValueOtherThanMany((m -> m.equals(License.OperationMode.BASIC) || m.equals(License.OperationMode.TRIAL)), + () -> randomFrom(License.OperationMode.values()))); + assertThat( + NodeDeprecationChecks.checkDelayClusterStateRecoverySettings(settings, null, clusterState, licenseState), + equalTo(expectedIssue) + ); + } + public void testCheckFixedAutoQueueSizeThreadpool() { String settingKey = "thread_pool.search.min_queue_size"; String settingValue = ""; @@ -1123,5 +1150,4 @@ public void testCheckMaxLocalStorageNodesSetting() { String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_node_changes"; checkSimpleSetting(settingKey, settingValue, url, NodeDeprecationChecks::checkMaxLocalStorageNodesSetting); } - }