Browse Source

Merge pull request #9458 from gyuho/pre-vote

functional-tester: test pre-vote in functional-tester
Gyuho Lee 7 years ago
parent
commit
dea71f32f6

+ 7 - 21
embed/config.go

@@ -107,8 +107,6 @@ func init() {
 
 
 // Config holds the arguments for configuring an etcd server.
 // Config holds the arguments for configuring an etcd server.
 type Config struct {
 type Config struct {
-	// member
-
 	CorsInfo       *cors.CORSInfo
 	CorsInfo       *cors.CORSInfo
 	LPUrls, LCUrls []url.URL
 	LPUrls, LCUrls []url.URL
 	Dir            string `json:"data-dir"`
 	Dir            string `json:"data-dir"`
@@ -135,8 +133,6 @@ type Config struct {
 	MaxTxnOps         uint  `json:"max-txn-ops"`
 	MaxTxnOps         uint  `json:"max-txn-ops"`
 	MaxRequestBytes   uint  `json:"max-request-bytes"`
 	MaxRequestBytes   uint  `json:"max-request-bytes"`
 
 
-	// gRPC server options
-
 	// GRPCKeepAliveMinTime is the minimum interval that a client should
 	// GRPCKeepAliveMinTime is the minimum interval that a client should
 	// wait before pinging server. When client pings "too fast", server
 	// wait before pinging server. When client pings "too fast", server
 	// sends goaway and closes the connection (errors: too_many_pings,
 	// 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.
 	// before closing a non-responsive connection. 0 to disable.
 	GRPCKeepAliveTimeout time.Duration `json:"grpc-keepalive-timeout"`
 	GRPCKeepAliveTimeout time.Duration `json:"grpc-keepalive-timeout"`
 
 
-	// clustering
-
 	APUrls, ACUrls        []url.URL
 	APUrls, ACUrls        []url.URL
 	ClusterState          string `json:"initial-cluster-state"`
 	ClusterState          string `json:"initial-cluster-state"`
 	DNSCluster            string `json:"discovery-srv"`
 	DNSCluster            string `json:"discovery-srv"`
@@ -165,7 +159,12 @@ type Config struct {
 	StrictReconfigCheck   bool   `json:"strict-reconfig-check"`
 	StrictReconfigCheck   bool   `json:"strict-reconfig-check"`
 	EnableV2              bool   `json:"enable-v2"`
 	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
 	ClientTLSInfo transport.TLSInfo
 	ClientAutoTLS bool
 	ClientAutoTLS bool
@@ -198,8 +197,6 @@ type Config struct {
 	// - https://github.com/coreos/etcd/issues/9353
 	// - https://github.com/coreos/etcd/issues/9353
 	HostWhitelist []string `json:"host-whitelist"`
 	HostWhitelist []string `json:"host-whitelist"`
 
 
-	// debug
-
 	Debug                 bool   `json:"debug"`
 	Debug                 bool   `json:"debug"`
 	LogPkgLevels          string `json:"log-package-levels"`
 	LogPkgLevels          string `json:"log-package-levels"`
 	LogOutput             string `json:"log-output"`
 	LogOutput             string `json:"log-output"`
@@ -225,22 +222,11 @@ type Config struct {
 	//	embed.StartEtcd(cfg)
 	//	embed.StartEtcd(cfg)
 	ServiceRegister func(*grpc.Server) `json:"-"`
 	ServiceRegister func(*grpc.Server) `json:"-"`
 
 
-	// auth
-
 	AuthToken string `json:"auth-token"`
 	AuthToken string `json:"auth-token"`
 
 
-	// Experimental flags
-
 	ExperimentalInitialCorruptCheck bool          `json:"experimental-initial-corrupt-check"`
 	ExperimentalInitialCorruptCheck bool          `json:"experimental-initial-corrupt-check"`
 	ExperimentalCorruptCheckTime    time.Duration `json:"experimental-corrupt-check-time"`
 	ExperimentalCorruptCheckTime    time.Duration `json:"experimental-corrupt-check-time"`
 	ExperimentalEnableV2V3          string        `json:"experimental-enable-v2v3"`
 	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
 // configYAML holds the config suitable for yaml parsing
@@ -300,7 +286,7 @@ func NewConfig() *Config {
 		EnableV2:              DefaultEnableV2,
 		EnableV2:              DefaultEnableV2,
 		HostWhitelist:         defaultHostWhitelist,
 		HostWhitelist:         defaultHostWhitelist,
 		AuthToken:             "simple",
 		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)
 	cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name)
 	return cfg
 	return cfg

+ 1 - 1
embed/etcd.go

@@ -171,7 +171,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
 		AuthToken:               cfg.AuthToken,
 		AuthToken:               cfg.AuthToken,
 		InitialCorruptCheck:     cfg.ExperimentalInitialCorruptCheck,
 		InitialCorruptCheck:     cfg.ExperimentalInitialCorruptCheck,
 		CorruptCheckTime:        cfg.ExperimentalCorruptCheckTime,
 		CorruptCheckTime:        cfg.ExperimentalCorruptCheckTime,
-		PreVote:                 cfg.ExperimentalPreVote,
+		PreVote:                 cfg.PreVote,
 		Debug:                   cfg.Debug,
 		Debug:                   cfg.Debug,
 	}
 	}
 
 

+ 2 - 3
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.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.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
 	// proxy
 	fs.Var(cfg.cf.proxy, "proxy", fmt.Sprintf("Valid values include %q", cfg.cf.proxy.Valids()))
 	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.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.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.")
 	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
 	// 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.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.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
 	// ignored
 	for _, f := range cfg.ignored {
 	for _, f := range cfg.ignored {

+ 3 - 5
etcdmain/help.go

@@ -104,6 +104,8 @@ clustering flags:
 		suffix to the dns srv name queried when bootstrapping.
 		suffix to the dns srv name queried when bootstrapping.
 	--strict-reconfig-check '` + strconv.FormatBool(embed.DefaultStrictReconfigCheck) + `'
 	--strict-reconfig-check '` + strconv.FormatBool(embed.DefaultStrictReconfigCheck) + `'
 		reject reconfiguration requests that would cause quorum loss.
 		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 '0'
 		auto compaction retention length. 0 means disable auto compaction.
 		auto compaction retention length. 0 means disable auto compaction.
 	--auto-compaction-mode 'periodic'
 	--auto-compaction-mode 'periodic'
@@ -111,8 +113,7 @@ clustering flags:
 	--enable-v2 '` + strconv.FormatBool(embed.DefaultEnableV2) + `'
 	--enable-v2 '` + strconv.FormatBool(embed.DefaultEnableV2) + `'
 		Accept etcd V2 client requests.
 		Accept etcd V2 client requests.
 
 
-proxy flags:
-	"proxy" supports v2 API only.
+proxy flags (v2 API only):
 
 
 	--proxy 'off'
 	--proxy 'off'
 		proxy mode setting ('off', 'readonly' or 'on').
 		proxy mode setting ('off', 'readonly' or 'on').
@@ -127,7 +128,6 @@ proxy flags:
 	--proxy-read-timeout 0
 	--proxy-read-timeout 0
 		time (in milliseconds) for a read to timeout.
 		time (in milliseconds) for a read to timeout.
 
 
-
 security flags:
 security flags:
 
 
 	--ca-file '' [DEPRECATED]
 	--ca-file '' [DEPRECATED]
@@ -197,7 +197,5 @@ experimental flags:
 		duration of time between cluster corruption check passes.
 		duration of time between cluster corruption check passes.
 	--experimental-enable-v2v3 ''
 	--experimental-enable-v2v3 ''
 		serve v2 requests through the v3 backend under a given prefix.
 		serve v2 requests through the v3 backend under a given prefix.
-	--experimental-pre-vote 'false'
-		enable to run an additional Raft election phase.
 `
 `
 )
 )

+ 1 - 1
tools/functional-tester/etcd-tester/cluster.go

@@ -82,7 +82,7 @@ func (c *cluster) bootstrap() error {
 			m.Flags(),
 			m.Flags(),
 			"--initial-cluster-token", token,
 			"--initial-cluster-token", token,
 			"--initial-cluster", clusterStr,
 			"--initial-cluster", clusterStr,
-			"--snapshot-count", "10000")
+		)
 
 
 		if _, err := m.Agent.Start(flags...); err != nil {
 		if _, err := m.Agent.Start(flags...); err != nil {
 			// cleanup
 			// cleanup

+ 4 - 2
tools/functional-tester/etcd-tester/member.go

@@ -49,6 +49,8 @@ func (m *member) Flags() []string {
 		"--listen-peer-urls", m.PeerURL,
 		"--listen-peer-urls", m.PeerURL,
 		"--initial-advertise-peer-urls", m.AdvertisePeerURL,
 		"--initial-advertise-peer-urls", m.AdvertisePeerURL,
 		"--initial-cluster-state", "new",
 		"--initial-cluster-state", "new",
+		"--snapshot-count", "10000",
+		"--pre-vote",
 		"--experimental-initial-corrupt-check",
 		"--experimental-initial-corrupt-check",
 	}
 	}
 }
 }
@@ -76,7 +78,7 @@ func (m *member) CheckCompact(rev int64) error {
 }
 }
 
 
 func (m *member) Defrag() error {
 func (m *member) Defrag() error {
-	plog.Printf("defragmenting %s\n", m.AdvertiseClientURL)
+	plog.Printf("defragmenting %s", m.AdvertiseClientURL)
 	cli, err := m.newClientV3()
 	cli, err := m.newClientV3()
 	if err != nil {
 	if err != nil {
 		return err
 		return err
@@ -88,7 +90,7 @@ func (m *member) Defrag() error {
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	plog.Printf("defragmented %s\n", m.AdvertiseClientURL)
+	plog.Printf("defragmented %s", m.AdvertiseClientURL)
 	return nil
 	return nil
 }
 }