From e5e87e5d53be6c48a9e9c9fd13988f24e3f64339 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 23 Aug 2019 14:35:14 -0400 Subject: [PATCH 1/5] Add deprecation check for processors The processors setting is deprecated. This commit adds a deprecation check for the use of the processors setting. --- .../xpack/deprecation/DeprecationChecks.java | 2 +- .../deprecation/NodeDeprecationChecks.java | 32 +++++++++++++++ .../NodeDeprecationChecksTests.java | 41 +++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java create mode 100644 x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java 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 dfb344f829da8..4bdccc267fb88 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 @@ -41,7 +41,7 @@ private DeprecationChecks() { static List> NODE_SETTINGS_CHECKS = Collections.unmodifiableList(Arrays.asList( - // STUB + NodeDeprecationChecks::checkProcessors )); static List> INDEX_SETTINGS_CHECKS = 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 new file mode 100644 index 0000000000000..8f738590f31b6 --- /dev/null +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -0,0 +1,32 @@ +package org.elasticsearch.xpack.deprecation; + +import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; + +import java.util.Locale; + +class NodeDeprecationChecks { + + static DeprecationIssue checkProcessors(final Settings settings , final PluginsAndModules pluginsAndModules) { + if (EsExecutors.PROCESSORS_SETTING.exists(settings) == false) { + return null; + } + final String message = String.format( + Locale.ROOT, + "setting [%s] is deprecated in favor of setting [%s]", + EsExecutors.PROCESSORS_SETTING.getKey(), + EsExecutors.NODE_PROCESSORS_SETTING.getKey()); + final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html#remove-processors"; + final String details = String.format( + Locale.ROOT, + "the setting [%s] is currently set to [%d], instead set [%s] to [%d]", + EsExecutors.PROCESSORS_SETTING.getKey(), + EsExecutors.PROCESSORS_SETTING.get(settings), + EsExecutors.NODE_PROCESSORS_SETTING.getKey(), + EsExecutors.PROCESSORS_SETTING.get(settings)); + return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details); + } + +} 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 new file mode 100644 index 0000000000000..a90ecb5e01ed8 --- /dev/null +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -0,0 +1,41 @@ +package org.elasticsearch.xpack.deprecation; + +import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.empty; + +public class NodeDeprecationChecksTests extends ESTestCase { + + public void testCheckProcessors() { + final int processors = randomIntBetween(1, 4); + final Settings settings = Settings.builder().put(EsExecutors.PROCESSORS_SETTING.getKey(), processors).build(); + final PluginsAndModules pluginsAndModules = new PluginsAndModules(Collections.emptyList(), Collections.emptyList()); + final List issues = + DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings, pluginsAndModules)); + final DeprecationIssue expected = new DeprecationIssue( + DeprecationIssue.Level.CRITICAL, + "setting [processors] is deprecated in favor of setting [node.processors]", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html#remove-processors", + "the setting [processors] is currently set to [" + processors + "], instead set [node.processors] to [" + processors + "]"); + assertThat(issues, contains(expected)); + assertSettingDeprecationsAndWarnings(new Setting[]{EsExecutors.PROCESSORS_SETTING}); + } + + public void testCheckProcessorsNotSet() { + final Settings settings = Settings.EMPTY; + final PluginsAndModules pluginsAndModules = new PluginsAndModules(Collections.emptyList(), Collections.emptyList()); + final List issues = + DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings, pluginsAndModules)); + assertThat(issues, empty()); + } + +} From 69f79e0481a6ca3587f7091a5bf0ed7070f79a74 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 23 Aug 2019 14:49:17 -0400 Subject: [PATCH 2/5] License headers --- .../xpack/deprecation/NodeDeprecationChecks.java | 6 ++++++ .../xpack/deprecation/NodeDeprecationChecksTests.java | 6 ++++++ 2 files changed, 12 insertions(+) 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 8f738590f31b6..af9e10e1d6be1 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 @@ -1,3 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + package org.elasticsearch.xpack.deprecation; import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules; 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 a90ecb5e01ed8..1af9595b82470 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 @@ -1,3 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + package org.elasticsearch.xpack.deprecation; import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules; From d63271e65a08fd4f4c9f26295e580ce4fac55313 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 23 Aug 2019 18:30:46 -0400 Subject: [PATCH 3/5] Use permalink --- .../elasticsearch/xpack/deprecation/NodeDeprecationChecks.java | 3 ++- .../xpack/deprecation/NodeDeprecationChecksTests.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 af9e10e1d6be1..5f27c388a5634 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,7 +24,8 @@ static DeprecationIssue checkProcessors(final Settings settings , final PluginsA "setting [%s] is deprecated in favor of setting [%s]", EsExecutors.PROCESSORS_SETTING.getKey(), EsExecutors.NODE_PROCESSORS_SETTING.getKey()); - final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html#remove-processors"; + final String url = + "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking_74_plugin_changes.html#breaking_74_settings_changes"; final String details = String.format( Locale.ROOT, "the setting [%s] is currently set to [%d], instead set [%s] to [%d]", 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 1af9595b82470..ea53cee8815d4 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,7 +30,7 @@ public void testCheckProcessors() { final DeprecationIssue expected = new DeprecationIssue( DeprecationIssue.Level.CRITICAL, "setting [processors] is deprecated in favor of setting [node.processors]", - "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-8.0.html#remove-processors", + "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking_74_plugin_changes.html#breaking_74_settings_changes", "the setting [processors] is currently set to [" + processors + "], instead set [node.processors] to [" + processors + "]"); assertThat(issues, contains(expected)); assertSettingDeprecationsAndWarnings(new Setting[]{EsExecutors.PROCESSORS_SETTING}); From e199d128db8b3279cda011ae095051163c5a4a85 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 23 Aug 2019 18:51:16 -0400 Subject: [PATCH 4/5] A better link --- .../elasticsearch/xpack/deprecation/NodeDeprecationChecks.java | 2 +- .../xpack/deprecation/NodeDeprecationChecksTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 5f27c388a5634..85660d076e913 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,7 +25,7 @@ static DeprecationIssue checkProcessors(final Settings settings , final PluginsA EsExecutors.PROCESSORS_SETTING.getKey(), EsExecutors.NODE_PROCESSORS_SETTING.getKey()); final String url = - "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking_74_plugin_changes.html#breaking_74_settings_changes"; + "https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.4.html#deprecate-processors"; final String details = String.format( Locale.ROOT, "the setting [%s] is currently set to [%d], instead set [%s] to [%d]", 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 ea53cee8815d4..272513611626b 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,7 +30,7 @@ public void testCheckProcessors() { final DeprecationIssue expected = new DeprecationIssue( DeprecationIssue.Level.CRITICAL, "setting [processors] is deprecated in favor of setting [node.processors]", - "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking_74_plugin_changes.html#breaking_74_settings_changes", + "https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.4.html#deprecate-processors", "the setting [processors] is currently set to [" + processors + "], instead set [node.processors] to [" + processors + "]"); assertThat(issues, contains(expected)); assertSettingDeprecationsAndWarnings(new Setting[]{EsExecutors.PROCESSORS_SETTING}); From 8ad9c7c8493d24044b06500e6672da4f9fe51fce Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 23 Aug 2019 18:53:06 -0400 Subject: [PATCH 5/5] Fix link --- .../elasticsearch/xpack/deprecation/NodeDeprecationChecks.java | 2 +- .../xpack/deprecation/NodeDeprecationChecksTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 85660d076e913..835026183f06c 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,7 +25,7 @@ static DeprecationIssue checkProcessors(final Settings settings , final PluginsA EsExecutors.PROCESSORS_SETTING.getKey(), EsExecutors.NODE_PROCESSORS_SETTING.getKey()); final String url = - "https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.4.html#deprecate-processors"; + "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking-changes-7.4.html#deprecate-processors"; final String details = String.format( Locale.ROOT, "the setting [%s] is currently set to [%d], instead set [%s] to [%d]", 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 272513611626b..9c5b67ee1d0d2 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,7 +30,7 @@ public void testCheckProcessors() { final DeprecationIssue expected = new DeprecationIssue( DeprecationIssue.Level.CRITICAL, "setting [processors] is deprecated in favor of setting [node.processors]", - "https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.4.html#deprecate-processors", + "https://www.elastic.co/guide/en/elasticsearch/reference/7.4/breaking-changes-7.4.html#deprecate-processors", "the setting [processors] is currently set to [" + processors + "], instead set [node.processors] to [" + processors + "]"); assertThat(issues, contains(expected)); assertSettingDeprecationsAndWarnings(new Setting[]{EsExecutors.PROCESSORS_SETTING});