Skip to content

Commit e171bd9

Browse files
authored
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
1 parent 89469aa commit e171bd9

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ private DeprecationChecks() {
5353
IndexDeprecationChecks::delimitedPayloadFilterCheck,
5454
IndexDeprecationChecks::percolatorUnmappedFieldsAsStringCheck,
5555
IndexDeprecationChecks::indexNameCheck,
56-
IndexDeprecationChecks::nodeLeftDelayedTimeCheck
56+
IndexDeprecationChecks::nodeLeftDelayedTimeCheck,
57+
IndexDeprecationChecks::shardOnStartupCheck
5758
));
5859

5960
/**

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.common.Strings;
1616
import org.elasticsearch.common.settings.Settings;
1717
import org.elasticsearch.common.unit.TimeValue;
18+
import org.elasticsearch.index.IndexSettings;
1819
import org.elasticsearch.index.analysis.AnalysisRegistry;
1920
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
2021

@@ -149,4 +150,20 @@ static DeprecationIssue nodeLeftDelayedTimeCheck(IndexMetaData indexMetaData) {
149150
}
150151
return null;
151152
}
153+
154+
static DeprecationIssue shardOnStartupCheck(IndexMetaData indexMetaData) {
155+
String setting = IndexSettings.INDEX_CHECK_ON_STARTUP.getKey();
156+
String value = indexMetaData.getSettings().get(setting);
157+
if (Strings.isNullOrEmpty(value) == false) {
158+
if ("fix".equalsIgnoreCase(value)) {
159+
return new DeprecationIssue(DeprecationIssue.Level.WARNING,
160+
"The value [fix] for setting [" + setting + "] is no longer valid",
161+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
162+
"#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed",
163+
"The index [" + indexMetaData.getIndex().getName() + "] has the setting [" + setting + "] set to value [fix]" +
164+
", but [fix] is no longer a valid value. Valid values are true, false, and checksum");
165+
}
166+
}
167+
return null;
168+
}
152169
}

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java

+26
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.elasticsearch.cluster.metadata.IndexMetaData;
1010
import org.elasticsearch.cluster.routing.UnassignedInfo;
1111
import org.elasticsearch.common.settings.Settings;
12+
import org.elasticsearch.index.IndexSettings;
1213
import org.elasticsearch.test.ESTestCase;
1314
import org.elasticsearch.test.VersionUtils;
1415
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
@@ -136,4 +137,29 @@ public void testNodeLeftDelayedTimeCheck() {
136137
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
137138
assertTrue(noIssues.isEmpty());
138139
}
140+
141+
public void testShardOnStartupCheck() {
142+
String indexName = randomAlphaOfLengthBetween(0, 10);
143+
String setting = IndexSettings.INDEX_CHECK_ON_STARTUP.getKey();
144+
final IndexMetaData badIndex = IndexMetaData.builder(indexName)
145+
.settings(settings(Version.CURRENT).put(setting, "fix"))
146+
.numberOfShards(randomIntBetween(1, 100))
147+
.numberOfReplicas(randomIntBetween(1, 15))
148+
.build();
149+
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING,
150+
"The value [fix] for setting [" + setting + "] is no longer valid",
151+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
152+
"#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed",
153+
"The index [" + indexName + "] has the setting [" + setting + "] set to value [fix]" +
154+
", but [fix] is no longer a valid value. Valid values are true, false, and checksum");
155+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex));
156+
assertEquals(singletonList(expected), issues);
157+
final IndexMetaData goodIndex = IndexMetaData.builder(indexName)
158+
.settings(settings(Version.CURRENT))
159+
.numberOfShards(randomIntBetween(1, 100))
160+
.numberOfReplicas(randomIntBetween(1, 15))
161+
.build();
162+
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
163+
assertTrue(noIssues.isEmpty());
164+
}
139165
}

0 commit comments

Comments
 (0)