|
@@ -158,26 +158,26 @@ func (b *healthBalancer) pinned() string {
|
|
|
|
|
|
|
|
func (b *healthBalancer) hostPortError(hostPort string, err error) {
|
|
func (b *healthBalancer) hostPortError(hostPort string, err error) {
|
|
|
if b.endpoint(hostPort) == "" {
|
|
if b.endpoint(hostPort) == "" {
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: %q is stale (skip marking as unhealthy on %q)", hostPort, err.Error())
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: %q is stale (skip marking as unhealthy on %q)", hostPort, err.Error())
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
b.unhealthyMu.Lock()
|
|
b.unhealthyMu.Lock()
|
|
|
b.unhealthyHostPorts[hostPort] = time.Now()
|
|
b.unhealthyHostPorts[hostPort] = time.Now()
|
|
|
b.unhealthyMu.Unlock()
|
|
b.unhealthyMu.Unlock()
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: %q is marked unhealthy (%q)", hostPort, err.Error())
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: %q is marked unhealthy (%q)", hostPort, err.Error())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (b *healthBalancer) removeUnhealthy(hostPort, msg string) {
|
|
func (b *healthBalancer) removeUnhealthy(hostPort, msg string) {
|
|
|
if b.endpoint(hostPort) == "" {
|
|
if b.endpoint(hostPort) == "" {
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: %q was not in unhealthy (%q)", hostPort, msg)
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: %q was not in unhealthy (%q)", hostPort, msg)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
b.unhealthyMu.Lock()
|
|
b.unhealthyMu.Lock()
|
|
|
delete(b.unhealthyHostPorts, hostPort)
|
|
delete(b.unhealthyHostPorts, hostPort)
|
|
|
b.unhealthyMu.Unlock()
|
|
b.unhealthyMu.Unlock()
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: %q is removed from unhealthy (%q)", hostPort, msg)
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: %q is removed from unhealthy (%q)", hostPort, msg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (b *healthBalancer) countUnhealthy() (count int) {
|
|
func (b *healthBalancer) countUnhealthy() (count int) {
|
|
@@ -199,7 +199,7 @@ func (b *healthBalancer) cleanupUnhealthy() {
|
|
|
for k, v := range b.unhealthyHostPorts {
|
|
for k, v := range b.unhealthyHostPorts {
|
|
|
if time.Since(v) > b.healthCheckTimeout {
|
|
if time.Since(v) > b.healthCheckTimeout {
|
|
|
delete(b.unhealthyHostPorts, k)
|
|
delete(b.unhealthyHostPorts, k)
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: removed %q from unhealthy after %v", k, b.healthCheckTimeout)
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: removed %q from unhealthy after %v", k, b.healthCheckTimeout)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
b.unhealthyMu.Unlock()
|
|
b.unhealthyMu.Unlock()
|
|
@@ -402,7 +402,7 @@ func (b *healthBalancer) Up(addr grpc.Address) func(error) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if b.pinAddr != "" {
|
|
if b.pinAddr != "" {
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: %q is up but not pinned (already pinned %q)", addr.Addr, b.pinAddr)
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: %q is up but not pinned (already pinned %q)", addr.Addr, b.pinAddr)
|
|
|
return func(err error) {}
|
|
return func(err error) {}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -410,7 +410,7 @@ func (b *healthBalancer) Up(addr grpc.Address) func(error) {
|
|
|
close(b.upc)
|
|
close(b.upc)
|
|
|
b.downc = make(chan struct{})
|
|
b.downc = make(chan struct{})
|
|
|
b.pinAddr = addr.Addr
|
|
b.pinAddr = addr.Addr
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: pin %q", addr.Addr)
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: pin %q", addr.Addr)
|
|
|
|
|
|
|
|
// notify client that a connection is up
|
|
// notify client that a connection is up
|
|
|
b.readyOnce.Do(func() { close(b.readyc) })
|
|
b.readyOnce.Do(func() { close(b.readyc) })
|
|
@@ -427,7 +427,7 @@ func (b *healthBalancer) Up(addr grpc.Address) func(error) {
|
|
|
close(b.downc)
|
|
close(b.downc)
|
|
|
b.pinAddr = ""
|
|
b.pinAddr = ""
|
|
|
b.mu.Unlock()
|
|
b.mu.Unlock()
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: unpin %q (%q)", addr.Addr, err.Error())
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: unpin %q (%q)", addr.Addr, err.Error())
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -454,7 +454,7 @@ func (b *healthBalancer) mayPin(addr grpc.Address) bool {
|
|
|
// 3. grpc-healthcheck still SERVING, thus retry to pin
|
|
// 3. grpc-healthcheck still SERVING, thus retry to pin
|
|
|
// instead, return before grpc-healthcheck if failed within healthcheck timeout
|
|
// instead, return before grpc-healthcheck if failed within healthcheck timeout
|
|
|
if elapsed := time.Since(failedTime); elapsed < b.healthCheckTimeout {
|
|
if elapsed := time.Since(failedTime); elapsed < b.healthCheckTimeout {
|
|
|
- logger.Lvl(4).Infof("clientv3/balancer: %q is up but not pinned (failed %v ago, require minimum %v after failure)", addr.Addr, elapsed, b.healthCheckTimeout)
|
|
|
|
|
|
|
+ lg.Lvl(4).Infof("clientv3/balancer: %q is up but not pinned (failed %v ago, require minimum %v after failure)", addr.Addr, elapsed, b.healthCheckTimeout)
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|