Prevalidate node removal APIedit

This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported.

Prevalidate node removal.

Requestedit

POST /_internal/prevalidate_node_removal

Prerequisitesedit

  • If the Elasticsearch security features are enabled, you must have the monitor or manage cluster privilege to use this API.

Descriptionedit

This API checks whether attempting to remove the specified node(s) from the cluster is likely to succeed or not. For a cluster with no unassigned shards, removal of any node is considered safe which means the removal of the nodes is likely to succeed. In case the cluster has a red cluster health status, it verifies that the removal of the node(s) would not risk removing the last remaining copy of an unassigned shard.

The response includes the overall safety of the removal of the specified nodes, and a detailed response for each node. The node-specific part of the response also includes more details on why removal of that node might not succeed.

Note that only one of the query parameters (names, ids, or external_ids) must be used to specify the set of nodes.

Note that if the prevalidation result for a set of nodes returns true (i.e. it is likely to succeed), this does not mean that all those nodes could be successfully removed at once, but rather removal of each individual node would potentially be successful. The actual node removal could be handled via the Node lifecycle API.

Query parametersedit

master_timeout
(Optional, time units) Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s.
names
(Optional, string) Comma-separated list of node names.
ids
(Optional, string) Comma-separated list of node IDs.
external_ids
(Optional, string) Comma-separated list of node external IDs.

Response bodyedit

is_safe
(boolean) Whether the removal of all the provided nodes is safe or not.
message
(string) A message providing more detail on why the operation is considered safe or not.
nodes
(object) Prevalidation result for the removal of each of the provided nodes.

Examplesedit

This example validates whether it is safe to remove the nodes node1 and node2. The response indicates that it is safe to remove node1, but it might not be safe to remove node2. Therefore, the overall prevalidation of the removal of the two nodes returns false.

POST /_internal/prevalidate_node_removal?names=node1,node2

The API returns the following response:

{
  "is_safe": false,
  "message": "cluster health is RED",
  "nodes": [
    {
      "id": "node1-id",
      "name" : "node1",
      "external_id" : "node1-externalId",
      "result" : {
        "is_safe": true,
        "message": ""
      }
    },
    {
      "id": "node2-id",
      "name" : "node2",
      "external_id" : "node2-externalId",
      "result" : {
        "is_safe": false,
        "message": "node may contain a copy of a red index shard"
      }
    }
  ]
}