Skip to content

Commit

Permalink
Add frozen index deprecation check. (#79037)
Browse files Browse the repository at this point in the history
Backporting #78915 to 7.x branch.

If an index has `index.frozen` index setting set to `true` then
the deprecation info api will emit a deprecation check.

Relates to #70192
  • Loading branch information
martijnvg authored Oct 13, 2021
1 parent 0721ca2 commit 8ffc2b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ private DeprecationChecks() {
IndexDeprecationChecks::checkIndexRoutingIncludeSetting,
IndexDeprecationChecks::checkIndexRoutingExcludeSetting,
IndexDeprecationChecks::checkIndexMatrixFiltersSetting,
IndexDeprecationChecks::checkGeoShapeMappings
IndexDeprecationChecks::checkGeoShapeMappings,
IndexDeprecationChecks::frozenIndexSettingCheck
));

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexingSlowLog;
import org.elasticsearch.index.mapper.GeoShapeFieldMapper;
import org.elasticsearch.index.engine.frozen.FrozenEngine;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
import org.elasticsearch.index.SearchSlowLog;
import org.elasticsearch.index.SlowLogLevel;
Expand Down Expand Up @@ -420,4 +421,21 @@ static DeprecationIssue checkGeoShapeMappings(IndexMetadata indexMetadata) {
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
}
}

static DeprecationIssue frozenIndexSettingCheck(IndexMetadata indexMetadata) {
Boolean isIndexFrozen = FrozenEngine.INDEX_FROZEN.get(indexMetadata.getSettings());
if (Boolean.TRUE.equals(isIndexFrozen)) {
String indexName = indexMetadata.getIndex().getName();
return new DeprecationIssue(
DeprecationIssue.Level.WARNING,
"index [" + indexName +
"] is a frozen index. The frozen indices feature is deprecated and will be removed in a future version",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/frozen-indices.html",
"Frozen indices no longer offer any advantages. Consider cold or frozen tiers in place of frozen indices.",
false,
null
);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.index.SearchSlowLog;
import org.elasticsearch.index.SlowLogLevel;
import org.elasticsearch.index.mapper.FieldNamesFieldMapper;
import org.elasticsearch.index.engine.frozen.FrozenEngine;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
Expand Down Expand Up @@ -654,4 +655,20 @@ public void testAdjacencyMatrixSetting() {

assertWarnings(expectedWarnings);
}

public void testFrozenIndex() {
Settings.Builder settings = settings(Version.CURRENT);
settings.put(FrozenEngine.INDEX_FROZEN.getKey(), true);
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(indexMetadata));
assertThat(issues, contains(
new DeprecationIssue(DeprecationIssue.Level.WARNING,
"index [test] is a frozen index. The frozen indices feature is deprecated and will be removed in a future version",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/frozen-indices.html",
"Frozen indices no longer offer any advantages. Consider cold or frozen tiers in place of frozen indices.",
false,
null
)
));
}
}

0 comments on commit 8ffc2b6

Please sign in to comment.