feature/port_error_counts #257

Merged
alexvanin merged 2 commits from dkirillov/frostfs-sdk-go:feature/port_error_counts into support/v1.0.0-rc.5 2024-09-04 19:51:16 +00:00
3 changed files with 39 additions and 10 deletions

View file

@ -1180,6 +1180,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()
@ -1188,16 +1204,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),

View file

@ -836,6 +836,11 @@ LOOP:
if startI != indexI || startJ != indexJ { if startI != indexI || startJ != indexJ {
p.setStartIndices(indexI, indexJ) p.setStartIndices(indexI, indexJ)
} }
if err != nil {
err = fmt.Errorf("address %s: %w", p.innerPools[indexI].clients[indexJ].endpoint(), err)
}
return err return err
} }