From 203bba65a0b33cf1ba3751b6b676b20cd1046119 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 14 Aug 2024 16:48:06 +0300 Subject: [PATCH] [#253] pool: Don't count regular FrostFS errors Previously we count all frostfs errors like: ObjectNotFound, EACLNotFound because frostfs status is unconditionally resolved into built-in go errors but handleError method handled built-in errors like internal network ones. Since after resolving frostfs errors status is also returned we start check this first Signed-off-by: Denis Kirillov --- pool/pool.go | 27 +++++++++++++++++---------- pool/pool_test.go | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/pool/pool.go b/pool/pool.go index fa1fa72..f9e3dae 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -1227,6 +1227,22 @@ func (c *clientWrapper) close() error { } func (c *clientStatusMonitor) handleError(ctx context.Context, st apistatus.Status, err error) error { + if stErr := apistatus.ErrFromStatus(st); stErr != nil { + switch stErr.(type) { + case *apistatus.ServerInternal, + *apistatus.WrongMagicNumber, + *apistatus.SignatureVerification, + *apistatus.NodeUnderMaintenance: + c.incErrorRate() + } + + if err == nil { + err = stErr + } + + return err + } + if err != nil { if needCountError(ctx, err) { c.incErrorRate() @@ -1235,16 +1251,7 @@ func (c *clientStatusMonitor) handleError(ctx context.Context, st apistatus.Stat return err } - err = apistatus.ErrFromStatus(st) - switch err.(type) { - case *apistatus.ServerInternal, - *apistatus.WrongMagicNumber, - *apistatus.SignatureVerification, - *apistatus.NodeUnderMaintenance: - c.incErrorRate() - } - - return err + return nil } func needCountError(ctx context.Context, err error) bool { diff --git a/pool/pool_test.go b/pool/pool_test.go index c8721b9..9189c3e 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -609,6 +609,23 @@ func TestHandleError(t *testing.T) { expectedError: true, countError: false, }, + { + ctx: ctx, + status: new(apistatus.ObjectNotFound), + err: &apistatus.ObjectNotFound{}, + expectedError: true, + countError: false, + }, + { + ctx: ctx, + status: nil, + err: &apistatus.EACLNotFound{}, + expectedError: true, + // we expect error be counted because status is nil + // currently we assume that DisableFrostFSErrorResolution be always false for pool + // and status be checked first in handleError + countError: true, + }, { ctx: ctx, status: new(apistatus.ServerInternal), -- 2.45.2