Switch to new client gracefully
@@ -600,13 +600,14 @@ hcLoop:
util.Logger().Errorf(cerr, "re-get etcd client %v failed.", c.Endpoints)
continue
}
- cerr = c.Client.Close()
- if cerr != nil {
- util.Logger().Errorf(cerr, "close unavailable etcd client failed.")
- }
- c.Client = client
+ c.Client, client = client, c.Client
util.Logger().Errorf(err, "Auto sync etcd members failed and re-connected etcd successfully")
+
+ if cerr = client.Close(); cerr != nil {
+ util.Logger().Errorf(cerr, "close unavailable etcd client failed.")
+ }
+ client = nil
}
}
}
