Skip to content

Commit 22b68e6

Browse files
authored
Deprecate single-tier allocation filtering settings (#76516)
Adding deprecation info API checks for the following properties that were removed in 8.0: cluster.routing.allocation.require._tier cluster.routing.allocation.include._tie; cluster.routing.allocation.exclude._tier index.routing.allocation.require._tier index.routing.allocation.include._tier index.routing.allocation.exclude._tier Relates #73074
1 parent dc7c4e1 commit 22b68e6

File tree

5 files changed

+240
-9
lines changed

5 files changed

+240
-9
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ private DeprecationChecks() {
9797
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
9898
NodeDeprecationChecks::checkSearchRemoteSettings,
9999
NodeDeprecationChecks::checkMonitoringExporterPassword,
100+
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,
101+
NodeDeprecationChecks::checkClusterRoutingRequireSetting,
102+
NodeDeprecationChecks::checkClusterRoutingIncludeSetting,
103+
NodeDeprecationChecks::checkClusterRoutingExcludeSetting,
100104
NodeDeprecationChecks::checkAcceptDefaultPasswordSetting,
101105
NodeDeprecationChecks::checkAcceptRolesCacheMaxSizeSetting,
102106
NodeDeprecationChecks::checkRolesCacheTTLSizeSetting,
@@ -117,6 +121,9 @@ private DeprecationChecks() {
117121
IndexDeprecationChecks::indexingSlowLogLevelSettingCheck,
118122
IndexDeprecationChecks::searchSlowLogLevelSettingCheck,
119123
IndexDeprecationChecks::storeTypeSettingCheck,
124+
IndexDeprecationChecks::checkIndexRoutingRequireSetting,
125+
IndexDeprecationChecks::checkIndexRoutingIncludeSetting,
126+
IndexDeprecationChecks::checkIndexRoutingExcludeSetting,
120127
IndexDeprecationChecks::checkGeoShapeMappings
121128
));
122129

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.cluster.metadata.MappingMetadata;
1515
import org.elasticsearch.common.joda.JodaDeprecationPatterns;
1616
import org.elasticsearch.common.settings.Setting;
17+
import org.elasticsearch.common.settings.Settings;
1718
import org.elasticsearch.index.IndexModule;
1819
import org.elasticsearch.index.IndexSettings;
1920
import org.elasticsearch.index.IndexingSlowLog;
@@ -34,6 +35,10 @@
3435
import java.util.function.Function;
3536
import java.util.stream.Collectors;
3637

38+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING;
39+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING;
40+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING;
41+
3742

3843
/**
3944
* Index-specific deprecation checks
@@ -320,6 +325,46 @@ static DeprecationIssue storeTypeSettingCheck(IndexMetadata indexMetadata) {
320325
return null;
321326
}
322327

328+
static DeprecationIssue checkRemovedSetting(final Settings settings,
329+
final Setting<?> removedSetting,
330+
final String url,
331+
DeprecationIssue.Level deprecationLevel) {
332+
if (removedSetting.exists(settings) == false) {
333+
return null;
334+
}
335+
final String removedSettingKey = removedSetting.getKey();
336+
final String value = removedSetting.get(settings).toString();
337+
final String message =
338+
String.format(Locale.ROOT, "setting [%s] is deprecated and will be removed in the next major version", removedSettingKey);
339+
final String details =
340+
String.format(Locale.ROOT, "the setting [%s] is currently set to [%s], remove this setting", removedSettingKey, value);
341+
return new DeprecationIssue(deprecationLevel, message, url, details, false, null);
342+
}
343+
344+
static DeprecationIssue checkIndexRoutingRequireSetting(IndexMetadata indexMetadata) {
345+
return checkRemovedSetting(indexMetadata.getSettings(),
346+
INDEX_ROUTING_REQUIRE_SETTING,
347+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
348+
DeprecationIssue.Level.CRITICAL
349+
);
350+
}
351+
352+
static DeprecationIssue checkIndexRoutingIncludeSetting(IndexMetadata indexMetadata) {
353+
return checkRemovedSetting(indexMetadata.getSettings(),
354+
INDEX_ROUTING_INCLUDE_SETTING,
355+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
356+
DeprecationIssue.Level.CRITICAL
357+
);
358+
}
359+
360+
static DeprecationIssue checkIndexRoutingExcludeSetting(IndexMetadata indexMetadata) {
361+
return checkRemovedSetting(indexMetadata.getSettings(),
362+
INDEX_ROUTING_EXCLUDE_SETTING,
363+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
364+
DeprecationIssue.Level.CRITICAL
365+
);
366+
}
367+
323368
protected static boolean isGeoShapeFieldWithDeprecatedParam(Map<?, ?> property) {
324369
return LegacyGeoShapeFieldMapper.CONTENT_TYPE.equals(property.get("type")) &&
325370
LegacyGeoShapeFieldMapper.DEPRECATED_PARAMETERS.stream().anyMatch(deprecatedParameter ->

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

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
import java.util.stream.Collectors;
5252

5353
import static org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING;
54+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_EXCLUDE_SETTING;
55+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_INCLUDE_SETTING;
56+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_REQUIRE_SETTING;
5457
import static org.elasticsearch.xpack.core.security.authc.RealmSettings.RESERVED_REALM_NAME_PREFIX;
5558

5659
class NodeDeprecationChecks {
@@ -649,32 +652,65 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
649652
);
650653
}
651654

652-
static DeprecationIssue checkAcceptDefaultPasswordSetting(final Settings settings,
653-
final PluginsAndModules pluginsAndModules,
654-
final ClusterState clusterState,
655-
final XPackLicenseState licenseState) {
655+
static DeprecationIssue checkClusterRoutingRequireSetting(final Settings settings,
656+
final PluginsAndModules pluginsAndModules,
657+
final ClusterState clusterState,
658+
final XPackLicenseState licenseState) {
656659
return checkRemovedSetting(settings,
657-
Setting.boolSetting(SecurityField.setting("authc.accept_default_password"),true, Setting.Property.Deprecated),
658-
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_security_changes",
660+
CLUSTER_ROUTING_REQUIRE_SETTING,
661+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
659662
DeprecationIssue.Level.CRITICAL
660663
);
661664
}
662665

663-
static DeprecationIssue checkAcceptRolesCacheMaxSizeSetting(final Settings settings,
666+
static DeprecationIssue checkClusterRoutingIncludeSetting(final Settings settings,
664667
final PluginsAndModules pluginsAndModules,
665668
final ClusterState clusterState,
666669
final XPackLicenseState licenseState) {
667670
return checkRemovedSetting(settings,
668-
Setting.intSetting(SecurityField.setting("authz.store.roles.index.cache.max_size"), 10000, Setting.Property.Deprecated),
671+
CLUSTER_ROUTING_INCLUDE_SETTING,
672+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
673+
DeprecationIssue.Level.CRITICAL
674+
);
675+
}
676+
677+
static DeprecationIssue checkClusterRoutingExcludeSetting(final Settings settings,
678+
final PluginsAndModules pluginsAndModules,
679+
final ClusterState clusterState,
680+
final XPackLicenseState licenseState) {
681+
return checkRemovedSetting(settings,
682+
CLUSTER_ROUTING_EXCLUDE_SETTING,
683+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
684+
DeprecationIssue.Level.CRITICAL
685+
);
686+
}
687+
688+
static DeprecationIssue checkAcceptDefaultPasswordSetting(final Settings settings,
689+
final PluginsAndModules pluginsAndModules,
690+
final ClusterState clusterState,
691+
final XPackLicenseState licenseState) {
692+
return checkRemovedSetting(settings,
693+
Setting.boolSetting(SecurityField.setting("authc.accept_default_password"),true, Setting.Property.Deprecated),
669694
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_security_changes",
670695
DeprecationIssue.Level.CRITICAL
671696
);
672697
}
673698

674-
static DeprecationIssue checkRolesCacheTTLSizeSetting(final Settings settings,
699+
static DeprecationIssue checkAcceptRolesCacheMaxSizeSetting(final Settings settings,
675700
final PluginsAndModules pluginsAndModules,
676701
final ClusterState clusterState,
677702
final XPackLicenseState licenseState) {
703+
return checkRemovedSetting(settings,
704+
Setting.intSetting(SecurityField.setting("authz.store.roles.index.cache.max_size"), 10000, Setting.Property.Deprecated),
705+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_security_changes",
706+
DeprecationIssue.Level.CRITICAL
707+
);
708+
}
709+
710+
static DeprecationIssue checkRolesCacheTTLSizeSetting(final Settings settings,
711+
final PluginsAndModules pluginsAndModules,
712+
final ClusterState clusterState,
713+
final XPackLicenseState licenseState) {
678714
return checkRemovedSetting(settings,
679715
Setting.timeSetting(SecurityField.setting("authz.store.roles.index.cache.ttl"), TimeValue.timeValueMinutes(20),
680716
Setting.Property.Deprecated),

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,27 @@
2424
import org.elasticsearch.index.mapper.FieldNamesFieldMapper;
2525
import org.elasticsearch.test.ESTestCase;
2626
import org.elasticsearch.test.VersionUtils;
27+
import org.elasticsearch.xpack.core.DataTier;
2728

2829
import java.io.IOException;
2930
import java.util.ArrayList;
3031
import java.util.Collections;
3132
import java.util.List;
33+
import java.util.Locale;
3234
import java.util.Map;
3335
import java.util.concurrent.atomic.AtomicInteger;
3436
import java.util.stream.Collectors;
3537
import java.util.stream.Stream;
3638

3739
import static java.util.Collections.singletonList;
3840
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
41+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING;
42+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING;
43+
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING;
3944
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTINGS_CHECKS;
4045
import static org.hamcrest.Matchers.containsInAnyOrder;
4146
import static org.hamcrest.Matchers.empty;
47+
import static org.hamcrest.Matchers.equalTo;
4248
import static org.hamcrest.Matchers.hasItem;
4349
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
4450

@@ -503,6 +509,72 @@ public void testSimpleFSSetting() {
503509
));
504510
}
505511

512+
public void testTierAllocationSettings() {
513+
String settingValue = DataTier.DATA_HOT;
514+
final Settings settings = settings(Version.CURRENT)
515+
.put(INDEX_ROUTING_REQUIRE_SETTING.getKey(), DataTier.DATA_HOT)
516+
.put(INDEX_ROUTING_INCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
517+
.put(INDEX_ROUTING_EXCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
518+
.build();
519+
final DeprecationIssue expectedRequireIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
520+
String.format(Locale.ROOT,
521+
"setting [%s] is deprecated and will be removed in the next major version",
522+
INDEX_ROUTING_REQUIRE_SETTING.getKey()),
523+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
524+
String.format(Locale.ROOT,
525+
"the setting [%s] is currently set to [%s], remove this setting",
526+
INDEX_ROUTING_REQUIRE_SETTING.getKey(),
527+
settingValue),
528+
false, null
529+
);
530+
final DeprecationIssue expectedIncludeIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
531+
String.format(Locale.ROOT,
532+
"setting [%s] is deprecated and will be removed in the next major version",
533+
INDEX_ROUTING_INCLUDE_SETTING.getKey()),
534+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
535+
String.format(Locale.ROOT,
536+
"the setting [%s] is currently set to [%s], remove this setting",
537+
INDEX_ROUTING_INCLUDE_SETTING.getKey(),
538+
settingValue),
539+
false, null
540+
);
541+
final DeprecationIssue expectedExcludeIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
542+
String.format(Locale.ROOT,
543+
"setting [%s] is deprecated and will be removed in the next major version",
544+
INDEX_ROUTING_EXCLUDE_SETTING.getKey()),
545+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
546+
String.format(Locale.ROOT,
547+
"the setting [%s] is currently set to [%s], remove this setting",
548+
INDEX_ROUTING_EXCLUDE_SETTING.getKey(),
549+
settingValue),
550+
false, null
551+
);
552+
553+
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
554+
assertThat(
555+
IndexDeprecationChecks.checkIndexRoutingRequireSetting(indexMetadata),
556+
equalTo(expectedRequireIssue)
557+
);
558+
assertThat(
559+
IndexDeprecationChecks.checkIndexRoutingIncludeSetting(indexMetadata),
560+
equalTo(expectedIncludeIssue)
561+
);
562+
assertThat(
563+
IndexDeprecationChecks.checkIndexRoutingExcludeSetting(indexMetadata),
564+
equalTo(expectedExcludeIssue)
565+
);
566+
567+
final String warningTemplate = "[%s] setting was deprecated in Elasticsearch and will be removed in a future release! " +
568+
"See the breaking changes documentation for the next major version.";
569+
final String[] expectedWarnings = {
570+
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_REQUIRE_SETTING.getKey()),
571+
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_INCLUDE_SETTING.getKey()),
572+
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_EXCLUDE_SETTING.getKey()),
573+
};
574+
575+
assertWarnings(expectedWarnings);
576+
}
577+
506578
public void testCheckGeoShapeMappings() throws Exception {
507579
Map<String, Object> emptyMappingMap = Collections.emptyMap();
508580
MappingMetadata mappingMetadata = new MappingMetadata("", emptyMappingMap);

0 commit comments

Comments
 (0)