[TrueCloudLab#16] pool: Don't count grpc canceled error

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-02-20 16:00:09 +03:00 committed by Gitea
parent 0e1999c965
commit 0ad877288e

View file

@ -32,6 +32,8 @@ import (
"go.uber.org/atomic" "go.uber.org/atomic"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
) )
// client represents virtual connection to the single FrostFS network endpoint from which Pool is formed. // client represents virtual connection to the single FrostFS network endpoint from which Pool is formed.
@ -995,11 +997,7 @@ func (c *clientWrapper) incRequests(elapsed time.Duration, method MethodIndex) {
func (c *clientStatusMonitor) handleError(st apistatus.Status, err error) error { func (c *clientStatusMonitor) handleError(st apistatus.Status, err error) error {
if err != nil { if err != nil {
// non-status logic error that could be returned if needCountError(err) {
// from the SDK client; should not be considered
// as a connection error
var siErr *object.SplitInfoError
if !errors.As(err, &siErr) {
c.incErrorRate() c.incErrorRate()
} }
@ -1018,6 +1016,20 @@ func (c *clientStatusMonitor) handleError(st apistatus.Status, err error) error
return err return err
} }
func needCountError(err error) bool {
// non-status logic error that could be returned
// from the SDK client; should not be considered
// as a connection error
var siErr *object.SplitInfoError
if errors.As(err, &siErr) {
return false
}
// we can't use errors.Is(err, context.Canceled)
// https://github.com/grpc/grpc-go/issues/4375
return status.Code(err) != codes.Canceled
}
// clientBuilder is a type alias of client constructors which open connection // clientBuilder is a type alias of client constructors which open connection
// to the given endpoint. // to the given endpoint.
type clientBuilder = func(endpoint string) client type clientBuilder = func(endpoint string) client