From e171bd96f1481d183db1e54ec304feaebf3f57b8 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Thu, 13 Dec 2018 10:42:45 -0600 Subject: [PATCH] deprecation info API: 'fix' value for index.shard.check_on_startup (#36458) This commit adds support to check for a value of 'fix' for the index setting `index.shard.check_on_startup` for the deprecation info API. This is no longer a valid value for this setting. relates #36024 relates #33194 --- .../xpack/deprecation/DeprecationChecks.java | 3 ++- .../deprecation/IndexDeprecationChecks.java | 17 ++++++++++++ .../IndexDeprecationChecksTests.java | 26 +++++++++++++++++++ 3 files changed, 45 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 63e2c013f5dc3..f848a15da7a61 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 @@ -53,7 +53,8 @@ private DeprecationChecks() { IndexDeprecationChecks::delimitedPayloadFilterCheck, IndexDeprecationChecks::percolatorUnmappedFieldsAsStringCheck, IndexDeprecationChecks::indexNameCheck, - IndexDeprecationChecks::nodeLeftDelayedTimeCheck + IndexDeprecationChecks::nodeLeftDelayedTimeCheck, + 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 a67e4f2271d7e..bfef54cf62394 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 @@ -15,6 +15,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; @@ -149,4 +150,20 @@ static DeprecationIssue nodeLeftDelayedTimeCheck(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 [" + setting + "] 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 [" + setting + "] set to value [fix]" + + ", but [fix] is no longer a valid value. 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 a01854ea1865e..25210aa8fc479 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 @@ -9,6 +9,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.routing.UnassignedInfo; 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; @@ -136,4 +137,29 @@ public void testNodeLeftDelayedTimeCheck() { List noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex)); assertTrue(noIssues.isEmpty()); } + + public void testShardOnStartupCheck() { + String indexName = randomAlphaOfLengthBetween(0, 10); + String setting = IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(); + final IndexMetaData badIndex = IndexMetaData.builder(indexName) + .settings(settings(Version.CURRENT).put(setting, "fix")) + .numberOfShards(randomIntBetween(1, 100)) + .numberOfReplicas(randomIntBetween(1, 15)) + .build(); + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, + "The value [fix] for setting [" + setting + "] 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 [" + setting + "] set to value [fix]" + + ", but [fix] is no longer a valid value. 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()); + } }