mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
grpcproxy: fix memberlist results not update when proxy node down
If start grpc proxy with --resolver-prefix, memberlist will return all alive proxy nodes, when one grpc proxy node is down, it is expected to not return the down node, but it is still return Signed-off-by: yellowzf <zzhf3311@163.com>
This commit is contained in:
@@ -112,9 +112,9 @@ func (cp *clusterProxy) monitor(wa endpoints.WatchChannel) {
|
||||
for _, up := range updates {
|
||||
switch up.Op {
|
||||
case endpoints.Add:
|
||||
cp.umap[up.Endpoint.Addr] = up.Endpoint
|
||||
cp.umap[up.Key] = up.Endpoint
|
||||
case endpoints.Delete:
|
||||
delete(cp.umap, up.Endpoint.Addr)
|
||||
delete(cp.umap, up.Key)
|
||||
}
|
||||
}
|
||||
cp.umu.Unlock()
|
||||
@@ -169,12 +169,12 @@ func (cp *clusterProxy) membersFromUpdates() ([]*pb.Member, error) {
|
||||
cp.umu.RLock()
|
||||
defer cp.umu.RUnlock()
|
||||
mbs := make([]*pb.Member, 0, len(cp.umap))
|
||||
for addr, upt := range cp.umap {
|
||||
for _, upt := range cp.umap {
|
||||
m, err := decodeMeta(fmt.Sprint(upt.Metadata))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mbs = append(mbs, &pb.Member{Name: m.Name, ClientURLs: []string{addr}})
|
||||
mbs = append(mbs, &pb.Member{Name: m.Name, ClientURLs: []string{upt.Addr}})
|
||||
}
|
||||
return mbs, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user