Browse Source

Add deprecation info API entries for deprecated monitoring settings (#78799)

Recently we have deprecated a number of settings in monitoring. These settings should be represented in the deprecation info API. This PR will be backported with some minor changes to the 7.x branch so that we can start the deprecation process in that release cycle.
James Baiera 4 years ago
parent
commit
ceaf53cf9e

+ 0 - 2
docs/reference/migration/migrate_8_0.asciidoc

@@ -25,7 +25,6 @@ coming[8.0.0]
 * <<breaking_80_ingest_changes>>
 * <<breaking_80_java_changes>>
 * <<breaking_80_mappings_changes>>
-* <<breaking_80_monitoring_changes>>
 * <<breaking_80_network_changes>>
 * <<breaking_80_node_changes>>
 * <<breaking_80_packaging_changes>>
@@ -128,7 +127,6 @@ include::migrate_8_0/indices.asciidoc[]
 include::migrate_8_0/ingest.asciidoc[]
 include::migrate_8_0/java.asciidoc[]
 include::migrate_8_0/mappings.asciidoc[]
-include::migrate_8_0/monitoring.asciidoc[]
 include::migrate_8_0/network.asciidoc[]
 include::migrate_8_0/node.asciidoc[]
 include::migrate_8_0/packaging.asciidoc[]

+ 0 - 47
docs/reference/migration/migrate_8_0/monitoring.asciidoc

@@ -1,47 +0,0 @@
-[discrete]
-[[breaking_80_monitoring_changes]]
-=== Monitoring changes
-
-//NOTE: The notable-breaking-changes tagged regions are re-used in the
-//Installation and Upgrade Guide
-
-//tag::notable-breaking-changes[]
-.The `use_ingest` setting on Monitoring exporter configurations has been removed.
-[%collapsible]
-====
-*Details* +
-The `xpack.monitoring.exporters.*.use_ingest` property was deprecated in 7.16.0 and
-has been removed. This parameter controlled the creation of pipelines for monitoring
-indices that previously had no function.
-
-*Impact* +
-Discontinue the use of the `xpack.monitoring.exporters.*.use_ingest` setting.
-====
-
-.The `index.pipeline.master_timeout` setting on Monitoring HTTP exporter configurations has been removed.
-[%collapsible]
-====
-*Details* +
-The `xpack.monitoring.exporters.*.index.pipeline.master_timeout` property was
-deprecated in 7.16.0. This parameter set the timeout when waiting for the remote
-Monitoring cluster to create pipelines. Those pipelines for monitoring indices previously
-had no function and are now removed in 8.0.0.
-
-*Impact* +
-Discontinue the use of the `xpack.monitoring.exporters.*.index.pipeline.master_timeout` setting.
-====
-
-.The `index.template.create_legacy_templates` setting on Monitoring HTTP exporter configurations has been removed.
-[%collapsible]
-====
-*Details* +
-The `xpack.monitoring.exporters.*.index.template.create_legacy_templates` property was
-deprecated in 7.16.0. This parameter instructed the exporter to install the previous version
-of monitoring templates on the monitoring cluster. These older templates were meant to assist
-in transitioning to the current monitoring data format. They are currently empty and are no
-longer of any use.
-
-*Impact* +
-Discontinue the use of the `xpack.monitoring.exporters.*.index.template.create_legacy_templates` setting.
-====
-//end::notable-breaking-changes[]

+ 1 - 1
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/MonitoringDeprecatedSettings.java → x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/MonitoringDeprecatedSettings.java

@@ -5,7 +5,7 @@
  * 2.0.
  */
 
-package org.elasticsearch.xpack.monitoring;
+package org.elasticsearch.xpack.core.monitoring;
 
 import org.elasticsearch.common.settings.Setting;
 import org.elasticsearch.common.settings.Setting.Property;

+ 4 - 1
x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

@@ -45,7 +45,10 @@ public class DeprecationChecks {
     static List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS = List.of(
         NodeDeprecationChecks::checkSharedDataPathSetting,
         NodeDeprecationChecks::checkReservedPrefixedRealmNames,
-        NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting
+        NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting,
+        NodeDeprecationChecks::checkExporterUseIngestPipelineSettings,
+        NodeDeprecationChecks::checkExporterPipelineMasterTimeoutSetting,
+        NodeDeprecationChecks::checkExporterCreateLegacyTemplateSetting
     );
 
     static List<Function<IndexMetadata, DeprecationIssue>> INDEX_SETTINGS_CHECKS = List.of(

+ 46 - 0
x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

@@ -13,10 +13,12 @@ import org.elasticsearch.common.settings.Setting;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
 import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
+import org.elasticsearch.xpack.core.monitoring.MonitoringDeprecatedSettings;
 import org.elasticsearch.xpack.core.security.authc.RealmConfig;
 import org.elasticsearch.xpack.core.security.authc.RealmSettings;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -93,4 +95,48 @@ public class NodeDeprecationChecks {
 
         return null;
     }
+
+    private static DeprecationIssue deprecatedAffixSetting(Setting.AffixSetting<?> deprecatedAffixSetting, String detailPattern,
+                                                           String url, DeprecationIssue.Level warningLevel, Settings settings) {
+        List<Setting<?>> deprecatedConcreteSettings = deprecatedAffixSetting.getAllConcreteSettings(settings)
+            .sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList());
+
+        if (deprecatedConcreteSettings.isEmpty()) {
+            return null;
+        }
+
+        final String concatSettingNames = deprecatedConcreteSettings.stream().map(Setting::getKey).collect(Collectors.joining(","));
+        final String message = String.format(
+            Locale.ROOT,
+            "The [%s] settings are deprecated and will be removed after 8.0",
+            concatSettingNames
+        );
+        final String details = String.format(Locale.ROOT, detailPattern, concatSettingNames);
+
+        return new DeprecationIssue(warningLevel, message, url, details, false, null);
+    }
+
+    static DeprecationIssue checkExporterUseIngestPipelineSettings(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return deprecatedAffixSetting(MonitoringDeprecatedSettings.USE_INGEST_PIPELINE_SETTING,
+            "Remove the following settings from elasticsearch.yml: [%s]",
+            "https://ela.st/es-deprecation-7-monitoring-exporter-use-ingest-setting",
+            DeprecationIssue.Level.WARNING,
+            settings);
+    }
+
+    static DeprecationIssue checkExporterPipelineMasterTimeoutSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return deprecatedAffixSetting(MonitoringDeprecatedSettings.PIPELINE_CHECK_TIMEOUT_SETTING,
+            "Remove the following settings from elasticsearch.yml: [%s]",
+            "https://ela.st/es-deprecation-7-monitoring-exporter-pipeline-timeout-setting",
+            DeprecationIssue.Level.WARNING,
+            settings);
+    }
+
+    static DeprecationIssue checkExporterCreateLegacyTemplateSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
+        return deprecatedAffixSetting(MonitoringDeprecatedSettings.TEMPLATE_CREATE_LEGACY_VERSIONS_SETTING,
+            "Remove the following settings from elasticsearch.yml: [%s]",
+            "https://ela.st/es-deprecation-7-monitoring-exporter-create-legacy-template-setting",
+            DeprecationIssue.Level.WARNING,
+            settings);
+    }
 }

+ 54 - 0
x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

@@ -11,6 +11,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider
 import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.settings.Setting;
 import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.core.TimeValue;
 import org.elasticsearch.env.Environment;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
@@ -138,4 +139,57 @@ public class NodeDeprecationChecksTests extends ESTestCase {
                     " Discontinue use of this setting.",
                 false, null)));
     }
+
+    public void testExporterUseIngestPipelineSettings() {
+        Settings settings = Settings.builder()
+            .put("xpack.monitoring.exporters.test.use_ingest", true)
+            .build();
+
+        List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
+
+        final String expectedUrl =
+            "https://ela.st/es-deprecation-7-monitoring-exporter-use-ingest-setting";
+        assertThat(issues, hasItem(
+            new DeprecationIssue(DeprecationIssue.Level.WARNING,
+                "The [xpack.monitoring.exporters.test.use_ingest] settings are deprecated and will be removed after 8.0",
+                expectedUrl,
+                "Remove the following settings from elasticsearch.yml: [xpack.monitoring.exporters.test.use_ingest]",
+                false, null)));
+    }
+
+    public void testExporterPipelineMasterTimeoutSetting() {
+        Settings settings = Settings.builder()
+            .put("xpack.monitoring.exporters.test.index.pipeline.master_timeout", TimeValue.timeValueSeconds(10))
+            .build();
+
+        List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
+
+        final String expectedUrl =
+            "https://ela.st/es-deprecation-7-monitoring-exporter-pipeline-timeout-setting";
+        assertThat(issues, hasItem(
+            new DeprecationIssue(DeprecationIssue.Level.WARNING,
+                "The [xpack.monitoring.exporters.test.index.pipeline.master_timeout] settings are deprecated and will be removed after 8.0",
+                expectedUrl,
+                "Remove the following settings from elasticsearch.yml: [xpack.monitoring.exporters.test.index.pipeline.master_timeout]",
+                false, null)));
+    }
+
+    public void testExporterCreateLegacyTemplateSetting() {
+        Settings settings = Settings.builder()
+            .put("xpack.monitoring.exporters.test.index.template.create_legacy_templates", true)
+            .build();
+
+        List<DeprecationIssue> issues = DeprecationChecks.filterChecks(NODE_SETTINGS_CHECKS, c -> c.apply(settings, null));
+
+        final String expectedUrl =
+            "https://ela.st/es-deprecation-7-monitoring-exporter-create-legacy-template-setting";
+        assertThat(issues, hasItem(
+            new DeprecationIssue(DeprecationIssue.Level.WARNING,
+                "The [xpack.monitoring.exporters.test.index.template.create_legacy_templates] settings are deprecated and will be " +
+                    "removed after 8.0",
+                expectedUrl,
+                "Remove the following settings from elasticsearch.yml: " +
+                    "[xpack.monitoring.exporters.test.index.template.create_legacy_templates]",
+                false, null)));
+    }
 }

+ 1 - 0
x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/Monitoring.java

@@ -37,6 +37,7 @@ import org.elasticsearch.xcontent.NamedXContentRegistry;
 import org.elasticsearch.xpack.core.XPackPlugin;
 import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction;
 import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;
+import org.elasticsearch.xpack.core.monitoring.MonitoringDeprecatedSettings;
 import org.elasticsearch.xpack.core.monitoring.MonitoringField;
 import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkAction;
 import org.elasticsearch.xpack.core.monitoring.action.MonitoringMigrateAlertsAction;