From 34a1cc99b1c25475f341262a0f239944ee1e4f31 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" Date: Wed, 10 May 2023 11:54:55 -0500 Subject: [PATCH] simplify fix --- agent/grpc-internal/resolver/resolver.go | 32 ++---------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/agent/grpc-internal/resolver/resolver.go b/agent/grpc-internal/resolver/resolver.go index 510fac1333de..bb2224ee0844 100644 --- a/agent/grpc-internal/resolver/resolver.go +++ b/agent/grpc-internal/resolver/resolver.go @@ -155,10 +155,6 @@ func (s *ServerResolverBuilder) AddServer(areaID types.AreaID, server *metadata. areaServers[uniqueID(server)] = server - if areaID == types.AreaLAN || s.cfg.Datacenter == server.Datacenter { - s.leaderResolver.updateClientConn() - } - addrs := s.getDCAddrs(server.Datacenter) for _, resolver := range s.resolvers { if resolver.datacenter == server.Datacenter { @@ -201,10 +197,6 @@ func (s *ServerResolverBuilder) RemoveServer(areaID types.AreaID, server *metada delete(s.servers, areaID) } - if areaID == types.AreaLAN || s.cfg.Datacenter == server.Datacenter { - s.leaderResolver.updateClientConn() - } - addrs := s.getDCAddrs(server.Datacenter) for _, resolver := range s.resolvers { if resolver.datacenter == server.Datacenter { @@ -281,28 +273,8 @@ func (s *ServerResolverBuilder) UpdateLeaderAddr(datacenter, addr string) { s.lock.Lock() defer s.lock.Unlock() - lanAddr := DCPrefix(datacenter, addr) - - s.leaderResolver.globalAddr = lanAddr - - if s.lanHasAddrLocked(lanAddr) { - s.leaderResolver.updateClientConn() - } -} - -func (s *ServerResolverBuilder) lanHasAddrLocked(lanAddr string) bool { - areaServers, ok := s.servers[types.AreaLAN] - if !ok { - return false - } - - for _, server := range areaServers { - if DCPrefix(server.Datacenter, server.Addr.String()) == lanAddr { - return true - } - } - - return false + s.leaderResolver.globalAddr = DCPrefix(datacenter, addr) + s.leaderResolver.updateClientConn() } // serverResolver is a grpc Resolver that will keep a grpc.ClientConn up to date