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 164f0ec77b146..1144a492ad5be 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 @@ -48,7 +48,8 @@ private DeprecationChecks() { Collections.unmodifiableList(Arrays.asList( IndexDeprecationChecks::oldIndicesCheck, IndexDeprecationChecks::delimitedPayloadFilterCheck, - IndexDeprecationChecks::indexNameCheck + IndexDeprecationChecks::indexNameCheck, + IndexDeprecationChecks::shardOnStartupCheck )); /** 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 5134d86f51891..d1edcaa8421ee 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 @@ -11,7 +11,9 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; @@ -116,4 +118,21 @@ static DeprecationIssue indexNameCheck(IndexMetaData indexMetaData) { } return null; } + + static DeprecationIssue shardOnStartupCheck(IndexMetaData indexMetaData) { + String setting = IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(); + String value = indexMetaData.getSettings().get(setting); + if (Strings.isNullOrEmpty(value) == false) { + if ("fix".equalsIgnoreCase(value)) { + return new DeprecationIssue(DeprecationIssue.Level.WARNING, + "The value 'fix' for setting index.shard.check_on_startup is no longer valid", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed", + "The index [" + indexMetaData.getIndex().getName() + "] has the setting index.shard.check_on_startup = 'fix'. " + + "Valid values are 'true', 'false', and 'checksum'"); + } + } + 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 8255461c1bcdd..619b5702e1c0e 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 @@ -8,6 +8,7 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.VersionUtils; import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction; @@ -76,4 +77,29 @@ public void testIndexNameCheck(){ List noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex)); assertTrue(noIssues.isEmpty()); } + + public void testShardOnStartupCheck() { + String indexName = randomAlphaOfLengthBetween(0, 10); + final IndexMetaData badIndex = IndexMetaData.builder(indexName) + .settings(settings(Version.CURRENT).put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), "fix")) + .numberOfShards(randomIntBetween(1, 100)) + .numberOfReplicas(randomIntBetween(1, 15)) + .build(); + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, + "The value 'fix' for setting index.shard.check_on_startup is no longer valid", + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + + "#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed", + "The index [" + indexName + "] has the setting index.shard.check_on_startup = 'fix'. " + + "Valid values are 'true', 'false', and 'checksum'"); + List issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex)); + assertEquals(singletonList(expected), issues); + final IndexMetaData goodIndex = IndexMetaData.builder(indexName) + .settings(settings(Version.CURRENT)) + .numberOfShards(randomIntBetween(1, 100)) + .numberOfReplicas(randomIntBetween(1, 15)) + .build(); + List noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex)); + assertTrue(noIssues.isEmpty()); + } + }