mirror of
https://github.com/datarhei/core.git
synced 2025-10-25 00:40:38 +08:00
Make emergency leadership only available in a cluster with two nodes
This commit is contained in:
@@ -1697,6 +1697,11 @@ func (c *cluster) sentinel() {
|
||||
"num_peers": stats.NumPeers,
|
||||
}).Log("Stats")
|
||||
|
||||
if stats.NumPeers > 1 {
|
||||
// Enable emergency leadership only in a configuration with two nodes.
|
||||
break
|
||||
}
|
||||
|
||||
if stats.LastContact > c.emergencyLeaderTimeout && !isEmergencyLeader {
|
||||
c.logger.Warn().Log("Force leadership due to lost contact to leader")
|
||||
c.raftEmergencyNotifyCh <- true
|
||||
|
||||
@@ -348,10 +348,7 @@ func (c *cluster) synchronizeAndRebalance(ctx context.Context, interval time.Dur
|
||||
}
|
||||
|
||||
c.doSynchronize(emergency)
|
||||
|
||||
if !emergency {
|
||||
c.doRebalance(emergency)
|
||||
}
|
||||
c.doRebalance(emergency)
|
||||
} else {
|
||||
c.doSynchronize(emergency)
|
||||
}
|
||||
@@ -588,6 +585,11 @@ func (c *cluster) doSynchronize(emergency bool) {
|
||||
}
|
||||
|
||||
func (c *cluster) doRebalance(emergency bool) {
|
||||
if emergency {
|
||||
// Don't rebalance in emergency mode
|
||||
return
|
||||
}
|
||||
|
||||
have := c.proxy.ListProxyProcesses()
|
||||
nodes := c.proxy.ListNodes()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user