Merge pull request #9315 from wanyaoqi/bugfix/wyq/restart-session-check-lease-living

fix(host): check lease living on restart etcd session
This commit is contained in:
Zexi Li
2020-12-09 20:33:08 +08:00
committed by GitHub
2 changed files with 8 additions and 1 deletions
+4
View File
@@ -143,6 +143,10 @@ func (cli *SEtcdClient) GetClient() *clientv3.Client {
return cli.client
}
func (cli *SEtcdClient) SessionLiving() bool {
return cli.leaseLiving
}
func (cli *SEtcdClient) startSession() error {
ctx := context.TODO()
+4 -1
View File
@@ -112,8 +112,11 @@ func (c *SEtcdClient) OnKeepaliveFailure() {
}
func (c *SEtcdClient) Reconnect() {
if c.cli.SessionLiving() {
return
}
for {
if err := c.cli.RestartSession(); err != nil {
if err := c.cli.RestartSession(); err != nil && !c.cli.SessionLiving() {
log.Errorf("restart session failed %s", err)
time.Sleep(1 * time.Second)
} else {