From 699fcb70c029693702b852de18f2fce3171ffef5 Mon Sep 17 00:00:00 2001 From: Yuri Nikolic Date: Fri, 2 Aug 2024 18:01:24 +0200 Subject: [PATCH 1/2] globalerror: get rid of deprecated gprc.ErrClientConnClosing Signed-off-by: Yuri Nikolic --- pkg/util/globalerror/grpc.go | 13 +++---------- pkg/util/globalerror/grpc_test.go | 8 +++----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/pkg/util/globalerror/grpc.go b/pkg/util/globalerror/grpc.go index e6a9d1263e8..8f4a50c9d7e 100644 --- a/pkg/util/globalerror/grpc.go +++ b/pkg/util/globalerror/grpc.go @@ -7,22 +7,15 @@ import ( "github.com/gogo/status" "github.com/grafana/dskit/grpcutil" - "google.golang.org/grpc" "google.golang.org/grpc/codes" grpcstatus "google.golang.org/grpc/status" "github.com/grafana/mimir/pkg/mimirpb" ) -var grpcClientConnectionIsClosingErr string - -func init() { - // Ignore deprecation warning for now - //nolint:staticcheck - if stat, ok := grpcutil.ErrorToStatus(grpc.ErrClientConnClosing); ok && stat.Code() == codes.Canceled { - grpcClientConnectionIsClosingErr = stat.Message() - } -} +var ( + grpcClientConnectionIsClosingErr = "grpc: the client connection is closing" +) // WrapGRPCErrorWithContextError checks if the given error is a gRPC error corresponding // to a standard golang context error, and if it is, wraps the former with the latter. diff --git a/pkg/util/globalerror/grpc_test.go b/pkg/util/globalerror/grpc_test.go index a71b5db6a36..f9501fc0aa8 100644 --- a/pkg/util/globalerror/grpc_test.go +++ b/pkg/util/globalerror/grpc_test.go @@ -83,10 +83,8 @@ func TestWrapContextError(t *testing.T) { expectedGrpcCode: codes.DeadlineExceeded, expectedContextErr: context.DeadlineExceeded, }, - "grpc.ErrClientConnClosing": { - // Ignore deprecation warning for now - // nolint:staticcheck - origErr: grpc.ErrClientConnClosing, + "grpc: the client connection is closing": { + origErr: status.Error(codes.Canceled, grpcClientConnectionIsClosingErr), expectedGrpcCode: codes.Canceled, expectedContextErr: nil, }, @@ -367,7 +365,7 @@ func checkGRPCConnectionIsClosingError(t *testing.T, err error) { stat, ok := grpcutil.ErrorToStatus(err) require.True(t, ok) require.Equal(t, codes.Canceled, stat.Code()) - require.Equal(t, "grpc: the client connection is closing", stat.Message()) + require.Equal(t, grpcClientConnectionIsClosingErr, stat.Message()) } type mockServer struct { From a33d729875f80caf8e34a3567c717f66e31847f3 Mon Sep 17 00:00:00 2001 From: Yuri Nikolic Date: Fri, 2 Aug 2024 18:03:34 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md Signed-off-by: Yuri Nikolic --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0983c4e0d28..62c8395a785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,7 +75,7 @@ * [BUGFIX] Query-frontend: Ensure that internal errors result in an HTTP 500 response code instead of 422. #8595 #8666 * [BUGFIX] Configuration: Multi line envs variables are flatten during injection to be compatible with YAML syntax * [BUGFIX] Querier: fix issue where queries can return incorrect results if a single store-gateway returns overlapping chunks for a series. #8827 -* [BUGFIX] Querier: do not return `grpc: the client connection is closing` errors as HTTP `499`. #8865 +* [BUGFIX] Querier: do not return `grpc: the client connection is closing` errors as HTTP `499`. #8865 #8888 ### Mixin