Skip to content

Commit

Permalink
use removeClient to close etcd client
Browse files Browse the repository at this point in the history
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
  • Loading branch information
iosmanthus authored and ti-chi-bot committed Nov 16, 2023
1 parent 0846360 commit b57985f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/utils/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (checker *healthyChecker) update(eps []string) {
lastHealthy := client.(*healthyClient).lastHealth
if time.Since(lastHealthy) > etcdServerOfflineTimeout {
log.Info("some etcd server maybe offline", zap.String("endpoint", ep))
checker.Delete(ep)
checker.removeClient(ep)

Check warning on line 396 in pkg/utils/etcdutil/etcdutil.go

View check run for this annotation

Codecov / codecov/patch

pkg/utils/etcdutil/etcdutil.go#L396

Added line #L396 was not covered by tests
}
if time.Since(lastHealthy) > etcdServerDisconnectedTimeout {
// try to reset client endpoint to trigger reconnect
Expand All @@ -409,7 +409,7 @@ func (checker *healthyChecker) update(eps []string) {
checker.Range(func(key, value interface{}) bool {
ep := key.(string)
if _, ok := epMap[ep]; !ok {
log.Info("[etcd client] remove stale etcd client", zap.String("endpoint", ep))
log.Info("remove stale etcd client", zap.String("endpoint", ep))
checker.removeClient(ep)
}
return true
Expand All @@ -432,7 +432,7 @@ func (checker *healthyChecker) removeClient(ep string) {
if client, ok := checker.LoadAndDelete(ep); ok {
err := client.(*healthyClient).Close()
if err != nil {
log.Error("[etcd client] failed to close etcd healthy client", zap.Error(err))
log.Error("failed to close etcd healthy client", zap.Error(err))
}
}
}
Expand Down

0 comments on commit b57985f

Please sign in to comment.