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:
@@ -14,7 +14,7 @@ Standbys also act as standby nodes in the event that a peer node in the cluster
|
|||||||
There are three configuration parameters used by standbys: active size, remove delay and standby sync interval.
|
There are three configuration parameters used by standbys: active size, remove delay and standby sync interval.
|
||||||
|
|
||||||
The active size specifies a target size for the number of peers in the cluster.
|
The active size specifies a target size for the number of peers in the cluster.
|
||||||
If there are not enough peers to meet the active size then, standbys will send join requests until the peer count is equal to the active size.
|
If there are not enough peers to meet the active size, standbys will send join requests until the peer count is equal to the active size.
|
||||||
If there are more peers than the target active size then peers are removed by the leader and will become standbys.
|
If there are more peers than the target active size then peers are removed by the leader and will become standbys.
|
||||||
|
|
||||||
The remove delay specifies how long the cluster should wait before removing a dead peer.
|
The remove delay specifies how long the cluster should wait before removing a dead peer.
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ func (e *Etcd) runServer() {
|
|||||||
var removeNotify <-chan bool
|
var removeNotify <-chan bool
|
||||||
for {
|
for {
|
||||||
if e.mode == PeerMode {
|
if e.mode == PeerMode {
|
||||||
log.Infof("%v starts to run in peer mode", e.Config.Name)
|
log.Infof("%v starting in peer mode", e.Config.Name)
|
||||||
// Starting peer server should be followed close by listening on its port
|
// Starting peer server should be followed close by listening on its port
|
||||||
// If not, it may leave many requests unaccepted, or cannot receive heartbeat from the cluster.
|
// If not, it may leave many requests unaccepted, or cannot receive heartbeat from the cluster.
|
||||||
// One severe problem caused if failing receiving heartbeats is when the second node joins one-node cluster,
|
// One severe problem caused if failing receiving heartbeats is when the second node joins one-node cluster,
|
||||||
@@ -301,7 +301,7 @@ func (e *Etcd) runServer() {
|
|||||||
e.PeerServer.Start(e.Config.Snapshot, e.Config.ClusterConfig())
|
e.PeerServer.Start(e.Config.Snapshot, e.Config.ClusterConfig())
|
||||||
removeNotify = e.PeerServer.RemoveNotify()
|
removeNotify = e.PeerServer.RemoveNotify()
|
||||||
} else {
|
} else {
|
||||||
log.Infof("%v starts to run in standby mode", e.Config.Name)
|
log.Infof("%v starting in standby mode", e.Config.Name)
|
||||||
e.StandbyServer.Start()
|
e.StandbyServer.Start()
|
||||||
removeNotify = e.StandbyServer.RemoveNotify()
|
removeNotify = e.StandbyServer.RemoveNotify()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ import (
|
|||||||
"github.com/coreos/etcd/store"
|
"github.com/coreos/etcd/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
const UninitedSyncInterval = time.Duration(5) * time.Second
|
|
||||||
|
|
||||||
type StandbyServerConfig struct {
|
type StandbyServerConfig struct {
|
||||||
Name string
|
Name string
|
||||||
PeerScheme string
|
PeerScheme string
|
||||||
@@ -44,7 +42,7 @@ func NewStandbyServer(config StandbyServerConfig, client *Client) *StandbyServer
|
|||||||
return &StandbyServer{
|
return &StandbyServer{
|
||||||
Config: config,
|
Config: config,
|
||||||
client: client,
|
client: client,
|
||||||
syncInterval: UninitedSyncInterval,
|
syncInterval: time.Duration(int64(DefaultSyncInterval * float64(time.Second))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +207,7 @@ func (s *StandbyServer) join(peer string) error {
|
|||||||
// Our version must match the leaders version
|
// Our version must match the leaders version
|
||||||
version, err := s.client.GetVersion(peer)
|
version, err := s.client.GetVersion(peer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("fail checking join version")
|
log.Debugf("error getting peer version")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if version < store.MinVersion() || version > store.MaxVersion() {
|
if version < store.MinVersion() || version > store.MaxVersion() {
|
||||||
@@ -220,7 +218,7 @@ func (s *StandbyServer) join(peer string) error {
|
|||||||
// Fetch cluster config to see whether exists some place.
|
// Fetch cluster config to see whether exists some place.
|
||||||
clusterConfig, err := s.client.GetClusterConfig(peer)
|
clusterConfig, err := s.client.GetClusterConfig(peer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("fail getting cluster config")
|
log.Debugf("error getting cluster config")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if clusterConfig.ActiveSize <= len(s.Cluster()) {
|
if clusterConfig.ActiveSize <= len(s.Cluster()) {
|
||||||
@@ -237,7 +235,7 @@ func (s *StandbyServer) join(peer string) error {
|
|||||||
EtcdURL: s.Config.ClientURL,
|
EtcdURL: s.Config.ClientURL,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("fail on join request")
|
log.Debugf("error on join request")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.joinIndex = commitIndex
|
s.joinIndex = commitIndex
|
||||||
|
|||||||
Reference in New Issue
Block a user