[#589] Add LimitExceeded error #593

Open
r.loginov wants to merge 1 commit from r.loginov/frostfs-s3-gw:feature/589-return-quota-limit-reached_status into master
Member

close #589

As part of this PR, an error was added when access was denied due to exceeding the quota. Examples of how it used to be and how it is now:

(In a situation where we receive an error exceeding the quota from the node)

before:

$ aws s3api put-object --bucket cats --key cat1 --body testf --endpoint http://localhost:8084

An error occurred (AccessDenied) when calling the PutObject operation: Access Denied.

now:

$ aws s3api put-object --bucket cats --key cat1 --body testf --endpoint http://localhost:8084

An error occurred (LimitExceeded) when calling the PutObject operation: You have reached the quota limit.
close #589 As part of this PR, an error was added when access was denied due to exceeding the quota. Examples of how it used to be and how it is now: (In a situation where we receive an error exceeding the quota from the node) before: ``` $ aws s3api put-object --bucket cats --key cat1 --body testf --endpoint http://localhost:8084 An error occurred (AccessDenied) when calling the PutObject operation: Access Denied. ``` now: ``` $ aws s3api put-object --bucket cats --key cat1 --body testf --endpoint http://localhost:8084 An error occurred (LimitExceeded) when calling the PutObject operation: You have reached the quota limit. ```
r.loginov self-assigned this 2024-12-23 02:36:50 +00:00
r.loginov added 1 commit 2024-12-23 02:36:51 +00:00
[#589] Add LimitExceeded error
All checks were successful
/ DCO (pull_request) Successful in 2m9s
/ Vulncheck (pull_request) Successful in 2m53s
/ Builds (pull_request) Successful in 3m16s
/ Lint (pull_request) Successful in 3m52s
/ Tests (pull_request) Successful in 3m24s
c58334a378
The Access Denied status may be received
from APE due to exceeding the quota. In
this situation, you need to return the
appropriate error.

Signed-off-by: Roman Loginov <r.loginov@yadro.com>
r.loginov requested review from storage-services-developers 2024-12-23 02:36:52 +00:00
r.loginov requested review from storage-services-committers 2024-12-23 02:36:52 +00:00
nzinkevich reviewed 2024-12-23 06:24:12 +00:00
@ -1766,0 +1770,4 @@
ErrCode: ErrLimitExceeded,
Code: "LimitExceeded",
Description: "You have reached the quota limit.",
HTTPStatusCode: http.StatusConflict,
Member

It seems to me that the StatusConflict is not very suitable for quota limit errors. Maybe we should use another response code, such as TooManyRequests or Forbidden?

It seems to me that the StatusConflict is not very suitable for quota limit errors. Maybe we should use another response code, such as TooManyRequests or Forbidden?
Author
Member

That's a good point. I agree that at first glance, the Conflict status is not quite appropriate
I used it for two reasons:

  1. The same status is used in the aws error on the basis of which this error was made.
  2. Based on RFC 9110, it seems that this status is appropriate. If you look at the phrase

This code is used in situations where the user might be able to resolve the conflict and resubmit the request. The server SHOULD generate content that includes enough information for a user to recognize the source of the conflict.

This is exactly the situation we are in. Upon receiving a message that the quota has been exceeded, the user can remove this quota himself by deleting related resources. And resend the request, which will work successfully.

Using the Too Many Requests status doesn't seem quite right, because based on RFC 6585, this status is used in communications when a user has sent too many requests in a given period of time. And in our situation, we are talking specifically about the resource quota (the amount of space occupied, the number of containers, the number of objects).

Using the Forbidden status can be considered for use in this situation. However, I am a little confused that if you follow RFC 9110, then this status is used in situations where a user with certain credentials does not have access to this resource. On the one hand, this is true, but only create/put operations are not available to the user. The user may well request and delete the resource. Moreover, it turns out that the user can delete the data in the resource himself, thereby removing his quota. It doesn't seem to be the behavior that the current status implies.

However, I don't have a clear opinion on whether to use Conflict or Forbidden. Let's also wait for the opinions of other reviewers.

That's a good point. I agree that at first glance, the `Conflict` status is not quite appropriate I used it for two reasons: 1. The same status is used in the [aws error](https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateUser.html#API_CreateUser_Errors) on the basis of which this error was made. 2. Based on [RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#name-409-conflict), it seems that this status is appropriate. If you look at the phrase > This code is used in situations where the user might be able to resolve the conflict and resubmit the request. The server SHOULD generate content that includes enough information for a user to recognize the source of the conflict. This is exactly the situation we are in. Upon receiving a message that the quota has been exceeded, the user can remove this quota himself by deleting related resources. And resend the request, which will work successfully. Using the Too Many Requests status doesn't seem quite right, because based on [RFC 6585](https://datatracker.ietf.org/doc/html/rfc6585#section-4), this status is used in communications when a user has sent too many requests in a given period of time. And in our situation, we are talking specifically about the resource quota (the amount of space occupied, the number of containers, the number of objects). Using the Forbidden status can be considered for use in this situation. However, I am a little confused that if you follow [RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#name-403-forbidden), then this status is used in situations where a user with certain credentials does not have access to this resource. On the one hand, this is true, but only create/put operations are not available to the user. The user may well request and delete the resource. Moreover, it turns out that the user can delete the data in the resource himself, thereby removing his quota. It doesn't seem to be the behavior that the current status implies. However, I don't have a clear opinion on whether to use Conflict or Forbidden. Let's also wait for the opinions of other reviewers.
Author
Member

We have agreed that we will use the 409 Conflict

We have agreed that we will use the 409 Conflict
r.loginov marked this conversation as resolved
r.loginov changed title from [#589] Add LimitExceeded error to WIP: [#589] Add LimitExceeded error 2024-12-23 11:58:02 +00:00
dkirillov reviewed 2024-12-23 11:59:45 +00:00
@ -477,6 +477,9 @@ func handleObjectError(msg string, err error) error {
}
if reason, ok := frosterr.IsErrObjectAccessDenied(err); ok {
if strings.Contains(reason, "Quota limit reached") {
Member

Can we ensure if reason always stars with capital letter?
Probably we can check this in lowercased reason or find just limit reached

Can we ensure if reason always stars with capital letter? Probably we can check this in lowercased reason or find just `limit reached`
r.loginov marked this conversation as resolved
dkirillov approved these changes 2024-12-23 12:00:39 +00:00
Dismissed
dkirillov left a comment
Member

LGTM, but see comment

LGTM, but see comment
r.loginov force-pushed feature/589-return-quota-limit-reached_status from c58334a378 to 3e3b36ead8 2024-12-24 05:04:25 +00:00 Compare
r.loginov dismissed dkirillov's review 2024-12-24 05:04:25 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

r.loginov changed title from WIP: [#589] Add LimitExceeded error to [#589] Add LimitExceeded error 2024-12-24 05:20:29 +00:00
r.loginov requested review from storage-services-developers 2024-12-24 05:20:29 +00:00
r.loginov requested review from storage-services-committers 2024-12-24 05:20:30 +00:00
dkirillov approved these changes 2024-12-24 09:25:37 +00:00
All checks were successful
/ DCO (pull_request) Successful in 2m54s
Required
Details
/ Vulncheck (pull_request) Successful in 3m32s
Required
Details
/ Builds (pull_request) Successful in 3m51s
Required
Details
/ Lint (pull_request) Successful in 5m10s
Required
Details
/ Tests (pull_request) Successful in 3m59s
Required
Details
This pull request doesn't have enough approvals yet. 1 of 2 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u feature/589-return-quota-limit-reached_status:r.loginov-feature/589-return-quota-limit-reached_status
git checkout r.loginov-feature/589-return-quota-limit-reached_status
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-s3-gw#593
No description provided.