From 4edf517960da7cc4c927c01359b6bef1e635ec63 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Thu, 16 Oct 2025 10:17:13 +0200 Subject: [PATCH] transport: Suppress warning when the connection is closing Don't emit a warning when the connection is closing. A warning implies that something is not as it should be, but it's expected that the connection attempt is interrupted in this case. RELEASE NOTES: N/A Signed-off-by: Tom Wieczorek --- clientconn.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clientconn.go b/clientconn.go index a3c315f2d76e..35f09244472a 100644 --- a/clientconn.go +++ b/clientconn.go @@ -1348,6 +1348,13 @@ func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, c if err == nil { return nil } + // The connection might be closing. + // Don't emit a warning in this case and err out early. + if ctx.Err() != nil { + return errConnClosing + } + channelz.Warningf(logger, ac.channelz, "grpc: addrConn.createTransport failed to connect to %s. Err: %v", addr, err) + if firstConnErr == nil { firstConnErr = err } @@ -1404,7 +1411,6 @@ func (ac *addrConn) createTransport(ctx context.Context, addr resolver.Address, } // newTr is either nil, or closed. hcancel() - channelz.Warningf(logger, ac.channelz, "grpc: addrConn.createTransport failed to connect to %s. Err: %v", addr, err) return err }