From ad701a9d6bfdd345e3060219344e0a420e568c11 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Wed, 31 Jan 2024 16:51:06 +0800 Subject: [PATCH] fix Signed-off-by: Ryan Leung --- pkg/utils/grpcutil/grpcutil.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/utils/grpcutil/grpcutil.go b/pkg/utils/grpcutil/grpcutil.go index 4d2f250d53e..e54ddfe1711 100644 --- a/pkg/utils/grpcutil/grpcutil.go +++ b/pkg/utils/grpcutil/grpcutil.go @@ -252,11 +252,11 @@ func CheckStream(ctx context.Context, cancel context.CancelFunc, done chan struc // NeedRebuildConnection checks if the error is a connection error. func NeedRebuildConnection(err error) bool { - return err != nil && err == io.EOF || + return (err != nil) && (err == io.EOF || strings.Contains(err.Error(), codes.Unavailable.String()) || // Unavailable indicates the service is currently unavailable. This is a most likely a transient condition. strings.Contains(err.Error(), codes.DeadlineExceeded.String()) || // DeadlineExceeded means operation expired before completion. strings.Contains(err.Error(), codes.Internal.String()) || // Internal errors. strings.Contains(err.Error(), codes.Unknown.String()) || // Unknown error. - strings.Contains(err.Error(), codes.ResourceExhausted.String()) // ResourceExhausted is returned when either the client or the server has exhausted their resources. + strings.Contains(err.Error(), codes.ResourceExhausted.String())) // ResourceExhausted is returned when either the client or the server has exhausted their resources. // Besides, we don't need to rebuild the connection if the code is Canceled, which means the client cancelled the request. }