From 476f5f9e58e6562d160c5b4803f3480e05894a75 Mon Sep 17 00:00:00 2001 From: kpango Date: Tue, 2 Mar 2021 15:53:18 +0900 Subject: [PATCH] bugfix nil pointer no target discovered Signed-off-by: kpango --- internal/net/grpc/client.go | 7 ++++++- internal/net/grpc/pool/pool.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/net/grpc/client.go b/internal/net/grpc/client.go index f5fe3124f5c..bd05d6d8d7d 100644 --- a/internal/net/grpc/client.go +++ b/internal/net/grpc/client.go @@ -573,7 +573,12 @@ func (g *gRPCClient) Connect(ctx context.Context, addr string, dopts ...DialOpti g.atomicAddrs.Add(addr) return conn, nil } - log.Warnf("failed to reconnect unhealthy pool addr= %s\terror= %s", addr, err.Error()) + log.Warnf("failed to reconnect unhealthy pool addr= %s\terror= %s\t trying to disconnect", addr, func() string { + if err != nil { + return err.Error() + } + return "connection response is nil or pool is nil" + }()) err = g.Disconnect(ctx, addr) if err != nil { log.Warnf("failed to disconnect unhealthy pool addr= %s\terror= %s", addr, err.Error()) diff --git a/internal/net/grpc/pool/pool.go b/internal/net/grpc/pool/pool.go index bb7a8bbc959..1268ee6a124 100644 --- a/internal/net/grpc/pool/pool.go +++ b/internal/net/grpc/pool/pool.go @@ -121,7 +121,7 @@ func New(ctx context.Context, opts ...Option) (c Conn, err error) { } func (p *pool) Connect(ctx context.Context) (c Conn, err error) { - if p.closing.Load().(bool) { + if p.closing.Load().(bool) || p == nil{ return p, nil }