mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
chore(standby): minor changes based on comments
This commit is contained in:
@@ -11,10 +11,10 @@ const (
|
||||
// MinActiveSize is the minimum active size allowed.
|
||||
MinActiveSize = 3
|
||||
|
||||
// DefaultRemoveDelay is the default elapsed time before promotion.
|
||||
// DefaultRemoveDelay is the default elapsed time before removal.
|
||||
DefaultRemoveDelay = int((30 * time.Minute) / time.Second)
|
||||
|
||||
// MinRemoveDelay is the minimum promote delay allowed.
|
||||
// MinRemoveDelay is the minimum remove delay allowed.
|
||||
MinRemoveDelay = int((2 * time.Second) / time.Second)
|
||||
|
||||
// DefaultSyncInterval is the default interval for cluster sync.
|
||||
|
||||
@@ -372,8 +372,8 @@ func (s *PeerServer) ClusterConfig() *ClusterConfig {
|
||||
}
|
||||
|
||||
// SetClusterConfig updates the current cluster configuration.
|
||||
// Adjusting the active size will cause the PeerServer to demote peers or
|
||||
// promote standbys to match the new size.
|
||||
// Adjusting the active size will cause cluster to add or remove machines
|
||||
// to match the new size.
|
||||
func (s *PeerServer) SetClusterConfig(c *ClusterConfig) {
|
||||
// Set minimums.
|
||||
if c.ActiveSize < MinActiveSize {
|
||||
@@ -820,7 +820,7 @@ func (s *PeerServer) monitorPeerActivity() {
|
||||
removeDelay := time.Duration(s.ClusterConfig().RemoveDelay) * time.Second
|
||||
peers := s.raftServer.Peers()
|
||||
for _, peer := range peers {
|
||||
// If the last response from the peer is longer than the promote delay
|
||||
// If the last response from the peer is longer than the remove delay
|
||||
// then automatically demote the peer.
|
||||
if !peer.LastActivity().IsZero() && now.Sub(peer.LastActivity()) > removeDelay {
|
||||
log.Infof("%s: removing node: %v; last activity %v ago", s.Config.Name, peer.Name, now.Sub(peer.LastActivity()))
|
||||
|
||||
@@ -221,7 +221,6 @@ func (ps *PeerServer) setClusterConfigHttpHandler(w http.ResponseWriter, req *ht
|
||||
}
|
||||
|
||||
// Retrieves a list of peers and standbys.
|
||||
// If leader exists, it is at the first place.
|
||||
func (ps *PeerServer) getMachinesHttpHandler(w http.ResponseWriter, req *http.Request) {
|
||||
machines := make([]*machineMessage, 0)
|
||||
leader := ps.raftServer.Leader()
|
||||
|
||||
Reference in New Issue
Block a user