Skip to content

Commit d8b5bfe

Browse files
authored
[8.0] Revert "Return 200 OK response code for a cluster health timeout (#78968)" (#80826)
* [8.0] Revert "Return 200 OK response code for a cluster health timeout (#78968)" This reverts commit a2c3dae * Revert "Allow deprecation warning for the return_200_for_cluster_health_timeout parameter (#80178) (#80444)" This reverts commit 4102cf7. * Revert "Drop pre-7.2.0 wire format in ClusterHealthRequest (#79551)" This reverts commit b9fbe66. * Revert "Adjust the BWC version for the return200ForClusterHealthTimeout field (#79436)" This reverts commit f60bda5. * Revert "Use query param instead of a system property for opting in for new cluster health response code (#79351)" This reverts commit 8901a99 * Revert "Deprecate returning 408 for a server timeout on `_cluster/health` (#78180)" This reverts commit f266eb3 * Drop pre-7.2.0 wire format in ClusterHealthRequest (#79551) This reverts commit fa4d562. * Revert "[8.0] Disable BWC for #80821 (#80840)"
1 parent 43f61bb commit d8b5bfe

File tree

20 files changed

+30
-185
lines changed

20 files changed

+30
-185
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ tasks.register("verifyVersions") {
125125
* after the backport of the backcompat code is complete.
126126
*/
127127

128-
boolean bwc_tests_enabled = false
128+
boolean bwc_tests_enabled = true
129129
// place a PR link here when committing bwc changes:
130-
String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/80821"
130+
String bwc_tests_disabled_issue = ""
131131
/*
132132
* FIPS 140-2 behavior was fixed in 7.11.0. Before that there is no way to run elasticsearch in a
133133
* JVM that is properly configured to be in fips mode with BCFIPS. For now we need to disable

client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public void testClusterHealthNotFoundIndex() throws IOException {
334334

335335
assertThat(response, notNullValue());
336336
assertThat(response.isTimedOut(), equalTo(true));
337-
assertThat(response.status(), equalTo(RestStatus.OK));
337+
assertThat(response.status(), equalTo(RestStatus.REQUEST_TIMEOUT));
338338
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.RED));
339339
assertNoIndices(response);
340340
}

docs/changelog/78968.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/reference/cluster/health.asciidoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
9797
provided or better, i.e. `green` > `yellow` > `red`. By default, will not
9898
wait for any status.
9999

100-
`return_200_for_cluster_health_timeout`::
101-
(Optional, Boolean) A boolean value which controls whether to return HTTP 200
102-
status code instead of HTTP 408 in case of a cluster health timeout from
103-
the server side. Defaults to false.
104-
105100
[[cluster-health-api-response-body]]
106101
==== {api-response-body-title}
107102

rest-api-spec/src/main/resources/rest-api-spec/api/cluster.health.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@
102102
"red"
103103
],
104104
"description":"Wait until cluster is in a specific state"
105-
},
106-
"return_200_for_cluster_health_timeout":{
107-
"type":"boolean",
108-
"description":"Whether to return HTTP 200 instead of 408 in case of a cluster health timeout from the server side"
109105
}
110106
}
111107
}
Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
---
22
"cluster health request timeout on waiting for nodes":
3-
- skip:
4-
version: " - 8.0.99"
5-
reason: "Set for 7.99.99 when back-ported to 8.0"
63
- do:
4+
catch: request_timeout
75
cluster.health:
86
wait_for_nodes: 10
97
timeout: 1ms
@@ -21,10 +19,8 @@
2119

2220
---
2321
"cluster health request timeout waiting for active shards":
24-
- skip:
25-
version: " - 8.0.99"
26-
reason: "Set for 7.99.99 when back-ported to 8.0"
2722
- do:
23+
catch: request_timeout
2824
cluster.health:
2925
timeout: 1ms
3026
wait_for_active_shards: 5
@@ -39,28 +35,3 @@
3935
- match: { initializing_shards: 0 }
4036
- match: { unassigned_shards: 0 }
4137
- gte: { number_of_pending_tasks: 0 }
42-
43-
---
44-
"cluster health request timeout with 200 response code":
45-
- skip:
46-
version: " - 7.15.99"
47-
reason: "return_200_for_cluster_health_timeout was added in 7.16"
48-
features: [ "allowed_warnings" ]
49-
- do:
50-
allowed_warnings:
51-
- 'the [return_200_for_cluster_health_timeout] parameter is deprecated and will be removed in a future release.'
52-
cluster.health:
53-
timeout: 1ms
54-
wait_for_active_shards: 5
55-
return_200_for_cluster_health_timeout: true
56-
57-
- is_true: cluster_name
58-
- is_true: timed_out
59-
- gte: { number_of_nodes: 1 }
60-
- gte: { number_of_data_nodes: 1 }
61-
- match: { active_primary_shards: 0 }
62-
- match: { active_shards: 0 }
63-
- match: { relocating_shards: 0 }
64-
- match: { initializing_shards: 0 }
65-
- match: { unassigned_shards: 0 }
66-
- gte: { number_of_pending_tasks: 0 }

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public class ClusterHealthRequest extends MasterNodeReadRequest<ClusterHealthReq
3434
private ActiveShardCount waitForActiveShards = ActiveShardCount.NONE;
3535
private String waitForNodes = "";
3636
private Priority waitForEvents = null;
37-
private boolean return200ForClusterHealthTimeout;
38-
3937
/**
4038
* Only used by the high-level REST Client. Controls the details level of the health information returned.
4139
* The default value is 'cluster'.
@@ -63,7 +61,6 @@ public ClusterHealthRequest(StreamInput in) throws IOException {
6361
}
6462
waitForNoInitializingShards = in.readBoolean();
6563
indicesOptions = IndicesOptions.readIndicesOptions(in);
66-
return200ForClusterHealthTimeout = in.readBoolean();
6764
}
6865

6966
@Override
@@ -92,7 +89,6 @@ public void writeTo(StreamOutput out) throws IOException {
9289
}
9390
out.writeBoolean(waitForNoInitializingShards);
9491
indicesOptions.writeIndicesOptions(out);
95-
out.writeBoolean(return200ForClusterHealthTimeout);
9692
}
9793

9894
@Override
@@ -236,18 +232,6 @@ public Priority waitForEvents() {
236232
return this.waitForEvents;
237233
}
238234

239-
public boolean doesReturn200ForClusterHealthTimeout() {
240-
return return200ForClusterHealthTimeout;
241-
}
242-
243-
/**
244-
* Sets whether to return HTTP 200 status code instead of HTTP 408 in case of a
245-
* cluster health timeout from the server side.
246-
*/
247-
public void return200ForClusterHealthTimeout(boolean return200ForClusterHealthTimeout) {
248-
this.return200ForClusterHealthTimeout = return200ForClusterHealthTimeout;
249-
}
250-
251235
/**
252236
* Set the level of detail for the health information to be returned.
253237
* Only used by the high-level REST Client.

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.elasticsearch.common.io.stream.StreamInput;
1818
import org.elasticsearch.common.io.stream.StreamOutput;
1919
import org.elasticsearch.common.xcontent.StatusToXContentObject;
20-
import org.elasticsearch.core.RestApiVersion;
2120
import org.elasticsearch.core.TimeValue;
2221
import org.elasticsearch.rest.RestStatus;
2322
import org.elasticsearch.xcontent.ConstructingObjectParser;
@@ -152,7 +151,8 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
152151
private boolean timedOut = false;
153152
private ClusterStateHealth clusterStateHealth;
154153
private ClusterHealthStatus clusterHealthStatus;
155-
private boolean return200ForClusterHealthTimeout;
154+
155+
public ClusterHealthResponse() {}
156156

157157
public ClusterHealthResponse(StreamInput in) throws IOException {
158158
super(in);
@@ -164,17 +164,11 @@ public ClusterHealthResponse(StreamInput in) throws IOException {
164164
numberOfInFlightFetch = in.readInt();
165165
delayedUnassignedShards = in.readInt();
166166
taskMaxWaitingTime = in.readTimeValue();
167-
return200ForClusterHealthTimeout = in.readBoolean();
168167
}
169168

170169
/** needed for plugins BWC */
171-
public ClusterHealthResponse(
172-
String clusterName,
173-
String[] concreteIndices,
174-
ClusterState clusterState,
175-
boolean return200ForServerTimeout
176-
) {
177-
this(clusterName, concreteIndices, clusterState, -1, -1, -1, TimeValue.timeValueHours(0), return200ForServerTimeout);
170+
public ClusterHealthResponse(String clusterName, String[] concreteIndices, ClusterState clusterState) {
171+
this(clusterName, concreteIndices, clusterState, -1, -1, -1, TimeValue.timeValueHours(0));
178172
}
179173

180174
public ClusterHealthResponse(
@@ -184,8 +178,7 @@ public ClusterHealthResponse(
184178
int numberOfPendingTasks,
185179
int numberOfInFlightFetch,
186180
int delayedUnassignedShards,
187-
TimeValue taskMaxWaitingTime,
188-
boolean return200ForServerTimeout
181+
TimeValue taskMaxWaitingTime
189182
) {
190183
this.clusterName = clusterName;
191184
this.numberOfPendingTasks = numberOfPendingTasks;
@@ -194,7 +187,6 @@ public ClusterHealthResponse(
194187
this.taskMaxWaitingTime = taskMaxWaitingTime;
195188
this.clusterStateHealth = new ClusterStateHealth(clusterState, concreteIndices);
196189
this.clusterHealthStatus = clusterStateHealth.getStatus();
197-
this.return200ForClusterHealthTimeout = return200ForServerTimeout;
198190
}
199191

200192
/**
@@ -333,7 +325,6 @@ public void writeTo(StreamOutput out) throws IOException {
333325
out.writeInt(numberOfInFlightFetch);
334326
out.writeInt(delayedUnassignedShards);
335327
out.writeTimeValue(taskMaxWaitingTime);
336-
out.writeBoolean(return200ForClusterHealthTimeout);
337328
}
338329

339330
@Override
@@ -343,16 +334,7 @@ public String toString() {
343334

344335
@Override
345336
public RestStatus status() {
346-
return status(RestApiVersion.current());
347-
}
348-
349-
@Override
350-
public RestStatus status(RestApiVersion restApiVersion) {
351-
// Legacy behaviour
352-
if (isTimedOut() && restApiVersion == RestApiVersion.V_7 && return200ForClusterHealthTimeout == false) {
353-
return RestStatus.REQUEST_TIMEOUT;
354-
}
355-
return RestStatus.OK;
337+
return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK;
356338
}
357339

358340
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/health/TransportClusterHealthAction.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ private ClusterHealthResponse clusterHealth(
411411
numberOfPendingTasks,
412412
numberOfInFlightFetch,
413413
UnassignedInfo.getNumberOfDelayedUnassigned(clusterState),
414-
pendingTaskTimeInQueue,
415-
request.doesReturn200ForClusterHealthTimeout()
414+
pendingTaskTimeInQueue
416415
);
417416
response.setStatus(ClusterHealthStatus.RED);
418417
return response;
@@ -425,8 +424,7 @@ private ClusterHealthResponse clusterHealth(
425424
numberOfPendingTasks,
426425
numberOfInFlightFetch,
427426
UnassignedInfo.getNumberOfDelayedUnassigned(clusterState),
428-
pendingTaskTimeInQueue,
429-
request.doesReturn200ForClusterHealthTimeout()
427+
pendingTaskTimeInQueue
430428
);
431429
}
432430
}

server/src/main/java/org/elasticsearch/common/xcontent/StatusToXContentObject.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88
package org.elasticsearch.common.xcontent;
99

10-
import org.elasticsearch.core.RestApiVersion;
1110
import org.elasticsearch.rest.RestStatus;
1211
import org.elasticsearch.xcontent.ToXContentObject;
1312

@@ -21,8 +20,4 @@ public interface StatusToXContentObject extends ToXContentObject {
2120
* Returns the REST status to make sure it is returned correctly
2221
*/
2322
RestStatus status();
24-
25-
default RestStatus status(RestApiVersion restApiVersion) {
26-
return status();
27-
}
2823
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public RestStatusToXContentListener(RestChannel channel, Function<Response, Stri
4444
public RestResponse buildResponse(Response response, XContentBuilder builder) throws Exception {
4545
assert response.isFragment() == false; // would be nice if we could make default methods final
4646
response.toXContent(builder, channel.request());
47-
RestResponse restResponse = new BytesRestResponse(response.status(builder.getRestApiVersion()), builder);
47+
RestResponse restResponse = new BytesRestResponse(response.status(), builder);
4848
if (RestStatus.CREATED == restResponse.status()) {
4949
final String location = extractLocation.apply(response);
5050
if (location != null) {

server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterHealthAction.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
import org.elasticsearch.cluster.health.ClusterHealthStatus;
1616
import org.elasticsearch.common.Priority;
1717
import org.elasticsearch.common.Strings;
18-
import org.elasticsearch.common.logging.DeprecationCategory;
19-
import org.elasticsearch.common.logging.DeprecationLogger;
2018
import org.elasticsearch.rest.BaseRestHandler;
2119
import org.elasticsearch.rest.RestRequest;
2220
import org.elasticsearch.rest.action.RestStatusToXContentListener;
23-
import org.elasticsearch.rest.action.search.RestSearchAction;
2421

2522
import java.io.IOException;
2623
import java.util.Collections;
@@ -33,12 +30,6 @@
3330

3431
public class RestClusterHealthAction extends BaseRestHandler {
3532

36-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSearchAction.class);
37-
private static final String RETURN_200_FOR_CLUSTER_HEALTH_TIMEOUT = "return_200_for_cluster_health_timeout";
38-
private static final String CLUSTER_HEALTH_REQUEST_TIMEOUT_DEPRECATION_MSG = "the ["
39-
+ RETURN_200_FOR_CLUSTER_HEALTH_TIMEOUT
40-
+ "] parameter is deprecated and will be removed in a future release.";
41-
4233
@Override
4334
public List<Route> routes() {
4435
return List.of(new Route(GET, "/_cluster/health"), new Route(GET, "/_cluster/health/{index}"));
@@ -90,15 +81,6 @@ public static ClusterHealthRequest fromRequest(final RestRequest request) {
9081
if (request.param("wait_for_events") != null) {
9182
clusterHealthRequest.waitForEvents(Priority.valueOf(request.param("wait_for_events").toUpperCase(Locale.ROOT)));
9283
}
93-
String return200ForClusterHealthTimeout = request.param(RETURN_200_FOR_CLUSTER_HEALTH_TIMEOUT);
94-
if (return200ForClusterHealthTimeout != null) {
95-
deprecationLogger.warn(
96-
DeprecationCategory.API,
97-
"cluster_health_request_timeout",
98-
CLUSTER_HEALTH_REQUEST_TIMEOUT_DEPRECATION_MSG
99-
);
100-
}
101-
clusterHealthRequest.return200ForClusterHealthTimeout(Boolean.parseBoolean(return200ForClusterHealthTimeout));
10284
return clusterHealthRequest;
10385
}
10486

server/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public void testSerialize() throws Exception {
3939
assertThat(cloneRequest.waitForEvents(), equalTo(originalRequest.waitForEvents()));
4040
assertIndicesEquals(cloneRequest.indices(), originalRequest.indices());
4141
assertThat(cloneRequest.indicesOptions(), equalTo(originalRequest.indicesOptions()));
42-
assertThat(cloneRequest.doesReturn200ForClusterHealthTimeout(), equalTo(originalRequest.doesReturn200ForClusterHealthTimeout()));
4342
}
4443

4544
public void testRequestReturnsHiddenIndicesByDefault() {

0 commit comments

Comments
 (0)