mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3/balancer: only notify healthy addresses
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
012b013538
commit
103efd922b
@ -367,19 +367,15 @@ func (b *healthBalancer) notifyAddrs(msg notifyMsg) {
|
||||
}
|
||||
}
|
||||
b.mu.RLock()
|
||||
addrs := b.addrs
|
||||
pinAddr := b.pinAddr
|
||||
downc := b.downc
|
||||
b.mu.RUnlock()
|
||||
addrs, hostPorts := b.liveAddrs()
|
||||
|
||||
var waitDown bool
|
||||
if pinAddr != "" {
|
||||
waitDown = true
|
||||
for _, a := range addrs {
|
||||
if a.Addr == pinAddr {
|
||||
waitDown = false
|
||||
}
|
||||
}
|
||||
_, ok := hostPorts[pinAddr]
|
||||
waitDown = !ok
|
||||
}
|
||||
|
||||
select {
|
||||
|
@ -64,8 +64,8 @@ func TestBalancerGetUnblocking(t *testing.T) {
|
||||
}
|
||||
|
||||
down1(errors.New("error"))
|
||||
if addrs := <-hb.Notify(); len(addrs) != len(endpoints) {
|
||||
t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection")
|
||||
if addrs := <-hb.Notify(); len(addrs) != len(endpoints)-1 { // we call down on one endpoint
|
||||
t.Errorf("closing the only connection should triggered balancer to send the %d endpoints via Notify chan so that we can establish a connection", len(endpoints)-1)
|
||||
}
|
||||
down2(errors.New("error"))
|
||||
_, _, err = hb.Get(context.Background(), unblockingOpts)
|
||||
@ -119,8 +119,8 @@ func TestBalancerGetBlocking(t *testing.T) {
|
||||
}
|
||||
|
||||
down1(errors.New("error"))
|
||||
if addrs := <-hb.Notify(); len(addrs) != len(endpoints) {
|
||||
t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection")
|
||||
if addrs := <-hb.Notify(); len(addrs) != len(endpoints)-1 { // we call down on one endpoint
|
||||
t.Errorf("closing the only connection should triggered balancer to send the %d endpoints via Notify chan so that we can establish a connection", len(endpoints)-1)
|
||||
}
|
||||
down2(errors.New("error"))
|
||||
ctx, cancel = context.WithTimeout(context.Background(), time.Millisecond*100)
|
||||
|
Loading…
x
Reference in New Issue
Block a user