Introduction
Consul requires a majority vote from the predefined quorum of nodes to bootstrap the cluster. Server nodes inside a cluster become voters to elect a leader of the cluster, and this process is known as the leader election. The active Consul nodes participating in the leader election are known as voters and contribute to the election as a means to elect leader nodes within the cluster.
Consul uses Raft as the consensus protocol which is used during leader elections. A healthy cluster will have all server nodes available to vote in the election, however, there are times when a Consul server will be demoted or removed as a voter from the cluster.
It is important to understand that the release of Consul that is being used is important in determining reasons why a voter can get removed or demoted. In the open-source releases of Consul the cluster is maintained by the server administrator, however, Consul Enterprise edition introduces automated features that can perform operations that will cause a voter to get demoted, or removed from the cluster. When using the open-source release of Consul most of the reasons a voter will get demoted, or removed, is due to an unhealthy agent, but this is not as simple in the Enterprise version.
OSS vs Enterprise
Open Source
Consul voters will only be removed if the node fails, or leaves as determined via gossip.
-
Node status observed through gossip
Enterprise
Enterprise Consul introduces automated features from Autopilot which can add more situations where a voter might be demoted or removed from the cluster. In addition, similar to Open Source voters can be removed, or demoted in the cluster if it’s determined that the node is either unhealthy or left the cluster.
-
Node status observed through gossip
-
-
Auto-Upgrade Process
-
Old version nodes will get demoted when new target version voters are promoted
-
The Add new servers section in the Automate Upgrades with Consul Enterprise tutorial explains when this happens
-
Note: If the option disable_upgrade_migration is set to
true
, the voters will not be rotated out of the cluster automatically.-
In case the feature is disabled (
disable-upgrade-migration=true
) in your datacenter you can enable it using theconsul operator autopilot set-config -disable-upgrade-migration=false
command.
-
-
-
-
Redundant extra voters in a zone will be demoted once a healthy replacement in another zone is available.
-
Redundancy zones will do whatever is necessary to keep 1 voter per zone.
-
Total Zone Failure
-
Autopilot will do anything necessary to ensure the right number of voters remains
-
It is possible that multiple voters will exist in one zone, however, the extra voter will be first to be demoted once the failed zone becomes healthy again.
-
-
-
-
Unhealthy servers in a zone will be demoted/removed
-
When AutoPilot is disabled there is a 72-hour delay until unhealthy servers are removed from the cluster.
-
-
FAQ
Question |
Answer |
---|---|
How do I know if a server agent is currently a voter in the cluster? |
On a server agent run the command:
Simply review the “Voter” column from the output of this command.
|
What kind of agent is eligible to become a voter? |
Only server agents are able to become a voter in Consul. |
Why can’t client agents participate in the leader election? |
Because a client agent is not able to become a leader within the cluster it is ineligible to vote in the leader election. All participating voters within an election are candidates to become the leader. Any requests sent to client agents will be forwarded to the leader server agent of the cluster. |
How can I remove a voter from the cluster? |
To remove a voter from the cluster and raft, you will need to use the Consul CLI remove-peer command. |