Commit 085a3b29 authored by Brad Davidson's avatar Brad Davidson

Make etcd voting members responsible for managing learners (#2399)

* Set etcd timeouts using values from k8s instead of etcdctl Fix for one of the warnings from #2303 * Use etcd zap logger instead of deprecated capsnlog Fix for one of the warnings from #2303 * Remove member self-promotion code paths * Add learner promotion tracking code * Fix RaftAppliedIndex progress check * Remove ErrGRPCKeyNotFound check This is not used by v3 API - it just returns a response with 0 KVs. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent ffb02676
...@@ -31,7 +31,7 @@ func (c *Cluster) testClusterDB(ctx context.Context) (<-chan struct{}, error) { ...@@ -31,7 +31,7 @@ func (c *Cluster) testClusterDB(ctx context.Context) (<-chan struct{}, error) {
go func() { go func() {
defer close(result) defer close(result)
for { for {
if err := c.managedDB.Test(ctx, c.clientAccessInfo); err != nil { if err := c.managedDB.Test(ctx); err != nil {
logrus.Infof("Failed to test data store connection: %v", err) logrus.Infof("Failed to test data store connection: %v", err)
} else { } else {
logrus.Info(c.managedDB.EndpointName() + " data store connection OK") logrus.Info(c.managedDB.EndpointName() + " data store connection OK")
...@@ -65,7 +65,7 @@ func (c *Cluster) start(ctx context.Context) error { ...@@ -65,7 +65,7 @@ func (c *Cluster) start(ctx context.Context) error {
} else { } else {
return fmt.Errorf("cluster-reset was successfully performed, please remove the cluster-reset flag and start %s normally, if you need to perform another cluster reset, you must first manually delete the %s file", version.Program, resetFile) return fmt.Errorf("cluster-reset was successfully performed, please remove the cluster-reset flag and start %s normally, if you need to perform another cluster reset, you must first manually delete the %s file", version.Program, resetFile)
} }
return c.managedDB.Reset(ctx, c.clientAccessInfo) return c.managedDB.Reset(ctx)
} }
// removing the reset file and ignore error if the file doesnt exist // removing the reset file and ignore error if the file doesnt exist
os.Remove(resetFile) os.Remove(resetFile)
......
...@@ -16,9 +16,9 @@ var ( ...@@ -16,9 +16,9 @@ var (
type Driver interface { type Driver interface {
IsInitialized(ctx context.Context, config *config.Control) (bool, error) IsInitialized(ctx context.Context, config *config.Control) (bool, error)
Register(ctx context.Context, config *config.Control, handler http.Handler) (http.Handler, error) Register(ctx context.Context, config *config.Control, handler http.Handler) (http.Handler, error)
Reset(ctx context.Context, clientAccessInfo *clientaccess.Info) error Reset(ctx context.Context) error
Start(ctx context.Context, clientAccessInfo *clientaccess.Info) error Start(ctx context.Context, clientAccessInfo *clientaccess.Info) error
Test(ctx context.Context, clientAccessInfo *clientaccess.Info) error Test(ctx context.Context) error
Restore(ctx context.Context) error Restore(ctx context.Context) error
EndpointName() string EndpointName() string
} }
......
...@@ -26,8 +26,12 @@ func (e Embedded) ETCD(args ETCDConfig) error { ...@@ -26,8 +26,12 @@ func (e Embedded) ETCD(args ETCDConfig) error {
} }
go func() { go func() {
err := <-etcd.Err() select {
logrus.Fatalf("etcd exited: %v", err) case <-etcd.Server.StopNotify():
logrus.Fatalf("etcd stopped - if this node was removed from the cluster, you must backup and delete %s before rejoining", args.DataDir)
case err := <-etcd.Err():
logrus.Fatalf("etcd exited: %v", err)
}
}() }()
return nil return nil
} }
...@@ -40,6 +40,8 @@ type ETCDConfig struct { ...@@ -40,6 +40,8 @@ type ETCDConfig struct {
ForceNewCluster bool `json:"force-new-cluster,omitempty"` ForceNewCluster bool `json:"force-new-cluster,omitempty"`
HeartbeatInterval int `json:"heartbeat-interval"` HeartbeatInterval int `json:"heartbeat-interval"`
ElectionTimeout int `json:"election-timeout"` ElectionTimeout int `json:"election-timeout"`
Logger string `json:"logger"`
LogOutputs []string `json:"log-outputs"`
} }
type ServerTrust struct { type ServerTrust struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment