From c512d19926b2f4e08c798ff821510b929176ce4d Mon Sep 17 00:00:00 2001 From: pgomulka Date: Mon, 22 Nov 2021 12:47:40 +0100 Subject: [PATCH 1/3] Change setting's deprecation message wording depending on whether a message is critical or warning a message shoudl indicate to check breaking changes documentation (critical level) or deprecation changes documentation (warn level) relates #79666 --- .../common/settings/Setting.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/settings/Setting.java b/server/src/main/java/org/elasticsearch/common/settings/Setting.java index 23f5ffcbef56a..7625b722689b0 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/Setting.java +++ b/server/src/main/java/org/elasticsearch/common/settings/Setting.java @@ -75,6 +75,11 @@ * */ public class Setting implements ToXContentObject { + private static final String DEPRECATED_MESSAGE_TEMPLATE = + "[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " + + "See the %s changes documentation for the next major version."; + private static final String DEPRECATED_WARN_MESSAGE = String.format(Locale.ROOT, DEPRECATED_MESSAGE_TEMPLATE, "deprecation"); + private static final String DEPRECATED_CRITICAL_MESSAGE = String.format(Locale.ROOT, DEPRECATED_MESSAGE_TEMPLATE, "breaking"); public enum Property { /** @@ -580,12 +585,20 @@ void checkDeprecation(Settings settings) { final String key = getKey(); List skipTheseDeprecations = settings.getAsList("deprecation.skip_deprecated_settings"); if (Regex.simpleMatch(skipTheseDeprecations, key) == false) { - String message = "[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " - + "See the breaking changes documentation for the next major version."; if (this.isDeprecatedWarningOnly()) { - Settings.DeprecationLoggerHolder.deprecationLogger.warn(DeprecationCategory.SETTINGS, key, message, key); + Settings.DeprecationLoggerHolder.deprecationLogger.warn( + DeprecationCategory.SETTINGS, + key, + DEPRECATED_WARN_MESSAGE, + key + ); } else { - Settings.DeprecationLoggerHolder.deprecationLogger.critical(DeprecationCategory.SETTINGS, key, message, key); + Settings.DeprecationLoggerHolder.deprecationLogger.critical( + DeprecationCategory.SETTINGS, + key, + DEPRECATED_CRITICAL_MESSAGE, + key + ); } } } From 5ed157834187936071ff5e8bd418bb13ce277b87 Mon Sep 17 00:00:00 2001 From: pgomulka Date: Mon, 22 Nov 2021 14:50:27 +0100 Subject: [PATCH 2/3] fix tests --- .../collecting-monitoring-data.asciidoc | 2 +- .../configuring-metricbeat.asciidoc | 62 +++++++++---------- .../restore-snapshot.asciidoc | 4 +- .../enrich/EnrichStatsCollectorTests.java | 2 +- .../monitoring/MonitoringServiceTests.java | 4 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/docs/reference/monitoring/collecting-monitoring-data.asciidoc b/docs/reference/monitoring/collecting-monitoring-data.asciidoc index adc0f166c89a0..0ab95e99977ea 100644 --- a/docs/reference/monitoring/collecting-monitoring-data.asciidoc +++ b/docs/reference/monitoring/collecting-monitoring-data.asciidoc @@ -55,7 +55,7 @@ PUT _cluster/settings } } ---------------------------------- -// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.] +// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the deprecation changes documentation for the next major version.] Alternatively, you can enable this setting in {kib}. In the side navigation, click *Monitoring*. If data collection is disabled, you are prompted to turn it diff --git a/docs/reference/monitoring/configuring-metricbeat.asciidoc b/docs/reference/monitoring/configuring-metricbeat.asciidoc index 4bdaabe1e80d5..052eac1b7f261 100644 --- a/docs/reference/monitoring/configuring-metricbeat.asciidoc +++ b/docs/reference/monitoring/configuring-metricbeat.asciidoc @@ -7,9 +7,9 @@ Collecting monitoring data with {metricbeat} ++++ -In 6.5 and later, you can use {metricbeat} to collect data about {es} -and ship it to the monitoring cluster, rather than routing it through exporters -as described in <>. +In 6.5 and later, you can use {metricbeat} to collect data about {es} +and ship it to the monitoring cluster, rather than routing it through exporters +as described in <>. image::monitoring/images/metricbeat.png[Example monitoring architecture] @@ -18,7 +18,7 @@ image::monitoring/images/metricbeat.png[Example monitoring architecture] -- // tag::enable-collection[] Set `xpack.monitoring.collection.enabled` to `true` on the -production cluster. By default, it is disabled (`false`). +production cluster. By default, it is disabled (`false`). You can use the following APIs to review and change this setting: @@ -36,9 +36,9 @@ PUT _cluster/settings } } ---------------------------------- -// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.] +// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the deprecation changes documentation for the next major version.] -If {es} {security-features} are enabled, you must have `monitor` cluster privileges to +If {es} {security-features} are enabled, you must have `monitor` cluster privileges to view the cluster settings and `manage` cluster privileges to change them. // end::enable-collection[] @@ -69,8 +69,8 @@ in the `modules.d` directory, run the following command: metricbeat modules enable elasticsearch-xpack ---------------------------------------------------------------------- -For more information, refer to -{metricbeat-ref}/metricbeat-module-elasticsearch.html[{es} module]. +For more information, refer to +{metricbeat-ref}/metricbeat-module-elasticsearch.html[{es} module]. -- . Configure the {es} module in {metricbeat} on each {es} node. @@ -107,15 +107,15 @@ configure the endpoint in the `hosts` list not to direct requests to the dedicated master nodes. If Elastic {security-features} are enabled, you must also provide a user ID -and password so that {metricbeat} can collect metrics successfully: +and password so that {metricbeat} can collect metrics successfully: .. Create a user on the production cluster that has the -<>. +<>. Alternatively, use the <>. .. Add the `username` and `password` settings to the {es} module configuration -file. +file. .. If TLS is enabled on the HTTP layer of your {es} cluster, you must either use https as the URL scheme in the `hosts` setting or add the `ssl.enabled: true` setting. Depending on the TLS configuration of your {es} cluster, you might also need to specify {metricbeat-ref}/configuration-ssl.html[additional ssl.*] settings. -- @@ -138,13 +138,13 @@ metricbeat modules disable system . Identify where to send the monitoring data. + -- -TIP: In production environments, we strongly recommend using a separate cluster -(referred to as the _monitoring cluster_) to store the data. Using a separate -monitoring cluster prevents production cluster outages from impacting your -ability to access your monitoring data. It also prevents monitoring activities +TIP: In production environments, we strongly recommend using a separate cluster +(referred to as the _monitoring cluster_) to store the data. Using a separate +monitoring cluster prevents production cluster outages from impacting your +ability to access your monitoring data. It also prevents monitoring activities from impacting the performance of your production cluster. -For example, specify the {es} output information in the {metricbeat} +For example, specify the {es} output information in the {metricbeat} configuration file (`metricbeat.yml`): [source,yaml] @@ -152,45 +152,45 @@ configuration file (`metricbeat.yml`): output.elasticsearch: # Array of hosts to connect to. hosts: ["http://es-mon-1:9200", "http://es-mon-2:9200"] <1> - + # Optional protocol and basic auth credentials. #protocol: "https" #username: "elastic" #password: "changeme" ---------------------------------- -<1> In this example, the data is stored on a monitoring cluster with nodes -`es-mon-1` and `es-mon-2`. +<1> In this example, the data is stored on a monitoring cluster with nodes +`es-mon-1` and `es-mon-2`. If you configured the monitoring cluster to use encrypted communications, you must access it via HTTPS. For example, use a `hosts` setting like `https://es-mon-1:9200`. IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore the -cluster that stores the monitoring data must have at least one -<>. +cluster that stores the monitoring data must have at least one +<>. If {es} {security-features} are enabled on the monitoring cluster, you must -provide a valid user ID and password so that {metricbeat} can send metrics -successfully: +provide a valid user ID and password so that {metricbeat} can send metrics +successfully: -.. Create a user on the monitoring cluster that has the -<>. -Alternatively, use the +.. Create a user on the monitoring cluster that has the +<>. +Alternatively, use the <>. -.. Add the `username` and `password` settings to the {es} output information in +.. Add the `username` and `password` settings to the {es} output information in the {metricbeat} configuration file. -For more information about these configuration options, see +For more information about these configuration options, see {metricbeat-ref}/elasticsearch-output.html[Configure the {es} output]. -- -. {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}] on each node. +. {metricbeat-ref}/metricbeat-starting.html[Start {metricbeat}] on each node. . Disable the default collection of {es} monitoring metrics. + -- -Set `xpack.monitoring.elasticsearch.collection.enabled` to `false` on the +Set `xpack.monitoring.elasticsearch.collection.enabled` to `false` on the production cluster. You can use the following API to change this setting: @@ -211,4 +211,4 @@ privileges to view the cluster settings and `manage` cluster privileges to change them. -- -. {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}]. +. {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}]. diff --git a/docs/reference/snapshot-restore/restore-snapshot.asciidoc b/docs/reference/snapshot-restore/restore-snapshot.asciidoc index 82424091511e2..9ac395f2948ae 100644 --- a/docs/reference/snapshot-restore/restore-snapshot.asciidoc +++ b/docs/reference/snapshot-restore/restore-snapshot.asciidoc @@ -368,7 +368,7 @@ PUT _cluster/settings } } ---- -// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.] +// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the deprecation changes documentation for the next major version.] * Watcher + @@ -493,7 +493,7 @@ PUT _cluster/settings } } ---- -// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.] +// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the deprecation changes documentation for the next major version.] // TEST[s/true/false/] * Watcher diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java index 278c77fb8cc44..f762864b32916 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/monitoring/collector/enrich/EnrichStatsCollectorTests.java @@ -143,7 +143,7 @@ public void testDoCollect() throws Exception { assertWarnings( "[xpack.monitoring.collection.enrich.stats.timeout] setting was deprecated in Elasticsearch and will be removed " - + "in a future release! See the breaking changes documentation for the next major version." + + "in a future release! See the deprecation changes documentation for the next major version." ); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java index f5b86fc8784cb..5358b6f6be9dc 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringServiceTests.java @@ -141,9 +141,9 @@ public void testSkipExecution() throws Exception { assertThat(exporter.getExportsCount(), equalTo(1)); assertWarnings( "[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in " - + "a future release! See the breaking changes documentation for the next major version.", + + "a future release! See the deprecation changes documentation for the next major version.", "[xpack.monitoring.collection.interval] setting was deprecated in Elasticsearch and will be removed in " - + "a future release! See the breaking changes documentation for the next major version." + + "a future release! See the deprecation changes documentation for the next major version." ); } From 7f42961b577398267f7292c9f5146adec4f61f8d Mon Sep 17 00:00:00 2001 From: pgomulka Date: Thu, 9 Dec 2021 14:34:34 +0100 Subject: [PATCH 3/3] fix few tests --- docs/reference/monitoring/configuring-metricbeat.asciidoc | 2 +- .../src/main/java/org/elasticsearch/test/ESTestCase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/monitoring/configuring-metricbeat.asciidoc b/docs/reference/monitoring/configuring-metricbeat.asciidoc index 052eac1b7f261..d8aaba32beb38 100644 --- a/docs/reference/monitoring/configuring-metricbeat.asciidoc +++ b/docs/reference/monitoring/configuring-metricbeat.asciidoc @@ -204,7 +204,7 @@ PUT _cluster/settings } } ---------------------------------- -// TEST[warning:[xpack.monitoring.elasticsearch.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.] +// TEST[warning:[xpack.monitoring.elasticsearch.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the deprecation changes documentation for the next major version.] If {es} {security-features} are enabled, you must have `monitor` cluster privileges to view the cluster settings and `manage` cluster privileges diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index bfed9fa05460e..2641d979b588f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -489,7 +489,7 @@ protected final void assertSettingDeprecationsAndWarnings(final Setting[] set String warningMessage = String.format( Locale.ROOT, "[%s] setting was deprecated in Elasticsearch and will be " - + "removed in a future release! See the breaking changes documentation for the next major version.", + + "removed in a future release! See the deprecation changes documentation for the next major version.", setting.getKey() ); return new DeprecationWarning(