mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
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:
@@ -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()
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user