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 aff4688d76290..93057e92b9a21 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::checkFixedAutoQueueSizeThreadpool, NodeDeprecationChecks::checkJoinTimeoutSetting, NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting, NodeDeprecationChecks::checkClusterRoutingRequireSetting, 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 cd66039a86033..876d4f3fa7b27 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 @@ -665,6 +665,42 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f ); } + static DeprecationIssue checkFixedAutoQueueSizeThreadpool(final Settings settings, + final PluginsAndModules pluginsAndModules, + final ClusterState clusterState, + final XPackLicenseState licenseState) { + List> deprecatedSettings = new ArrayList<>(); + deprecatedSettings.add(Setting.intSetting("thread_pool.search.min_queue_size", 1, Setting.Property.Deprecated)); + deprecatedSettings.add(Setting.intSetting("thread_pool.search.max_queue_size", 1, Setting.Property.Deprecated)); + deprecatedSettings.add(Setting.intSetting("thread_pool.search.auto_queue_frame_size", 1, Setting.Property.Deprecated)); + deprecatedSettings.add(Setting.intSetting("thread_pool.search.target_response_time", 1, Setting.Property.Deprecated)); + deprecatedSettings.add(Setting.intSetting("thread_pool.search_throttled.min_queue_size", 1, Setting.Property.Deprecated)); + deprecatedSettings.add(Setting.intSetting("thread_pool.search_throttled.max_queue_size", 1, Setting.Property.Deprecated)); + deprecatedSettings.add(Setting.intSetting("thread_pool.search_throttled.auto_queue_frame_size", 1, Setting.Property.Deprecated)); + deprecatedSettings.add(Setting.intSetting("thread_pool.search_throttled.target_response_time", 1, Setting.Property.Deprecated)); + 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 [%s] because fixed_auto_queue_size threadpool type has been deprecated and will be removed in the next" + + " major version", + settingNames + ); + final String details = String.format( + Locale.ROOT, + "cannot use properties [%s] because fixed_auto_queue_size threadpool type has 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_threadpool_changes"; + return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null); + } + static DeprecationIssue checkClusterRoutingRequireSetting(final Settings settings, final PluginsAndModules pluginsAndModules, final ClusterState clusterState, 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 992f9c4f5e54b..3663802deb048 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 @@ -961,6 +961,44 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() { assertThat(issues, empty()); } + public void testCheckFixedAutoQueueSizeThreadpool() { + String settingKey = "thread_pool.search.min_queue_size"; + String settingValue = ""; + Settings settings = Settings.builder() + .put("thread_pool.search.min_queue_size", randomIntBetween(30, 100)) + .put("thread_pool.search.max_queue_size", randomIntBetween(1, 25)) + .put("thread_pool.search.auto_queue_frame_size", randomIntBetween(1, 25)) + .put("thread_pool.search.target_response_time", randomIntBetween(1, 25)) + .put("thread_pool.search_throttled.min_queue_size", randomIntBetween(30, 100)) + .put("thread_pool.search_throttled.max_queue_size", randomIntBetween(1, 25)) + .put("thread_pool.search_throttled.auto_queue_frame_size", randomIntBetween(1, 25)) + .put("thread_pool.search_throttled.target_response_time", randomIntBetween(1, 25)) + .build(); + final ClusterState clusterState = ClusterState.EMPTY_STATE; + final DeprecationIssue expectedIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL, + "cannot use properties [thread_pool.search.min_queue_size,thread_pool.search.max_queue_size,thread_pool.search" + + ".auto_queue_frame_size,thread_pool.search.target_response_time,thread_pool.search_throttled.min_queue_size," + + "thread_pool.search_throttled.max_queue_size,thread_pool.search_throttled.auto_queue_frame_size,thread_pool" + + ".search_throttled.target_response_time] because fixed_auto_queue_size threadpool type has 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_threadpool_changes", + "cannot use properties [thread_pool.search.min_queue_size,thread_pool.search.max_queue_size,thread_pool.search" + + ".auto_queue_frame_size,thread_pool.search.target_response_time,thread_pool.search_throttled.min_queue_size," + + "thread_pool.search_throttled.max_queue_size,thread_pool.search_throttled.auto_queue_frame_size,thread_pool" + + ".search_throttled.target_response_time] because fixed_auto_queue_size threadpool type has 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.checkFixedAutoQueueSizeThreadpool(settings, null, clusterState, licenseState), + equalTo(expectedIssue) + ); + } + public void testTierAllocationSettings() { String settingValue = DataTier.DATA_HOT; final Settings settings = settings(Version.CURRENT)