elasticsearch icon indicating copy to clipboard operation
elasticsearch copied to clipboard

`/_cluster/reroute` should not return a cluster state in its response

Open idegtiarenko opened this issue 2 years ago • 4 comments

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.

idegtiarenko avatar Aug 01 '22 07:08 idegtiarenko

Pinging @elastic/es-distributed (Team:Distributed)

elasticsearchmachine avatar Aug 01 '22 07:08 elasticsearchmachine

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.

VimCommando avatar Aug 11 '22 01:08 VimCommando

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
# }

DaveCTurner avatar Aug 11 '22 09:08 DaveCTurner

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.

DaveCTurner avatar Sep 05 '22 10:09 DaveCTurner

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.

volodk85 avatar Jun 06 '23 17:06 volodk85