Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions consul/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,26 @@ def force_leave(self, node, token=None):
CB.bool(),
path='/v1/agent/force-leave/%s' % node, headers=headers)

def leave(self, node, token=None):
"""
This endpoint instructs the agent to graceful leave a node.
It is used to ensure other nodes see the agent as "left"
instead of "failed". Nodes that leave will not attempt to
re-join the cluster on restarting with a snapshot. For nodes
in server mode, the node is removed from the Raft peer
set in a graceful manner. This is critical, as in certain
situations a non-graceful leave can affect cluster availability.

*node* is the node to change state for.
"""
headers = {}
token = token or self.agent.token
if token:
headers['X-Consul-Token'] = token

return self.agent.http.put(
CB.bool(), '/v1/agent/leave/%s' % node, headers=headers)

class Service(object):
def __init__(self, agent):
self.agent = agent
Expand Down