Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globalerror: get rid of deprecated gprc.ErrClientConnClosing #8888

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 3 additions & 10 deletions pkg/util/globalerror/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions pkg/util/globalerror/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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 {
Expand Down
Loading