Skip to content

Commit 4910918

Browse files
authored
Remove unsupported group_shard_failures parameter (#33208)
We have had support for the `group_shard_failures` parameter in our code for a while, since we introduced failures grouping. When we introduced validation of parameters at REST, we seem to have forgotten to expose such parameter. Given that the parameter is effectively not supported for many months now, that no user has complained about that and that grouping is the expected behaviour, this commit removes support for the parameter.
1 parent 034fdbc commit 4910918

File tree

4 files changed

+3
-82
lines changed

4 files changed

+3
-82
lines changed

server/src/main/java/org/elasticsearch/action/search/SearchPhaseExecutionException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@ private static String buildMessage(String phaseName, String msg, ShardSearchFail
134134
@Override
135135
protected void metadataToXContent(XContentBuilder builder, Params params) throws IOException {
136136
builder.field("phase", phaseName);
137-
final boolean group = params.paramAsBoolean("group_shard_failures", true); // we group by default
138-
builder.field("grouped", group); // notify that it's grouped
137+
builder.field("grouped", true); // notify that it's grouped
139138
builder.field("failed_shards");
140139
builder.startArray();
141-
ShardOperationFailedException[] failures = group ? ExceptionsHelper.groupBy(shardFailures) : shardFailures;
140+
ShardOperationFailedException[] failures = ExceptionsHelper.groupBy(shardFailures);
142141
for (ShardOperationFailedException failure : failures) {
143142
builder.startObject();
144143
failure.toXContent(builder, params);

server/src/main/java/org/elasticsearch/rest/action/RestActions.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ public static void buildBroadcastShardsHeader(XContentBuilder builder, Params pa
9090
builder.field(FAILED_FIELD.getPreferredName(), failed);
9191
if (shardFailures != null && shardFailures.length > 0) {
9292
builder.startArray(FAILURES_FIELD.getPreferredName());
93-
final boolean group = params.paramAsBoolean("group_shard_failures", true); // we group by default
94-
for (ShardOperationFailedException shardFailure : group ? ExceptionsHelper.groupBy(shardFailures) : shardFailures) {
93+
for (ShardOperationFailedException shardFailure : ExceptionsHelper.groupBy(shardFailures)) {
9594
builder.startObject();
9695
shardFailure.toXContent(builder, params);
9796
builder.endObject();

server/src/test/java/org/elasticsearch/action/search/SearchPhaseExecutionExceptionTests.java

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.elasticsearch.common.bytes.BytesReference;
2727
import org.elasticsearch.common.xcontent.ToXContent;
2828
import org.elasticsearch.common.xcontent.XContent;
29-
import org.elasticsearch.common.xcontent.XContentBuilder;
3029
import org.elasticsearch.common.xcontent.XContentParser;
3130
import org.elasticsearch.common.xcontent.XContentType;
3231
import org.elasticsearch.index.Index;
@@ -38,8 +37,6 @@
3837

3938
import java.io.IOException;
4039

41-
import static java.util.Collections.singletonMap;
42-
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
4340
import static org.hamcrest.CoreMatchers.hasItem;
4441
import static org.hamcrest.Matchers.hasSize;
4542

@@ -87,56 +84,6 @@ public void testToXContent() throws IOException {
8784
"}" +
8885
"}" +
8986
"]}", Strings.toString(exception));
90-
91-
// Failures are NOT grouped
92-
ToXContent.MapParams params = new ToXContent.MapParams(singletonMap("group_shard_failures", "false"));
93-
try (XContentBuilder builder = jsonBuilder()) {
94-
builder.startObject();
95-
exception.toXContent(builder, params);
96-
builder.endObject();
97-
98-
assertEquals("{" +
99-
"\"type\":\"search_phase_execution_exception\"," +
100-
"\"reason\":\"all shards failed\"," +
101-
"\"phase\":\"test\"," +
102-
"\"grouped\":false," +
103-
"\"failed_shards\":[" +
104-
"{" +
105-
"\"shard\":0," +
106-
"\"index\":\"foo\"," +
107-
"\"node\":\"node_1\"," +
108-
"\"reason\":{" +
109-
"\"type\":\"parsing_exception\"," +
110-
"\"reason\":\"foobar\"," +
111-
"\"line\":1," +
112-
"\"col\":2" +
113-
"}" +
114-
"}," +
115-
"{" +
116-
"\"shard\":1," +
117-
"\"index\":\"foo\"," +
118-
"\"node\":\"node_2\"," +
119-
"\"reason\":{" +
120-
"\"type\":\"index_shard_closed_exception\"," +
121-
"\"reason\":\"CurrentState[CLOSED] Closed\"," +
122-
"\"index_uuid\":\"_na_\"," +
123-
"\"shard\":\"1\"," +
124-
"\"index\":\"foo\"" +
125-
"}" +
126-
"}," +
127-
"{" +
128-
"\"shard\":2," +
129-
"\"index\":\"foo\"," +
130-
"\"node\":\"node_3\"," +
131-
"\"reason\":{" +
132-
"\"type\":\"parsing_exception\"," +
133-
"\"reason\":\"foobar\"," +
134-
"\"line\":5," +
135-
"\"col\":7" +
136-
"}" +
137-
"}" +
138-
"]}", Strings.toString(builder));
139-
}
14087
}
14188

14289
public void testToAndFromXContent() throws IOException {

server/src/test/java/org/elasticsearch/action/support/broadcast/AbstractBroadcastResponseTestCase.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import java.io.IOException;
3535
import java.util.ArrayList;
36-
import java.util.Collections;
3736
import java.util.List;
3837

3938
import static org.hamcrest.CoreMatchers.anyOf;
@@ -130,29 +129,6 @@ public void testFailuresDeduplication() throws IOException {
130129
assertThat(parsedFailures[1].shardId(), equalTo(2));
131130
assertThat(parsedFailures[1].status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
132131
assertThat(parsedFailures[1].getCause().getMessage(), containsString("fizz"));
133-
134-
ToXContent.Params params = new ToXContent.MapParams(Collections.singletonMap("group_shard_failures", "false"));
135-
BytesReference bytesReferenceWithoutDedup = toShuffledXContent(response, xContentType, params, humanReadable);
136-
try(XContentParser parser = createParser(xContentType.xContent(), bytesReferenceWithoutDedup)) {
137-
parsedResponse = doParseInstance(parser);
138-
assertNull(parser.nextToken());
139-
}
140-
141-
assertThat(parsedResponse.getShardFailures().length, equalTo(3));
142-
parsedFailures = parsedResponse.getShardFailures();
143-
for (int i = 0; i < 3; i++) {
144-
if (i < 2) {
145-
assertThat(parsedFailures[i].index(), equalTo("test"));
146-
assertThat(parsedFailures[i].shardId(), equalTo(i));
147-
assertThat(parsedFailures[i].status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
148-
assertThat(parsedFailures[i].getCause().getMessage(), containsString("foo"));
149-
} else {
150-
assertThat(parsedFailures[i].index(), equalTo("test"));
151-
assertThat(parsedFailures[i].shardId(), equalTo(i));
152-
assertThat(parsedFailures[i].status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
153-
assertThat(parsedFailures[i].getCause().getMessage(), containsString("fizz"));
154-
}
155-
}
156132
}
157133

158134
public void testToXContent() {

0 commit comments

Comments
 (0)