Skip to content

Commit 3287dcb

Browse files
committed
Revert "Deprecate returning 408 for a server timeout on _cluster/health (#78180)"
This reverts commit f266eb3
1 parent f14bada commit 3287dcb

File tree

3 files changed

+10
-78
lines changed

3 files changed

+10
-78
lines changed

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

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import java.util.HashMap;
5050
import java.util.List;
5151
import java.util.Map;
52-
import java.util.function.BiConsumer;
5352

5453
import static java.util.Collections.emptyMap;
5554
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -74,13 +73,11 @@ public void testClusterPutSettings() throws IOException {
7473
ClusterUpdateSettingsRequest setRequest = new ClusterUpdateSettingsRequest();
7574
setRequest.transientSettings(transientSettings);
7675
setRequest.persistentSettings(map);
77-
RequestOptions options = RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build();
7876

7977
ClusterUpdateSettingsResponse setResponse = execute(
8078
setRequest,
8179
highLevelClient().cluster()::putSettings,
82-
highLevelClient().cluster()::putSettingsAsync,
83-
options
80+
highLevelClient().cluster()::putSettingsAsync
8481
);
8582

8683
assertAcked(setResponse);
@@ -107,8 +104,7 @@ public void testClusterPutSettings() throws IOException {
107104
ClusterUpdateSettingsResponse resetResponse = execute(
108105
resetRequest,
109106
highLevelClient().cluster()::putSettings,
110-
highLevelClient().cluster()::putSettingsAsync,
111-
options
107+
highLevelClient().cluster()::putSettingsAsync
112108
);
113109

114110
assertThat(resetResponse.getTransientSettings().get(transientSettingKey), equalTo(null));
@@ -123,22 +119,11 @@ public void testClusterPutSettings() throws IOException {
123119
assertThat(persistentResetValue, equalTo(null));
124120
}
125121

126-
public void testClusterUpdateTransientSettingNonExistent() {
127-
testClusterUpdateSettingNonExistent((settings, request) -> request.transientSettings(settings), "transient");
128-
}
129-
130-
public void testClusterUpdatePersistentSettingNonExistent() {
131-
testClusterUpdateSettingNonExistent((settings, request) -> request.persistentSettings(settings), "persistent");
132-
}
133-
134-
private void testClusterUpdateSettingNonExistent(
135-
final BiConsumer<Settings.Builder, ClusterUpdateSettingsRequest> consumer,
136-
String label
137-
) {
122+
public void testClusterUpdateSettingNonExistent() {
138123
String setting = "no_idea_what_you_are_talking_about";
139124
int value = 10;
140125
ClusterUpdateSettingsRequest clusterUpdateSettingsRequest = new ClusterUpdateSettingsRequest();
141-
consumer.accept(Settings.builder().put(setting, value), clusterUpdateSettingsRequest);
126+
clusterUpdateSettingsRequest.transientSettings(Settings.builder().put(setting, value).build());
142127

143128
ElasticsearchException exception = expectThrows(
144129
ElasticsearchException.class,
@@ -151,9 +136,7 @@ private void testClusterUpdateSettingNonExistent(
151136
assertThat(exception.status(), equalTo(RestStatus.BAD_REQUEST));
152137
assertThat(
153138
exception.getMessage(),
154-
equalTo(
155-
"Elasticsearch exception [type=illegal_argument_exception, reason=" + label + " setting [" + setting + "], not recognized]"
156-
)
139+
equalTo("Elasticsearch exception [type=illegal_argument_exception, reason=transient setting [" + setting + "], not recognized]")
157140
);
158141
}
159142

@@ -337,11 +320,6 @@ public void testClusterHealthNotFoundIndex() throws IOException {
337320
assertThat(response.status(), equalTo(RestStatus.REQUEST_TIMEOUT));
338321
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.RED));
339322
assertNoIndices(response);
340-
assertWarnings(
341-
"The HTTP status code for a cluster health timeout will be changed from 408 to 200 in a "
342-
+ "future version. Set the [es.cluster_health.request_timeout_200] system property to [true] to suppress this message and "
343-
+ "opt in to the future behaviour now."
344-
);
345323
}
346324

347325
public void testRemoteInfo() throws Exception {
@@ -353,13 +331,13 @@ public void testRemoteInfo() throws Exception {
353331
ClusterGetSettingsResponse settingsResponse = highLevelClient().cluster().getSettings(settingsRequest, RequestOptions.DEFAULT);
354332

355333
List<String> seeds = SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace(clusterAlias)
356-
.get(settingsResponse.getPersistentSettings());
357-
int connectionsPerCluster = SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER.get(settingsResponse.getPersistentSettings());
334+
.get(settingsResponse.getTransientSettings());
335+
int connectionsPerCluster = SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER.get(settingsResponse.getTransientSettings());
358336
TimeValue initialConnectionTimeout = RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(
359-
settingsResponse.getPersistentSettings()
337+
settingsResponse.getTransientSettings()
360338
);
361339
boolean skipUnavailable = RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace(clusterAlias)
362-
.get(settingsResponse.getPersistentSettings());
340+
.get(settingsResponse.getTransientSettings());
363341

364342
RemoteInfoRequest request = new RemoteInfoRequest();
365343
RemoteInfoResponse response = execute(

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

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
import org.elasticsearch.common.Strings;
1717
import org.elasticsearch.common.io.stream.StreamInput;
1818
import org.elasticsearch.common.io.stream.StreamOutput;
19-
import org.elasticsearch.common.logging.DeprecationLogger;
2019
import org.elasticsearch.common.xcontent.StatusToXContentObject;
2120
import org.elasticsearch.core.TimeValue;
2221
import org.elasticsearch.rest.RestStatus;
23-
import org.elasticsearch.rest.action.search.RestSearchAction;
2422
import org.elasticsearch.xcontent.ConstructingObjectParser;
2523
import org.elasticsearch.xcontent.ObjectParser;
2624
import org.elasticsearch.xcontent.ParseField;
@@ -57,7 +55,6 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
5755
private static final String INITIALIZING_SHARDS = "initializing_shards";
5856
private static final String UNASSIGNED_SHARDS = "unassigned_shards";
5957
private static final String INDICES = "indices";
60-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSearchAction.class);
6158

6259
private static final ConstructingObjectParser<ClusterHealthResponse, Void> PARSER = new ConstructingObjectParser<>(
6360
"cluster_health_response",
@@ -122,12 +119,6 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
122119
XContentParser parser,
123120
Void context,
124121
String index) -> ClusterIndexHealth.innerFromXContent(parser, index);
125-
private static final String ES_CLUSTER_HEALTH_REQUEST_TIMEOUT_200_KEY = "es.cluster_health.request_timeout_200";
126-
static final String CLUSTER_HEALTH_REQUEST_TIMEOUT_DEPRECATION_MSG = "The HTTP status code for a cluster health timeout "
127-
+ "will be changed from 408 to 200 in a future version. Set the ["
128-
+ ES_CLUSTER_HEALTH_REQUEST_TIMEOUT_200_KEY
129-
+ "] "
130-
+ "system property to [true] to suppress this message and opt in to the future behaviour now.";
131122

132123
static {
133124
// ClusterStateHealth fields
@@ -160,15 +151,9 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
160151
private boolean timedOut = false;
161152
private ClusterStateHealth clusterStateHealth;
162153
private ClusterHealthStatus clusterHealthStatus;
163-
private boolean esClusterHealthRequestTimeout200 = readEsClusterHealthRequestTimeout200FromProperty();
164154

165155
public ClusterHealthResponse() {}
166156

167-
/** For the testing of opting in for the 200 status code without setting a system property */
168-
ClusterHealthResponse(boolean esClusterHealthRequestTimeout200) {
169-
this.esClusterHealthRequestTimeout200 = esClusterHealthRequestTimeout200;
170-
}
171-
172157
public ClusterHealthResponse(StreamInput in) throws IOException {
173158
super(in);
174159
clusterName = in.readString();
@@ -349,15 +334,7 @@ public String toString() {
349334

350335
@Override
351336
public RestStatus status() {
352-
if (isTimedOut() == false) {
353-
return RestStatus.OK;
354-
}
355-
if (esClusterHealthRequestTimeout200) {
356-
return RestStatus.OK;
357-
} else {
358-
deprecationLogger.compatibleCritical("cluster_health_request_timeout", CLUSTER_HEALTH_REQUEST_TIMEOUT_DEPRECATION_MSG);
359-
return RestStatus.REQUEST_TIMEOUT;
360-
}
337+
return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK;
361338
}
362339

363340
@Override
@@ -425,18 +402,4 @@ public int hashCode() {
425402
clusterHealthStatus
426403
);
427404
}
428-
429-
private static boolean readEsClusterHealthRequestTimeout200FromProperty() {
430-
String property = System.getProperty(ES_CLUSTER_HEALTH_REQUEST_TIMEOUT_200_KEY);
431-
if (property == null) {
432-
return false;
433-
}
434-
if (Boolean.parseBoolean(property)) {
435-
return true;
436-
} else {
437-
throw new IllegalArgumentException(
438-
ES_CLUSTER_HEALTH_REQUEST_TIMEOUT_200_KEY + " can only be unset or [true] but was [" + property + "]"
439-
);
440-
}
441-
}
442405
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,12 @@ public void testIsTimeout() {
4848
res.setTimedOut(randomBoolean());
4949
if (res.isTimedOut()) {
5050
assertEquals(RestStatus.REQUEST_TIMEOUT, res.status());
51-
assertWarnings(ClusterHealthResponse.CLUSTER_HEALTH_REQUEST_TIMEOUT_DEPRECATION_MSG);
5251
} else {
5352
assertEquals(RestStatus.OK, res.status());
5453
}
5554
}
5655
}
5756

58-
public void testTimeoutReturns200IfOptedIn() {
59-
ClusterHealthResponse res = new ClusterHealthResponse(true);
60-
for (int i = 0; i < 5; i++) {
61-
res.setTimedOut(randomBoolean());
62-
assertEquals(RestStatus.OK, res.status());
63-
}
64-
}
65-
6657
public void testClusterHealth() throws IOException {
6758
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).build();
6859
int pendingTasks = randomIntBetween(0, 200);

0 commit comments

Comments
 (0)