From a66e657cac9d0246681024ec6340f944e97a52b3 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Sat, 17 Mar 2018 20:19:18 -0700 Subject: [PATCH 1/2] *: update "pre-vote" flag Disabled by default, anyway. Signed-off-by: Gyuho Lee --- embed/config.go | 28 +++++++--------------------- embed/etcd.go | 2 +- etcdmain/config.go | 5 ++--- etcdmain/help.go | 8 +++----- 4 files changed, 13 insertions(+), 30 deletions(-) diff --git a/embed/config.go b/embed/config.go index b5ffbb13d..0673fcf87 100644 --- a/embed/config.go +++ b/embed/config.go @@ -107,8 +107,6 @@ func init() { // Config holds the arguments for configuring an etcd server. type Config struct { - // member - CorsInfo *cors.CORSInfo LPUrls, LCUrls []url.URL Dir string `json:"data-dir"` @@ -135,8 +133,6 @@ type Config struct { MaxTxnOps uint `json:"max-txn-ops"` MaxRequestBytes uint `json:"max-request-bytes"` - // gRPC server options - // GRPCKeepAliveMinTime is the minimum interval that a client should // wait before pinging server. When client pings "too fast", server // sends goaway and closes the connection (errors: too_many_pings, @@ -152,8 +148,6 @@ type Config struct { // before closing a non-responsive connection. 0 to disable. GRPCKeepAliveTimeout time.Duration `json:"grpc-keepalive-timeout"` - // clustering - APUrls, ACUrls []url.URL ClusterState string `json:"initial-cluster-state"` DNSCluster string `json:"discovery-srv"` @@ -165,7 +159,12 @@ type Config struct { StrictReconfigCheck bool `json:"strict-reconfig-check"` EnableV2 bool `json:"enable-v2"` - // security + // PreVote is true to enable Raft Pre-Vote. + // If enabled, Raft runs an additional election phase + // to check whether it would get enough votes to win + // an election, thus minimizing disruptions. + // TODO: enable by default in 3.5. + PreVote bool `json:"pre-vote"` ClientTLSInfo transport.TLSInfo ClientAutoTLS bool @@ -198,8 +197,6 @@ type Config struct { // - https://github.com/coreos/etcd/issues/9353 HostWhitelist []string `json:"host-whitelist"` - // debug - Debug bool `json:"debug"` LogPkgLevels string `json:"log-package-levels"` LogOutput string `json:"log-output"` @@ -225,22 +222,11 @@ type Config struct { // embed.StartEtcd(cfg) ServiceRegister func(*grpc.Server) `json:"-"` - // auth - AuthToken string `json:"auth-token"` - // Experimental flags - ExperimentalInitialCorruptCheck bool `json:"experimental-initial-corrupt-check"` ExperimentalCorruptCheckTime time.Duration `json:"experimental-corrupt-check-time"` ExperimentalEnableV2V3 string `json:"experimental-enable-v2v3"` - - // ExperimentalPreVote is true to enable Raft Pre-Vote. - // If enabled, Raft runs an additional election phase - // to check whether it would get enough votes to win - // an election, thus minimizing disruptions. - // TODO: change to "pre-vote" and enable by default in 3.5. - ExperimentalPreVote bool `json:"experimental-pre-vote"` } // configYAML holds the config suitable for yaml parsing @@ -300,7 +286,7 @@ func NewConfig() *Config { EnableV2: DefaultEnableV2, HostWhitelist: defaultHostWhitelist, AuthToken: "simple", - ExperimentalPreVote: false, // TODO: enable by default in v3.5 + PreVote: false, // TODO: enable by default in v3.5 } cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name) return cfg diff --git a/embed/etcd.go b/embed/etcd.go index 78fbca461..029d5fb6e 100644 --- a/embed/etcd.go +++ b/embed/etcd.go @@ -171,7 +171,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) { AuthToken: cfg.AuthToken, InitialCorruptCheck: cfg.ExperimentalInitialCorruptCheck, CorruptCheckTime: cfg.ExperimentalCorruptCheckTime, - PreVote: cfg.ExperimentalPreVote, + PreVote: cfg.PreVote, Debug: cfg.Debug, } diff --git a/etcdmain/config.go b/etcdmain/config.go index 4bef82781..49a3529a5 100644 --- a/etcdmain/config.go +++ b/etcdmain/config.go @@ -162,11 +162,10 @@ func newConfig() *config { fs.BoolVar(&cfg.ec.StrictReconfigCheck, "strict-reconfig-check", cfg.ec.StrictReconfigCheck, "Reject reconfiguration requests that would cause quorum loss.") fs.BoolVar(&cfg.ec.EnableV2, "enable-v2", cfg.ec.EnableV2, "Accept etcd V2 client requests.") - fs.StringVar(&cfg.ec.ExperimentalEnableV2V3, "experimental-enable-v2v3", cfg.ec.ExperimentalEnableV2V3, "v3 prefix for serving emulated v2 state.") + fs.BoolVar(&cfg.ec.PreVote, "pre-vote", cfg.ec.PreVote, "Enable to run an additional Raft election phase.") // proxy fs.Var(cfg.cf.proxy, "proxy", fmt.Sprintf("Valid values include %q", cfg.cf.proxy.Valids())) - fs.UintVar(&cfg.cp.ProxyFailureWaitMs, "proxy-failure-wait", cfg.cp.ProxyFailureWaitMs, "Time (in milliseconds) an endpoint will be held in a failed state.") fs.UintVar(&cfg.cp.ProxyRefreshIntervalMs, "proxy-refresh-interval", cfg.cp.ProxyRefreshIntervalMs, "Time (in milliseconds) of the endpoints refresh interval.") fs.UintVar(&cfg.cp.ProxyDialTimeoutMs, "proxy-dial-timeout", cfg.cp.ProxyDialTimeoutMs, "Time (in milliseconds) for a dial to timeout.") @@ -217,7 +216,7 @@ func newConfig() *config { // experimental fs.BoolVar(&cfg.ec.ExperimentalInitialCorruptCheck, "experimental-initial-corrupt-check", cfg.ec.ExperimentalInitialCorruptCheck, "Enable to check data corruption before serving any client/peer traffic.") fs.DurationVar(&cfg.ec.ExperimentalCorruptCheckTime, "experimental-corrupt-check-time", cfg.ec.ExperimentalCorruptCheckTime, "Duration of time between cluster corruption check passes.") - fs.BoolVar(&cfg.ec.ExperimentalPreVote, "experimental-pre-vote", cfg.ec.ExperimentalPreVote, "Enable to run an additional Raft election phase.") + fs.StringVar(&cfg.ec.ExperimentalEnableV2V3, "experimental-enable-v2v3", cfg.ec.ExperimentalEnableV2V3, "v3 prefix for serving emulated v2 state.") // ignored for _, f := range cfg.ignored { diff --git a/etcdmain/help.go b/etcdmain/help.go index a806bc5db..9fc38f9b3 100644 --- a/etcdmain/help.go +++ b/etcdmain/help.go @@ -104,6 +104,8 @@ clustering flags: suffix to the dns srv name queried when bootstrapping. --strict-reconfig-check '` + strconv.FormatBool(embed.DefaultStrictReconfigCheck) + `' reject reconfiguration requests that would cause quorum loss. + --pre-vote 'false' + enable to run an additional Raft election phase. --auto-compaction-retention '0' auto compaction retention length. 0 means disable auto compaction. --auto-compaction-mode 'periodic' @@ -111,8 +113,7 @@ clustering flags: --enable-v2 '` + strconv.FormatBool(embed.DefaultEnableV2) + `' Accept etcd V2 client requests. -proxy flags: - "proxy" supports v2 API only. +proxy flags (v2 API only): --proxy 'off' proxy mode setting ('off', 'readonly' or 'on'). @@ -127,7 +128,6 @@ proxy flags: --proxy-read-timeout 0 time (in milliseconds) for a read to timeout. - security flags: --ca-file '' [DEPRECATED] @@ -197,7 +197,5 @@ experimental flags: duration of time between cluster corruption check passes. --experimental-enable-v2v3 '' serve v2 requests through the v3 backend under a given prefix. - --experimental-pre-vote 'false' - enable to run an additional Raft election phase. ` ) From 813c9aa4504aef7c38243e95ee5c5879704a354e Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Sat, 17 Mar 2018 20:22:41 -0700 Subject: [PATCH 2/2] functional-tester: enable "--pre-vote" Signed-off-by: Gyuho Lee --- tools/functional-tester/etcd-tester/cluster.go | 2 +- tools/functional-tester/etcd-tester/member.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/functional-tester/etcd-tester/cluster.go b/tools/functional-tester/etcd-tester/cluster.go index 0491337c3..92cbd418d 100644 --- a/tools/functional-tester/etcd-tester/cluster.go +++ b/tools/functional-tester/etcd-tester/cluster.go @@ -82,7 +82,7 @@ func (c *cluster) bootstrap() error { m.Flags(), "--initial-cluster-token", token, "--initial-cluster", clusterStr, - "--snapshot-count", "10000") + ) if _, err := m.Agent.Start(flags...); err != nil { // cleanup diff --git a/tools/functional-tester/etcd-tester/member.go b/tools/functional-tester/etcd-tester/member.go index bb129753d..2e3eef4db 100644 --- a/tools/functional-tester/etcd-tester/member.go +++ b/tools/functional-tester/etcd-tester/member.go @@ -49,6 +49,8 @@ func (m *member) Flags() []string { "--listen-peer-urls", m.PeerURL, "--initial-advertise-peer-urls", m.AdvertisePeerURL, "--initial-cluster-state", "new", + "--snapshot-count", "10000", + "--pre-vote", "--experimental-initial-corrupt-check", } } @@ -76,7 +78,7 @@ func (m *member) CheckCompact(rev int64) error { } func (m *member) Defrag() error { - plog.Printf("defragmenting %s\n", m.AdvertiseClientURL) + plog.Printf("defragmenting %s", m.AdvertiseClientURL) cli, err := m.newClientV3() if err != nil { return err @@ -88,7 +90,7 @@ func (m *member) Defrag() error { if err != nil { return err } - plog.Printf("defragmented %s\n", m.AdvertiseClientURL) + plog.Printf("defragmented %s", m.AdvertiseClientURL) return nil }