Skip to content

Commit 93e3e08

Browse files
committed
Revert "Add deprecation warning for default shards (#30587)"
This reverts commit 3bb200f.
1 parent 67902b2 commit 93e3e08

File tree

4 files changed

+6
-100
lines changed

4 files changed

+6
-100
lines changed

distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/DefaultShardsIT.java

-51
This file was deleted.

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020
package org.elasticsearch.cluster.metadata;
2121

22+
import com.carrotsearch.hppc.cursors.ObjectCursor;
2223
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
2324
import org.apache.logging.log4j.Logger;
2425
import org.apache.logging.log4j.message.ParameterizedMessage;
26+
import org.apache.lucene.util.CollectionUtil;
2527
import org.elasticsearch.ElasticsearchException;
2628
import org.elasticsearch.ResourceAlreadyExistsException;
2729
import org.elasticsearch.Version;
@@ -57,6 +59,7 @@
5759
import org.elasticsearch.common.io.PathUtils;
5860
import org.elasticsearch.common.logging.DeprecationLogger;
5961
import org.elasticsearch.common.logging.Loggers;
62+
import org.elasticsearch.common.regex.Regex;
6063
import org.elasticsearch.common.settings.IndexScopedSettings;
6164
import org.elasticsearch.common.settings.Setting;
6265
import org.elasticsearch.common.settings.Settings;
@@ -78,10 +81,12 @@
7881
import org.joda.time.DateTime;
7982
import org.joda.time.DateTimeZone;
8083

84+
import java.io.IOException;
8185
import java.io.UnsupportedEncodingException;
8286
import java.nio.file.Path;
8387
import java.util.ArrayList;
8488
import java.util.Collections;
89+
import java.util.Comparator;
8590
import java.util.HashMap;
8691
import java.util.List;
8792
import java.util.Locale;
@@ -371,9 +376,6 @@ public ClusterState execute(ClusterState currentState) throws Exception {
371376
// now, put the request settings, so they override templates
372377
indexSettingsBuilder.put(request.settings());
373378
if (indexSettingsBuilder.get(SETTING_NUMBER_OF_SHARDS) == null) {
374-
deprecationLogger.deprecated("the default number of shards will change from [5] to [1] in 7.0.0; "
375-
+ "if you wish to continue using the default of [5] shards, "
376-
+ "you must manage this on the create index request or with an index template");
377379
indexSettingsBuilder.put(SETTING_NUMBER_OF_SHARDS, settings.getAsInt(SETTING_NUMBER_OF_SHARDS, 5));
378380
}
379381
if (indexSettingsBuilder.get(SETTING_NUMBER_OF_REPLICAS) == null) {

server/src/test/java/org/elasticsearch/cluster/metadata/IndexCreationTaskTests.java

-36
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ public void testMatchTemplates() throws Exception {
120120

121121
final ClusterState result = executeTask();
122122

123-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
124-
+ "if you wish to continue using the default of [5] shards, "
125-
+ "you must manage this on the create index request or with an index template");
126-
127123
assertThat(result.metaData().index("test").getAliases(), hasAllKeys("alias_from_template_1", "alias_from_template_2"));
128124
assertThat(result.metaData().index("test").getAliases(), not(hasKey("alias_from_template_3")));
129125
}
@@ -138,10 +134,6 @@ public void testApplyDataFromTemplate() throws Exception {
138134

139135
final ClusterState result = executeTask();
140136

141-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
142-
+ "if you wish to continue using the default of [5] shards, "
143-
+ "you must manage this on the create index request or with an index template");
144-
145137
assertThat(result.metaData().index("test").getAliases(), hasKey("alias1"));
146138
assertThat(result.metaData().index("test").getCustoms(), hasKey("custom1"));
147139
assertThat(result.metaData().index("test").getSettings().get("key1"), equalTo("value1"));
@@ -156,10 +148,6 @@ public void testApplyDataFromRequest() throws Exception {
156148

157149
final ClusterState result = executeTask();
158150

159-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
160-
+ "if you wish to continue using the default of [5] shards, "
161-
+ "you must manage this on the create index request or with an index template");
162-
163151
assertThat(result.metaData().index("test").getAliases(), hasKey("alias1"));
164152
assertThat(result.metaData().index("test").getCustoms(), hasKey("custom1"));
165153
assertThat(result.metaData().index("test").getSettings().get("key1"), equalTo("value1"));
@@ -189,10 +177,6 @@ public void testRequestDataHavePriorityOverTemplateData() throws Exception {
189177

190178
final ClusterState result = executeTask();
191179

192-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
193-
+ "if you wish to continue using the default of [5] shards, "
194-
+ "you must manage this on the create index request or with an index template");
195-
196180
assertThat(result.metaData().index("test").getCustoms().get("custom1"), equalTo(mergedCustom));
197181
assertThat(result.metaData().index("test").getAliases().get("alias1").getSearchRouting(), equalTo("fromReq"));
198182
assertThat(result.metaData().index("test").getSettings().get("key1"), equalTo("reqValue"));
@@ -202,10 +186,6 @@ public void testRequestDataHavePriorityOverTemplateData() throws Exception {
202186
public void testDefaultSettings() throws Exception {
203187
final ClusterState result = executeTask();
204188

205-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
206-
+ "if you wish to continue using the default of [5] shards, "
207-
+ "you must manage this on the create index request or with an index template");
208-
209189
assertThat(result.getMetaData().index("test").getSettings().get(SETTING_NUMBER_OF_SHARDS), equalTo("5"));
210190
}
211191

@@ -214,10 +194,6 @@ public void testSettingsFromClusterState() throws Exception {
214194

215195
final ClusterState result = executeTask();
216196

217-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
218-
+ "if you wish to continue using the default of [5] shards, "
219-
+ "you must manage this on the create index request or with an index template");
220-
221197
assertThat(result.getMetaData().index("test").getSettings().get(SETTING_NUMBER_OF_SHARDS), equalTo("15"));
222198
}
223199

@@ -270,10 +246,6 @@ public void testRequestStateOpen() throws Exception {
270246

271247
executeTask();
272248

273-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
274-
+ "if you wish to continue using the default of [5] shards, "
275-
+ "you must manage this on the create index request or with an index template");
276-
277249
verify(allocationService, times(1)).reroute(anyObject(), anyObject());
278250
}
279251

@@ -283,10 +255,6 @@ public void testIndexRemovalOnFailure() throws Exception {
283255

284256
expectThrows(RuntimeException.class, this::executeTask);
285257

286-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
287-
+ "if you wish to continue using the default of [5] shards, "
288-
+ "you must manage this on the create index request or with an index template");
289-
290258
verify(indicesService, times(1)).removeIndex(anyObject(), anyObject(), anyObject());
291259
}
292260

@@ -322,10 +290,6 @@ public void testValidateWaitForActiveShardsFailure() throws Exception {
322290

323291
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, this::executeTask);
324292

325-
assertWarnings("the default number of shards will change from [5] to [1] in 7.0.0; "
326-
+ "if you wish to continue using the default of [5] shards, "
327-
+ "you must manage this on the create index request or with an index template");
328-
329293
assertThat(e.getMessage(), containsString("invalid wait_for_active_shards"));
330294
}
331295

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,7 @@ void checkWarningHeaders(final List<String> warningHeaders) {
271271
final boolean matches = matcher.matches();
272272
if (matches) {
273273
final String message = matcher.group(1);
274-
// noinspection StatementWithEmptyBody
275-
if (message.equals("the default number of shards will change from [5] to [1] in 7.0.0; "
276-
+ "if you wish to continue using the default of [5] shards, "
277-
+ "you must manage this on the create index request or with an index template")) {
278-
/*
279-
* This warning header will come back in the vast majority of our tests that create an index. Rather than rewrite our
280-
* tests to assert this warning header, we assume that it is expected.
281-
*/
282-
}
283-
else if (expected.remove(message) == false) {
274+
if (expected.remove(message) == false) {
284275
unexpected.add(header);
285276
}
286277
} else {

0 commit comments

Comments
 (0)