diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.health/20_request_timeout.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.health/20_request_timeout.yml index e5a4db4dbfd9f..74261d799ba7d 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.health/20_request_timeout.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.health/20_request_timeout.yml @@ -39,8 +39,8 @@ --- "cluster health request timeout with 200 response code": - skip: - version: " - 7.99.99" - reason: "return_200_for_cluster_health_timeout exists only in 8.0.0; re-enable in 7.16+ when back-ported" + version: " - 7.15.99" + reason: "return_200_for_cluster_health_timeout was added in 7.16" - do: cluster.health: timeout: 1ms diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java index d4aa7f1177bd5..8ee6e32653267 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java @@ -69,9 +69,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException { } else { indicesOptions = IndicesOptions.lenientExpandOpen(); } - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { - return200ForClusterHealthTimeout = in.readBoolean(); - } + return200ForClusterHealthTimeout = in.readBoolean(); } @Override @@ -102,11 +100,7 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getVersion().onOrAfter(Version.V_7_2_0)) { indicesOptions.writeIndicesOptions(out); } - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { - out.writeBoolean(return200ForClusterHealthTimeout); - } else if (return200ForClusterHealthTimeout) { - throw new IllegalArgumentException("Can't fix response code in a cluster involving nodes with version " + out.getVersion()); - } + out.writeBoolean(return200ForClusterHealthTimeout); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java index ca9da08311023..79bc4a59c2f73 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -8,7 +8,6 @@ package org.elasticsearch.action.admin.cluster.health; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.health.ClusterHealthStatus; @@ -150,9 +149,7 @@ public ClusterHealthResponse(StreamInput in) throws IOException { numberOfInFlightFetch = in.readInt(); delayedUnassignedShards= in.readInt(); taskMaxWaitingTime = in.readTimeValue(); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { - return200ForClusterHealthTimeout = in.readBoolean(); - } + return200ForClusterHealthTimeout = in.readBoolean(); } /** needed for plugins BWC */ @@ -304,11 +301,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeInt(numberOfInFlightFetch); out.writeInt(delayedUnassignedShards); out.writeTimeValue(taskMaxWaitingTime); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { - out.writeBoolean(return200ForClusterHealthTimeout); - } else if (return200ForClusterHealthTimeout) { - throw new IllegalArgumentException("Can't fix response code in a cluster involving nodes with version " + out.getVersion()); - } + out.writeBoolean(return200ForClusterHealthTimeout); } @Override diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestTests.java index 8608d9f3a6886..02851bbe5e50f 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestTests.java @@ -51,6 +51,7 @@ public void testRequestReturnsHiddenIndicesByDefault() { assertTrue(defaultRequest.indicesOptions().expandWildcardsHidden()); } + @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/79454") public void testBwcSerialization() throws Exception { for (int runs = 0; runs < randomIntBetween(5, 20); runs++) { // Generate a random cluster health request in version < 7.2.0 and serializes it