elasticsearch
elasticsearch copied to clipboard
`/_cluster/reroute` should not return a cluster state in its response
Description
Currently the result of POST /_cluster/reroute
command execution contains the entire cluster state after it was applied.
Probably it was added there to provide the user with overview of a shards allocation after command was executed, however cluster state is excessive for it, not documented, might cause OOM in smaller clusters while rendering and contains a lot of unnecessary details. I believe it should be removed from the response or replaced with some other shard allocation representation.
Pinging @elastic/es-distributed (Team:Distributed)
On very large clusters this can generate a response in the hundreds of megabytes. Manually calling the _cluster/reroute
typically happens when there is already some kind of issue in the cluster, this extra load does not help the situation.
Note that you can use the ?metric
parameter to restrict the parts of the cluster state returned:
POST /_cluster/reroute?metric=master_node
# 200 OK
# {
# "state": {
# "master_node": "wFnm6YfiQ_-JqbxfU5OMww",
# "cluster_uuid": "8vjr7qRkQ_qwKDMMIl_D8g"
# },
# "acknowledged": true
# }
POST /_cluster/reroute?metric=version
# 200 OK
# {
# "state": {
# "state_uuid": "jmcvChe8Tsi5rPYBqYFt6w",
# "version": 2533155,
# "cluster_uuid": "8vjr7qRkQ_qwKDMMIl_D8g"
# },
# "acknowledged": true
# }
In fact there's no validation of this parameter so you can get the absolute minimal output by setting it to a nonexistent metric name:
POST /_cluster/reroute?metric=_none
# 200 OK
# {
# "state": {
# "cluster_uuid": "8vjr7qRkQ_qwKDMMIl_D8g"
# },
# "acknowledged": true
# }
We discussed this internally and agreed that ?metric=none
will remove the state
field altogether, and other values of ?metric
will be deprecated and removed in the next major. Omitting ?metric
will also be deprecated, and its behaviour will change in the next major to be equivalent to ?metric=none
.
The issue is sitting in silos until 9.0.x work is started. Development is done and is awaiting right moment for review and merge.