From c2d855aedd11258c37126c5920e7e0ffde42425d Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Wed, 12 Feb 2025 16:45:39 +0300 Subject: [PATCH] [#1636] qos: Return Resource Exhausted error Signed-off-by: Dmitrii Stepanov --- internal/qos/limiter.go | 8 ++++++++ pkg/local_object_storage/engine/engine.go | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/qos/limiter.go b/internal/qos/limiter.go index 996cebea1..3b6c6547c 100644 --- a/internal/qos/limiter.go +++ b/internal/qos/limiter.go @@ -2,6 +2,7 @@ package qos import ( "context" + "errors" "fmt" "time" @@ -9,6 +10,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/internal/assert" "git.frostfs.info/TrueCloudLab/frostfs-qos/scheduling" "git.frostfs.info/TrueCloudLab/frostfs-qos/tagging" + apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" ) const ( @@ -110,6 +112,9 @@ func (n *mClockLimiter) ReadRequest(ctx context.Context) (ReleaseFunc, error) { } rel, err := n.readScheduler.RequestArrival(ctx, tag) if err != nil { + if errors.Is(err, scheduling.ErrMClockSchedulerRequestLimitExceeded) { + return nil, &apistatus.ResourceExhausted{} + } return nil, err } return ReleaseFunc(rel), nil @@ -125,6 +130,9 @@ func (n *mClockLimiter) WriteRequest(ctx context.Context) (ReleaseFunc, error) { } rel, err := n.writeScheduler.RequestArrival(ctx, tag) if err != nil { + if errors.Is(err, scheduling.ErrMClockSchedulerRequestLimitExceeded) { + return nil, &apistatus.ResourceExhausted{} + } return nil, err } return ReleaseFunc(rel), nil diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index 85652b3ae..e13252b82 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -14,6 +14,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" + apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" "go.uber.org/zap" ) @@ -176,7 +177,10 @@ func (e *StorageEngine) reportShardError( } func isLogical(err error) bool { - return errors.As(err, &logicerr.Logical{}) || errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) + return errors.As(err, &logicerr.Logical{}) || + errors.Is(err, context.Canceled) || + errors.Is(err, context.DeadlineExceeded) || + errors.As(err, new(*apistatus.ResourceExhausted)) } // Option represents StorageEngine's constructor option.