From c91c882c21a9b04344189f59daa6b09bbc9255d5 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 13 Oct 2021 09:02:39 +0200 Subject: [PATCH] Add frozen index deprecation check. 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 --- .../xpack/deprecation/DeprecationChecks.java | 3 ++- .../deprecation/IndexDeprecationChecks.java | 18 ++++++++++++++++++ .../IndexDeprecationChecksTests.java | 17 +++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java index 54500c24e5026..e944ec68fe51a 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java @@ -153,7 +153,8 @@ private DeprecationChecks() { IndexDeprecationChecks::checkIndexRoutingIncludeSetting, IndexDeprecationChecks::checkIndexRoutingExcludeSetting, IndexDeprecationChecks::checkIndexMatrixFiltersSetting, - IndexDeprecationChecks::checkGeoShapeMappings + IndexDeprecationChecks::checkGeoShapeMappings, + IndexDeprecationChecks::frozenIndexSettingCheck )); /** diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java index 0b39e005dc311..6c64c71256cd6 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java @@ -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; @@ -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; + } } diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java index e9f062c78c5fe..7543d2789062d 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java @@ -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; @@ -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 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 + ) + )); + } }