Skip to content

HDDS-15608. Return BucketAlreadyOwnedByYou when the same S3 owner recreates an existing bucket#10814

Merged
Gargi-jais11 merged 4 commits into
apache:masterfrom
Gargi-jais11:HDDS-15608
Jul 24, 2026
Merged

HDDS-15608. Return BucketAlreadyOwnedByYou when the same S3 owner recreates an existing bucket#10814
Gargi-jais11 merged 4 commits into
apache:masterfrom
Gargi-jais11:HDDS-15608

Conversation

@Gargi-jais11

Copy link
Copy Markdown
Contributor

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.

@Gargi-jais11
Gargi-jais11 marked this pull request as ready for review July 20, 2026 07:03
@Gargi-jais11 Gargi-jais11 added the s3 S3 Gateway label Jul 20, 2026

@rich7420 rich7420 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gargi-jais11 thanks for the patch!

@ArafatKhan2198 ArafatKhan2198 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested GitHub review comment

The overall approach looks good

@rich7420 rich7420 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gargi-jais11 thanks for the update! LGTM

@ArafatKhan2198 ArafatKhan2198 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of the comments @Gargi-jais11
LGTM +1

@Gargi-jais11
Gargi-jais11 merged commit 72f1f9a into apache:master Jul 24, 2026
131 of 133 checks passed
@Gargi-jais11

Copy link
Copy Markdown
Contributor Author

Thanks @rich7420 and @ArafatKhan2198 for reviewing the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants