Gargi-jais11 opened a new pull request, #10814:
URL: https://github.com/apache/ozone/pull/10814

   ## What changes were proposed in this pull request?
   s3-tests `test_bucket_create_exists` fails when the same S3 client creates a 
bucket twice. Ozone S3 Gateway always returns 409 with error code 
BucketAlreadyExists.
   
   AWS S3 expects:
   
   ```
   Scenario                                                         |      HTTP 
     | Error code
   --                                                               |        -- 
     | --
   Same S3 owner creates a bucket that already exists               |     409   
     | BucketAlreadyOwnedByYou
   Different S3 owner creates a bucket with an existing global name |    409    
     | BucketAlreadyExists
   ```
   
   Add **BUCKET_ALREADY_OWNED_BY_YOU** to `S3ErrorTable 
`(BucketAlreadyOwnedByYou, HTTP 409) and return when same S3 owner creates a 
bucket that already exists
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-15608
   
   ## How was this patch tested?
   
   Added IT and UT.
   Manual Testing:
   **Before Fix:**
   ```
   // wrong behaviour: same owner creating a bucket already existing --> throws 
BucketAlreadyExists error
   
    BUCKET="duplicate-test-$$"
   bash-5.1$ aws s3api create-bucket \
     --bucket "$BUCKET" \
     --endpoint-url http://s3g:9878/
   {
       "Location": "http://s3g:9878/duplicate-test-117";
   }
   bash-5.1$ aws s3api create-bucket \
     --bucket "$BUCKET" \
     --endpoint-url http://s3g:9878/
   
   // Different owner of bucket getting BucketAlreadyExists error is okay
   An error occurred (BucketAlreadyExists) when calling the CreateBucket 
operation: The requested bucket name is not available as it already exists.
   
   bash-5.1$ BUCKET="duplicate-other-owner-$$"
   bash-5.1$ ozone sh bucket create "/s3v/${BUCKET}" --user other-s3-owner
   bash-5.1$ aws s3api create-bucket \
     --bucket "$BUCKET" \
     --endpoint-url http://s3g:9878/
   
   An error occurred (BucketAlreadyExists) when calling the CreateBucket 
operation: The requested bucket name is not available as it already exists.
   
   ```
   **After Fix:**
   ```
   // Same owner creating already existing bucket ---> Throw 
BUCKET_ALREADY_OWNED_BY_YOU
   
   BUCKET="duplicate-test-$$"
   bash-5.1$ aws s3api create-bucket \
     --bucket "$BUCKET" \
     --endpoint-url http://s3g:9878/
   {
       "Location": "http://s3g:9878/duplicate-test-119";
   }
   bash-5.1$ aws s3api create-bucket \
     --bucket "$BUCKET" \
     --endpoint-url http://s3g:9878/
   
   An error occurred (BucketAlreadyOwnedByYou) when calling the CreateBucket 
operation: Your previous request to create the named bucket succeeded and you 
already own it.
   
   // Bucket owned by other user ---> Throws BUCKET_ALREADY_EXISTS
   
   bash-5.1$ BUCKET="duplicate-other-owner-$$"
   bash-5.1$ ozone sh bucket create "/s3v/${BUCKET}" --user other-s3-owner
   bash-5.1$ aws s3api create-bucket \
     --bucket "$BUCKET" \
     --endpoint-url http://s3g:9878/
   
   An error occurred (BucketAlreadyExists) when calling the CreateBucket 
operation: The requested bucket name is not available as it already exists.
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to