[#XX] pool: Don't count regular FrostFS errors
Some checks failed
DCO / DCO (pull_request) Failing after 56s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m4s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m2s
Tests and linters / Lint (pull_request) Successful in 1m37s

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 <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2024-08-14 16:48:06 +03:00
parent 98aabc45a7
commit 8ea5f2b03f
2 changed files with 34 additions and 10 deletions

View file

@ -1227,6 +1227,22 @@ func (c *clientWrapper) close() error {
} }
func (c *clientStatusMonitor) handleError(ctx context.Context, st apistatus.Status, err error) 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 err != nil {
if needCountError(ctx, err) { if needCountError(ctx, err) {
c.incErrorRate() c.incErrorRate()
@ -1235,16 +1251,7 @@ func (c *clientStatusMonitor) handleError(ctx context.Context, st apistatus.Stat
return err return err
} }
err = apistatus.ErrFromStatus(st) return nil
switch err.(type) {
case *apistatus.ServerInternal,
*apistatus.WrongMagicNumber,
*apistatus.SignatureVerification,
*apistatus.NodeUnderMaintenance:
c.incErrorRate()
}
return err
} }
func needCountError(ctx context.Context, err error) bool { func needCountError(ctx context.Context, err error) bool {

View file

@ -609,6 +609,23 @@ func TestHandleError(t *testing.T) {
expectedError: true, expectedError: true,
countError: false, 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, ctx: ctx,
status: new(apistatus.ServerInternal), status: new(apistatus.ServerInternal),