Skip to content

Commit

Permalink
Adding metadata about removable index settings (#84145)
Browse files Browse the repository at this point in the history
In #83601 we added metadata to identify removable cluster settings. This commit adds the same metadata for
removable index settings.
Relates #83116
  • Loading branch information
masseyke committed Feb 17, 2022
1 parent 2e957c6 commit 8c66bb9
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,14 @@ private static DeprecationIssue slowLogSettingCheck(IndexMetadata indexMetadata,
"Remove the [%s] setting. Use the [index.*.slowlog.threshold] settings to " + "set the log levels.",
setting.getKey()
);
return new DeprecationIssue(DeprecationIssue.Level.WARNING, message, url, details, false, null);
return new DeprecationIssue(
DeprecationIssue.Level.WARNING,
message,
url,
details,
false,
DeprecationIssue.createMetaMapForRemovableSettings(Collections.singletonList(setting.getKey()))
);
}
return null;
}
Expand Down Expand Up @@ -637,7 +644,11 @@ static DeprecationIssue checkRemovedSetting(
final String value = removedSetting.get(settings).toString();
final String message = String.format(Locale.ROOT, messagePattern, removedSettingKey);
final String details = String.format(Locale.ROOT, "Remove the [%s] setting. %s", removedSettingKey, additionalDetail);
return new DeprecationIssue(deprecationLevel, message, url, details, false, null);
boolean canBeRemoved = removedSetting.isDynamic() && removedSetting.isPrivateIndex() == false;
Map<String, Object> meta = canBeRemoved
? DeprecationIssue.createMetaMapForRemovableSettings(Collections.singletonList(removedSettingKey))
: null;
return new DeprecationIssue(deprecationLevel, message, url, details, false, meta);
}

static DeprecationIssue checkIndexRoutingRequireSetting(IndexMetadata indexMetadata) {
Expand Down Expand Up @@ -754,10 +765,6 @@ static DeprecationIssue frozenIndexSettingCheck(IndexMetadata indexMetadata) {
return null;
}

static DeprecationIssue checkSettingNoReplacement(IndexMetadata indexMetadata, Setting<?> deprecatedSetting, String url) {
return NodeDeprecationChecks.checkSettingNoReplacement(indexMetadata.getSettings(), deprecatedSetting, url);
}

static DeprecationIssue httpContentTypeRequiredSettingCheck(IndexMetadata indexMetadata) {
Setting<Boolean> deprecatedSetting = Store.FORCE_RAM_TERM_DICT;
String url = "https://ela.st/es-deprecation-7-force-memory-term-dictionary-setting";
Expand All @@ -772,7 +779,15 @@ static DeprecationIssue httpContentTypeRequiredSettingCheck(IndexMetadata indexM

static DeprecationIssue mapperDyamicSettingCheck(IndexMetadata indexMetadata) {
Setting<Boolean> deprecatedSetting = MapperService.INDEX_MAPPER_DYNAMIC_SETTING;
Settings indexSettings = indexMetadata.getSettings();
if (deprecatedSetting.exists(indexSettings) == false) {
return null;
}
String deprecatedSettingKey = deprecatedSetting.getKey();
String url = "https://ela.st/es-deprecation-7-mapper-dynamic-setting";
return checkSettingNoReplacement(indexMetadata, deprecatedSetting, url);
final String message = String.format(Locale.ROOT, "Setting [%s] is deprecated", deprecatedSettingKey);
final String details = String.format(Locale.ROOT, "Remove the [%s] setting.", deprecatedSettingKey);
Map<String, Object> meta = DeprecationIssue.createMetaMapForRemovableSettings(Collections.singletonList(deprecatedSettingKey));
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, meta);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,9 @@ public void testSlowLogLevel() {
expectedUrl,
"Remove the [index.search.slowlog.level] setting. Use the [index.*.slowlog.threshold] settings to set the log levels.",
false,
null
DeprecationIssue.createMetaMapForRemovableSettings(
Collections.singletonList(SearchSlowLog.INDEX_SEARCH_SLOWLOG_LEVEL.getKey())
)
),
new DeprecationIssue(
DeprecationIssue.Level.WARNING,
Expand All @@ -762,7 +764,9 @@ public void testSlowLogLevel() {
"Remove the [index.indexing.slowlog.level] setting. Use the [index.*.slowlog.threshold]"
+ " settings to set the log levels.",
false,
null
DeprecationIssue.createMetaMapForRemovableSettings(
Collections.singletonList(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_LEVEL_SETTING.getKey())
)
)
)
);
Expand Down Expand Up @@ -809,7 +813,7 @@ public void testTierAllocationSettings() {
settingValue
),
false,
null
DeprecationIssue.createMetaMapForRemovableSettings(Collections.singletonList(INDEX_ROUTING_REQUIRE_SETTING.getKey()))
);
final DeprecationIssue expectedIncludeIssue = new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
Expand All @@ -822,7 +826,7 @@ public void testTierAllocationSettings() {
settingValue
),
false,
null
DeprecationIssue.createMetaMapForRemovableSettings(Collections.singletonList(INDEX_ROUTING_INCLUDE_SETTING.getKey()))
);
final DeprecationIssue expectedExcludeIssue = new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
Expand All @@ -834,7 +838,7 @@ public void testTierAllocationSettings() {
INDEX_ROUTING_EXCLUDE_SETTING.getKey()
),
false,
null
DeprecationIssue.createMetaMapForRemovableSettings(Collections.singletonList(INDEX_ROUTING_EXCLUDE_SETTING.getKey()))
);

IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
Expand Down Expand Up @@ -963,7 +967,9 @@ public void testAdjacencyMatrixSetting() {
"Remove the [index.max_adjacency_matrix_filters] setting. Set [indices.query.bool.max_clause_count] to [5]. "
+ "[index.max_adjacency_matrix_filters] will be ignored in 8.0.",
false,
null
DeprecationIssue.createMetaMapForRemovableSettings(
Collections.singletonList(IndexSettings.MAX_ADJACENCY_MATRIX_FILTERS_SETTING.getKey())
)
)
)
);
Expand Down Expand Up @@ -1041,7 +1047,9 @@ public void testMapperDynamicSetting() {
"https://ela.st/es-deprecation-7-mapper-dynamic-setting",
"Remove the [index.mapper.dynamic] setting.",
false,
null
DeprecationIssue.createMetaMapForRemovableSettings(
Collections.singletonList(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey())
)
);
assertThat(issues, hasItem(expected));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.elasticsearch.cluster.action.shard.ShardStateAction;
import org.elasticsearch.cluster.coordination.DiscoveryUpgradeService;
import org.elasticsearch.cluster.coordination.NoMasterBlockService;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
Expand Down Expand Up @@ -79,9 +78,9 @@
import static org.elasticsearch.cluster.coordination.JoinHelper.JOIN_TIMEOUT_SETTING;
import static org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING;
import static org.elasticsearch.common.settings.Setting.Property;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_EXCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_INCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.INDEX_ROUTING_REQUIRE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_EXCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_INCLUDE_SETTING;
import static org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider.CLUSTER_ROUTING_REQUIRE_SETTING;
import static org.elasticsearch.xpack.deprecation.NodeDeprecationChecks.JAVA_DEPRECATION_MESSAGE;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.either;
Expand Down Expand Up @@ -1415,59 +1414,69 @@ public void testCheckFixedAutoQueueSizeThreadpool() {
}

public void testTierAllocationSettings() {
String settingValue = DataTier.DATA_HOT;
final Settings settings = settings(Version.CURRENT).put(INDEX_ROUTING_REQUIRE_SETTING.getKey(), DataTier.DATA_HOT)
.put(INDEX_ROUTING_INCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
.put(INDEX_ROUTING_EXCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
final Settings settings = settings(Version.CURRENT).put(CLUSTER_ROUTING_REQUIRE_SETTING.getKey(), DataTier.DATA_HOT)
.put(CLUSTER_ROUTING_INCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
.put(CLUSTER_ROUTING_EXCLUDE_SETTING.getKey(), DataTier.DATA_HOT)
.build();
final DeprecationIssue expectedRequireIssue = new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT, "Setting [%s] is deprecated", INDEX_ROUTING_REQUIRE_SETTING.getKey()),
String.format(Locale.ROOT, "Setting [%s] is deprecated", CLUSTER_ROUTING_REQUIRE_SETTING.getKey()),
"https://ela.st/es-deprecation-7-tier-filtering-settings",
String.format(
Locale.ROOT,
"Remove the [%s] setting. Use [index.routing.allocation.include._tier_preference] to control allocation to data tiers.",
INDEX_ROUTING_REQUIRE_SETTING.getKey()
CLUSTER_ROUTING_REQUIRE_SETTING.getKey()
),
false,
null
);
final DeprecationIssue expectedIncludeIssue = new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT, "Setting [%s] is deprecated", INDEX_ROUTING_INCLUDE_SETTING.getKey()),
String.format(Locale.ROOT, "Setting [%s] is deprecated", CLUSTER_ROUTING_INCLUDE_SETTING.getKey()),
"https://ela.st/es-deprecation-7-tier-filtering-settings",
String.format(
Locale.ROOT,
"Remove the [%s] setting. Use [index.routing.allocation.include._tier_preference] to control allocation to data tiers.",
INDEX_ROUTING_INCLUDE_SETTING.getKey()
CLUSTER_ROUTING_INCLUDE_SETTING.getKey()
),
false,
null
);
final DeprecationIssue expectedExcludeIssue = new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT, "Setting [%s] is deprecated", INDEX_ROUTING_EXCLUDE_SETTING.getKey()),
String.format(Locale.ROOT, "Setting [%s] is deprecated", CLUSTER_ROUTING_EXCLUDE_SETTING.getKey()),
"https://ela.st/es-deprecation-7-tier-filtering-settings",
String.format(
Locale.ROOT,
"Remove the [%s] setting. Use [index.routing.allocation.include._tier_preference] to control allocation to data tiers.",
INDEX_ROUTING_EXCLUDE_SETTING.getKey()
CLUSTER_ROUTING_EXCLUDE_SETTING.getKey()
),
false,
null
);

IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
assertThat(IndexDeprecationChecks.checkIndexRoutingRequireSetting(indexMetadata), equalTo(expectedRequireIssue));
assertThat(IndexDeprecationChecks.checkIndexRoutingIncludeSetting(indexMetadata), equalTo(expectedIncludeIssue));
assertThat(IndexDeprecationChecks.checkIndexRoutingExcludeSetting(indexMetadata), equalTo(expectedExcludeIssue));
final PluginsAndModules pluginsAndModules = new PluginsAndModules(Collections.emptyList(), Collections.emptyList());
final XPackLicenseState licenseState = new XPackLicenseState(Settings.EMPTY, () -> 0);
ClusterState clusterState = ClusterState.EMPTY_STATE;
assertThat(
NodeDeprecationChecks.checkClusterRoutingRequireSetting(settings, pluginsAndModules, clusterState, licenseState),
equalTo(expectedRequireIssue)
);
assertThat(
NodeDeprecationChecks.checkClusterRoutingIncludeSetting(settings, pluginsAndModules, clusterState, licenseState),
equalTo(expectedIncludeIssue)
);
assertThat(
NodeDeprecationChecks.checkClusterRoutingExcludeSetting(settings, pluginsAndModules, clusterState, licenseState),
equalTo(expectedExcludeIssue)
);

final String warningTemplate = "[%s] setting was deprecated in Elasticsearch and will be removed in a future release! "
+ "See the breaking changes documentation for the next major version.";
final String[] expectedWarnings = {
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_REQUIRE_SETTING.getKey()),
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_INCLUDE_SETTING.getKey()),
String.format(Locale.ROOT, warningTemplate, INDEX_ROUTING_EXCLUDE_SETTING.getKey()), };
String.format(Locale.ROOT, warningTemplate, CLUSTER_ROUTING_REQUIRE_SETTING.getKey()),
String.format(Locale.ROOT, warningTemplate, CLUSTER_ROUTING_INCLUDE_SETTING.getKey()),
String.format(Locale.ROOT, warningTemplate, CLUSTER_ROUTING_EXCLUDE_SETTING.getKey()), };

assertWarnings(expectedWarnings);
}
Expand Down

0 comments on commit 8c66bb9

Please sign in to comment.