Skip to content

Commit 07c3acf

Browse files
authored
Remove cluster state from /_cluster/reroute response (#114231)
Including the cluster state in responses to the `POST _cluster/state` API was deprecated in #90399 (v8.6.0) requiring callers to pass `?metric=none` to avoid the deprecation warning. This commit adjusts the behaviour as promised in v9 so that this API never returns the cluster state, and deprecates the `?metric` parameter itself. Closes #88978
1 parent 40bddaf commit 07c3acf

File tree

16 files changed

+136
-39
lines changed

16 files changed

+136
-39
lines changed

docs/changelog/114231.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pr: 114231
2+
summary: Remove cluster state from `/_cluster/reroute` response
3+
area: Allocation
4+
type: breaking
5+
issues:
6+
- 88978
7+
breaking:
8+
title: Remove cluster state from `/_cluster/reroute` response
9+
area: REST API
10+
details: >-
11+
The `POST /_cluster/reroute` API no longer returns the cluster state in its
12+
response. The `?metric` query parameter to this API now has no effect and
13+
its use will be forbidden in a future version.
14+
impact: >-
15+
Cease usage of the `?metric` query parameter when calling the
16+
`POST /_cluster/reroute` API.
17+
notable: false

docs/reference/cluster/reroute.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Changes the allocation of shards in a cluster.
1010
[[cluster-reroute-api-request]]
1111
==== {api-request-title}
1212

13-
`POST /_cluster/reroute?metric=none`
13+
`POST /_cluster/reroute`
1414

1515
[[cluster-reroute-api-prereqs]]
1616
==== {api-prereq-title}
@@ -193,7 +193,7 @@ This is a short example of a simple reroute API call:
193193

194194
[source,console]
195195
--------------------------------------------------
196-
POST /_cluster/reroute?metric=none
196+
POST /_cluster/reroute
197197
{
198198
"commands": [
199199
{

docs/reference/commands/shard-tool.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Changing allocation id V8QXk-QXSZinZMT-NvEq4w to tjm9Ve6uTBewVFAlfUMWjA
9595
9696
You should run the following command to allocate this shard:
9797
98-
POST /_cluster/reroute?metric=none
98+
POST /_cluster/reroute
9999
{
100100
"commands" : [
101101
{

docs/reference/troubleshooting/common-issues/red-yellow-cluster-status.asciidoc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
=== Red or yellow cluster health status
33

44
A red or yellow cluster health status indicates one or more shards are not assigned to
5-
a node.
5+
a node.
66

77
* **Red health status**: The cluster has some unassigned primary shards, which
8-
means that some operations such as searches and indexing may fail.
9-
* **Yellow health status**: The cluster has no unassigned primary shards but some
10-
unassigned replica shards. This increases your risk of data loss and can degrade
8+
means that some operations such as searches and indexing may fail.
9+
* **Yellow health status**: The cluster has no unassigned primary shards but some
10+
unassigned replica shards. This increases your risk of data loss and can degrade
1111
cluster performance.
1212

1313
When your cluster has a red or yellow health status, it will continue to process
@@ -16,8 +16,8 @@ cleanup activities until the cluster returns to green health status. For instanc
1616
some <<index-lifecycle-management,{ilm-init}>> actions require the index on which they
1717
operate to have a green health status.
1818

19-
In many cases, your cluster will recover to green health status automatically.
20-
If the cluster doesn't automatically recover, then you must <<fix-red-yellow-cluster-status,manually address>>
19+
In many cases, your cluster will recover to green health status automatically.
20+
If the cluster doesn't automatically recover, then you must <<fix-red-yellow-cluster-status,manually address>>
2121
the remaining problems so management and cleanup activities can proceed.
2222

2323
[discrete]
@@ -107,7 +107,7 @@ asynchronously in the background.
107107

108108
[source,console]
109109
----
110-
POST _cluster/reroute?metric=none
110+
POST _cluster/reroute
111111
----
112112

113113
[discrete]
@@ -231,10 +231,10 @@ unassigned. See <<high-jvm-memory-pressure>>.
231231

232232
If a node containing a primary shard is lost, {es} can typically replace it
233233
using a replica on another node. If you can't recover the node and replicas
234-
don't exist or are irrecoverable, <<cluster-allocation-explain,Allocation
235-
Explain>> will report `no_valid_shard_copy` and you'll need to do one of the following:
234+
don't exist or are irrecoverable, <<cluster-allocation-explain,Allocation
235+
Explain>> will report `no_valid_shard_copy` and you'll need to do one of the following:
236236

237-
* restore the missing data from <<snapshot-restore,snapshot>>
237+
* restore the missing data from <<snapshot-restore,snapshot>>
238238
* index the missing data from its original data source
239239
* accept data loss on the index-level by running <<indices-delete-index,Delete Index>>
240240
* accept data loss on the shard-level by executing <<cluster-reroute,Cluster Reroute>> allocate_stale_primary or allocate_empty_primary command with `accept_data_loss: true`
@@ -246,7 +246,7 @@ resulting in data loss.
246246
+
247247
[source,console]
248248
----
249-
POST _cluster/reroute?metric=none
249+
POST _cluster/reroute
250250
{
251251
"commands": [
252252
{

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SnapshotBasedRecoveryIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ private void cancelShard(String indexName, int shard, String nodeName) throws IO
203203
}
204204
builder.endObject();
205205

206-
Request request = new Request(HttpPost.METHOD_NAME, "/_cluster/reroute?pretty&metric=none");
206+
Request request = new Request(HttpPost.METHOD_NAME, "/_cluster/reroute?pretty");
207207
request.setJsonEntity(Strings.toString(builder));
208208
Response response = client().performRequest(request);
209209
logger.info("--> Relocated primary to an older version {}", EntityUtils.toString(response.getEntity()));
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
"Basic sanity check":
3+
- requires:
4+
cluster_features: ["cluster.reroute.ignores_metric_param"]
5+
reason: requires this feature
6+
37
- do:
4-
cluster.reroute:
5-
metric: none
8+
cluster.reroute: {}

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.reroute/11_explain.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,25 @@ setup:
1313

1414
---
1515
"Explain API with empty command list":
16+
- requires:
17+
cluster_features: ["cluster.reroute.ignores_metric_param"]
18+
reason: requires this feature
1619

1720
- do:
1821
cluster.reroute:
1922
explain: true
2023
dry_run: true
21-
metric: none
2224
body:
2325
commands: []
2426

2527
- match: {explanations: []}
2628

2729
---
2830
"Explain API for non-existent node & shard":
31+
- requires:
32+
cluster_features: ["cluster.reroute.ignores_metric_param"]
33+
reason: requires this feature
34+
2935
- skip:
3036
features: [arbitrary_key]
3137

@@ -39,7 +45,6 @@ setup:
3945
cluster.reroute:
4046
explain: true
4147
dry_run: true
42-
metric: none
4348
body:
4449
commands:
4550
- cancel:
Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
11
---
2-
"Do not return metadata by default and produce deprecation warning":
2+
"Do not return metadata by default and emit no warning":
3+
- requires:
4+
cluster_features: ["cluster.reroute.ignores_metric_param"]
5+
reason: requires this feature
6+
7+
- do:
8+
cluster.reroute: {}
9+
- is_false: state
10+
11+
---
12+
"Do not return metadata with ?metric=none and produce deprecation warning":
13+
- requires:
14+
cluster_features: ["cluster.reroute.ignores_metric_param"]
15+
reason: requires this feature
16+
317
- skip:
418
features: [ "allowed_warnings" ]
19+
520
- do:
6-
cluster.reroute: {}
21+
cluster.reroute:
22+
metric: none
723
allowed_warnings:
8-
- "The [state] field in the response to the reroute API is deprecated and will be removed in a future version. Specify ?metric=none to adopt the future behaviour."
9-
- is_false: state.metadata
24+
- >-
25+
the [?metric] query parameter to the [POST /_cluster/reroute] API has no effect;
26+
its use will be forbidden in a future version
27+
- is_false: state
28+
1029
---
11-
"If requested return metadata and produce deprecation warning":
30+
"Do not return metadata with ?metric=metadata and produce deprecation warning":
31+
- requires:
32+
cluster_features: ["cluster.reroute.ignores_metric_param"]
33+
reason: requires this feature
34+
1235
- skip:
1336
features: [ "allowed_warnings" ]
37+
1438
- do:
1539
cluster.reroute:
1640
metric: metadata
1741
allowed_warnings:
18-
- "The [state] field in the response to the reroute API is deprecated and will be removed in a future version. Specify ?metric=none to adopt the future behaviour."
19-
- is_true: state.metadata
20-
- is_false: state.nodes
21-
42+
- >-
43+
the [?metric] query parameter to the [POST /_cluster/reroute] API has no effect;
44+
its use will be forbidden in a future version
45+
- is_false: state

server/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@
429429
org.elasticsearch.indices.IndicesFeatures,
430430
org.elasticsearch.repositories.RepositoriesFeatures,
431431
org.elasticsearch.action.admin.cluster.allocation.AllocationStatsFeatures,
432+
org.elasticsearch.rest.action.admin.cluster.ClusterRerouteFeatures,
432433
org.elasticsearch.index.mapper.MapperFeatures,
433434
org.elasticsearch.ingest.IngestGeoIpFeatures,
434435
org.elasticsearch.search.SearchFeatures,

server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.common.xcontent.ChunkedToXContentObject;
2323
import org.elasticsearch.core.RestApiVersion;
2424
import org.elasticsearch.core.UpdateForV10;
25-
import org.elasticsearch.core.UpdateForV9;
2625
import org.elasticsearch.rest.action.search.RestSearchAction;
2726
import org.elasticsearch.xcontent.ToXContent;
2827

@@ -45,7 +44,6 @@ public class ClusterRerouteResponse extends ActionResponse implements IsAcknowle
4544
/**
4645
* To be removed when REST compatibility with {@link org.elasticsearch.Version#V_8_6_0} / {@link RestApiVersion#V_8} no longer needed
4746
*/
48-
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // to remove from the v9 API only
4947
@UpdateForV10(owner = UpdateForV10.Owner.DISTRIBUTED_COORDINATION) // to remove entirely
5048
private final ClusterState state;
5149
private final RoutingExplanations explanations;

0 commit comments

Comments
 (0)