Skip to content

Commit

Permalink
Add frozen index deprecation check. (#78915)
Browse files Browse the repository at this point in the history
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 939f81e commit b1e8e90
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 @@ -41,7 +41,8 @@ private DeprecationChecks() {
IndexDeprecationChecks::oldIndicesCheck,
IndexDeprecationChecks::translogRetentionSettingCheck,
IndexDeprecationChecks::checkIndexDataPath,
IndexDeprecationChecks::storeTypeSettingCheck
IndexDeprecationChecks::storeTypeSettingCheck,
IndexDeprecationChecks::frozenIndexSettingCheck
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.engine.frozen.FrozenEngine;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;

import java.util.Locale;
Expand Down Expand Up @@ -73,4 +74,21 @@ static DeprecationIssue storeTypeSettingCheck(IndexMetadata indexMetadata) {
}
return 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 @@ -12,6 +12,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.engine.frozen.FrozenEngine;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;

Expand Down Expand Up @@ -96,4 +97,20 @@ public void testSimpleFSSetting() {
"as it offers superior or equivalent performance to [simplefs].", false, null)
));
}

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 b1e8e90

Please sign in to comment.