Skip to content

Commit

Permalink
[7.x] Add deprecation info API entries for deprecated monitoring sett…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaiera committed Oct 20, 2021
1 parent 533d822 commit eac6fa1
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkRolesCacheTTLSizeSetting,
NodeDeprecationChecks::checkMaxLocalStorageNodesSetting,
NodeDeprecationChecks::checkSamlNameIdFormatSetting,
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,
NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting,
NodeDeprecationChecks::checkExporterUseIngestPipelineSettings,
NodeDeprecationChecks::checkExporterPipelineMasterTimeoutSetting,
NodeDeprecationChecks::checkExporterCreateLegacyTemplateSetting
)
).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,4 +987,62 @@ static DeprecationIssue checkSamlNameIdFormatSetting(final Settings settings,
return new DeprecationIssue(DeprecationIssue.Level.WARNING, message, url, details, false, 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,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return deprecatedAffixSetting(
Setting.affixKeySetting("xpack.monitoring.exporters.","use_ingest", key -> Setting.boolSetting(key, true)),
"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,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return deprecatedAffixSetting(
Setting.affixKeySetting("xpack.monitoring.exporters.","index.pipeline.master_timeout",
(key) -> Setting.timeSetting(key, TimeValue.MINUS_ONE)),
"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,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return deprecatedAffixSetting(
Setting.affixKeySetting("xpack.monitoring.exporters.","index.template.create_legacy_templates",
(key) -> Setting.boolSetting(key, true)),
"Remove the following settings from elasticsearch.yml: [%s]",
"https://ela.st/es-deprecation-7-monitoring-exporter-create-legacy-template-setting",
DeprecationIssue.Level.WARNING,
settings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.core.Set;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.gateway.GatewayService;
Expand Down Expand Up @@ -1453,4 +1454,63 @@ public void testCheckSamlNameIdFormatSetting() {
equalTo(expectedIssue)
);
}

public void testExporterUseIngestPipelineSettings() {
Settings settings = Settings.builder()
.put("xpack.monitoring.exporters.test.use_ingest", true)
.build();

List<DeprecationIssue> issues = Collections.singletonList(
NodeDeprecationChecks.checkExporterUseIngestPipelineSettings(settings, null, null, 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 = Collections.singletonList(
NodeDeprecationChecks.checkExporterPipelineMasterTimeoutSetting(settings, null, null, 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 = Collections.singletonList(
NodeDeprecationChecks.checkExporterCreateLegacyTemplateSetting(settings, null, null, 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)));
}
}

0 comments on commit eac6fa1

Please sign in to comment.