Get shutdown API

edit

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

Retrieves the status of a node that’s being prepared for shutdown.

Request

edit

GET _nodes/shutdown

GET _nodes/<node-id>/shutdown

Prerequisites

edit

Description

edit

Indicates whether a node is ready to be shut down, or if shut down preparations are still in progress or have stalled. Returns status information for each part of the shut down process. Use to monitor the shut down process after calling put shutdown.

Path parameters

edit
<node-id>
(Optional, string) The ID of a node that is being prepared for shutdown. If no ID is specified, returns the status of all nodes being prepared for shutdown.

Query parameters

edit
master_timeout
(Optional, time units) Period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. Defaults to 30s. Can also be set to -1 to indicate that the request should never timeout.
timeout
(Optional, time units) Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s.

Examples

edit

Prepare a node to be restarted:

response = client.shutdown.put_node(
  node_id: 'USpTGYaBSIKbgSUJR2Z9lg',
  body: {
    type: 'restart',
    reason: 'Demonstrating how the node shutdown API works',
    allocation_delay: '10m'
  }
)
puts response
PUT /_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown
{
  "type": "restart",
  "reason": "Demonstrating how the node shutdown API works",
  "allocation_delay": "10m"
}

Get the status of the shutdown preparations:

response = client.shutdown.get_node(
  node_id: 'USpTGYaBSIKbgSUJR2Z9lg'
)
puts response
GET /_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown

The response shows information about the shutdown preparations, including the status of shard migration, task migration, and plugin cleanup:

{
    "nodes": [
        {
            "node_id": "USpTGYaBSIKbgSUJR2Z9lg",
            "type": "RESTART",
            "reason": "Demonstrating how the node shutdown API works",
            "shutdown_startedmillis": 1624406108685,
            "allocation_delay": "10m",
            "status": "COMPLETE",
            "shard_migration": {
                "status": "COMPLETE",
                "shard_migrations_remaining": 0,
                "explanation": "no shard relocation is necessary for a node restart"
            },
            "persistent_tasks": {
                "status": "COMPLETE"
            },
            "plugins": {
                "status": "COMPLETE"
            }
        }
    ]
}