Skip to content

Commit 0c5750b

Browse files
committed
deprecation info API: 'fix' value for index.shard.check_on_startup
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 elastic#36024 relates elastic#33194
1 parent 27487c9 commit 0c5750b

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-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
@@ -48,7 +48,8 @@ private DeprecationChecks() {
4848
Collections.unmodifiableList(Arrays.asList(
4949
IndexDeprecationChecks::oldIndicesCheck,
5050
IndexDeprecationChecks::delimitedPayloadFilterCheck,
51-
IndexDeprecationChecks::indexNameCheck
51+
IndexDeprecationChecks::indexNameCheck,
52+
IndexDeprecationChecks::shardOnStartupCheck
5253
));
5354

5455
/**

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

+19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
import org.elasticsearch.Version;
1212
import org.elasticsearch.cluster.metadata.IndexMetaData;
1313
import org.elasticsearch.cluster.metadata.MappingMetaData;
14+
import org.elasticsearch.common.Strings;
1415
import org.elasticsearch.common.settings.Settings;
16+
import org.elasticsearch.index.IndexSettings;
1517
import org.elasticsearch.index.analysis.AnalysisRegistry;
1618
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1719

@@ -116,4 +118,21 @@ static DeprecationIssue indexNameCheck(IndexMetaData indexMetaData) {
116118
}
117119
return null;
118120
}
121+
122+
static DeprecationIssue shardOnStartupCheck(IndexMetaData indexMetaData) {
123+
String setting = IndexSettings.INDEX_CHECK_ON_STARTUP.getKey();
124+
String value = indexMetaData.getSettings().get(setting);
125+
if (Strings.isNullOrEmpty(value) == false) {
126+
if ("fix".equalsIgnoreCase(value)) {
127+
return new DeprecationIssue(DeprecationIssue.Level.WARNING,
128+
"The value 'fix' for setting index.shard.check_on_startup is no longer valid",
129+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
130+
"#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed",
131+
"The index [" + indexMetaData.getIndex().getName() + "] has the setting index.shard.check_on_startup = 'fix'. " +
132+
"Valid values are 'true', 'false', and 'checksum'");
133+
}
134+
}
135+
return null;
136+
}
119137
}
138+

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

+26
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.elasticsearch.Version;
99
import org.elasticsearch.cluster.metadata.IndexMetaData;
1010
import org.elasticsearch.common.settings.Settings;
11+
import org.elasticsearch.index.IndexSettings;
1112
import org.elasticsearch.test.ESTestCase;
1213
import org.elasticsearch.test.VersionUtils;
1314
import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
@@ -76,4 +77,29 @@ public void testIndexNameCheck(){
7677
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
7778
assertTrue(noIssues.isEmpty());
7879
}
80+
81+
public void testShardOnStartupCheck() {
82+
String indexName = randomAlphaOfLengthBetween(0, 10);
83+
final IndexMetaData badIndex = IndexMetaData.builder(indexName)
84+
.settings(settings(Version.CURRENT).put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), "fix"))
85+
.numberOfShards(randomIntBetween(1, 100))
86+
.numberOfReplicas(randomIntBetween(1, 15))
87+
.build();
88+
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING,
89+
"The value 'fix' for setting index.shard.check_on_startup is no longer valid",
90+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
91+
"#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed",
92+
"The index [" + indexName + "] has the setting index.shard.check_on_startup = 'fix'. " +
93+
"Valid values are 'true', 'false', and 'checksum'");
94+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex));
95+
assertEquals(singletonList(expected), issues);
96+
final IndexMetaData goodIndex = IndexMetaData.builder(indexName)
97+
.settings(settings(Version.CURRENT))
98+
.numberOfShards(randomIntBetween(1, 100))
99+
.numberOfReplicas(randomIntBetween(1, 15))
100+
.build();
101+
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
102+
assertTrue(noIssues.isEmpty());
103+
}
104+
79105
}

0 commit comments

Comments
 (0)