Bug #76398
openrgw: S3 CreateBucket on existing bucket returns error code/message inconsistent with AWS S3 / Swift
0%
Description
The way rgw handles the CreateBucket on an existing bucket is not fully consistent with AWS s3 / Swift standard.
- AWS s3: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html#API_CreateBucket_Errors
BucketAlreadyExists The requested bucket name is not available. The bucket namespace is shared by all users of the system. Select a different name and try again. HTTP Status Code: 409 BucketAlreadyOwnedByYou The bucket you tried to create already exists, and you own it. Amazon S3 returns this error in all AWS Regions except in the North Virginia Region. For legacy compatibility, if you re-create an existing bucket that you already own in the North Virginia Region, Amazon S3 returns 200 OK and resets the bucket access control lists (ACLs). HTTP Status Code: 409
- Swift create container (PUT): https://docs.openstack.org/api-ref/object-store/#create-container
You do not need to check whether a container already exists before issuing a PUT operation because the operation is idempotent: It creates a container or updates an existing container, as appropriate.
and rgw:swift::merge_policy: https://github.com/ceph/ceph/blob/2a23682b08f37afd358ffe6b58ea55d0b8d85f76/src/rgw/rgw_op.cc#L3870
Inconsistent behaviors in rgw:¶
s3: When rgw_bucket_eexist_override is true| op | existing bucket owned by | status code | error code | err message |
|---|---|---|---|---|
| CreateBucket with same acl | same owner | 409 | rgw: BucketAlreadyExists | rgw:The requested bucket name is not available. The bucket namespace is shared by all users of the system. Specify a different name and try again. |
| expected: 409 | expected: BucketAlreadyOwnedByYou | expected:The bucket you tried to create already exists, and you own it. | ||
| CreateBucket with different acl | same owner | 409 | rgw: BucketAlreadyExists | rgw:Cannot modify existing access control policy |
| expected: 409 | expected: BucketAlreadyOwnedByYou | expected:The bucket you tried to create already exists, and you own it. | ||
| CreateBucket | different owner | 409 | rgw: BucketAlreadyExists | rgw:Cannot modify existing access control policy |
| expected: 409 | expected: BucketAlreadyExists | expected:The requested bucket name is not available. The bucket namespace is shared by all users of the system. Specify a different name and try again. |
| op | existing bucket owned by | status code | error code | err message |
|---|---|---|---|---|
| CreateBucket with same configs -- this is consistent | same owner | 200 | rgw: OK | rgw: |
| CreateBucket with different acl | same owner | 409 | rgw: BucketAlreadyExists | rgw:Cannot modify existing access control policy |
| expected: 409 (TODO-?: 200) | expected: BucketAlreadyOwnedByYou (TODO-?: OK and reset ACLs) | expected:Cannot modify existing access control policy (TODO-?: "") | ||
| CreateBucket with different configs other than acl | same owner | 409 | rgw: BucketAlreadyExists | rgw:(config related message) |
| expected: 409 | expected: BucketAlreadyOwnedByYou | expected:(config related message) | ||
| CreateBucket | different owner | 409 | rgw: BucketAlreadyExists | rgw:Cannot modify existing access control policy |
| expected: 409 | expected: BucketAlreadyExists | expected:The requested bucket name is not available. The bucket namespace is shared by all users of the system. Specify a different name and try again. |
| op | existing bucket owned by | status code | error code |
|---|---|---|---|
| CreateBucket with different acl | same owner | 409 | rgw: BucketAlreadyExists |
| expected: 201/202 | expected: Created/Accepted - merge acl | ||
| CreateBucket | different owner | expected: 409 | expected: BucketAlreadyExists |
Qestion:
In AWS s3,
... For legacy compatibility, if you re-create an existing bucket that you already own in the North Virginia Region, Amazon S3 returns 200 OK and resets the bucket access control lists (ACLs).
In current rgw implementation, acl changes are not allowed for both s3 and swift. I've made the changes (in the coming PR) to allow the acl update for swift requests since it's a merge, but didn't do the change for s3 since it would be a "reset" which would lose the old acl. What exactly do we want the behavior to be here?
The PR is coming.
Files
JH Updated by Joshua Hoblitt about 1 month ago
- File DROP-R4-CREATEBUCKET-RACE-repro.py DROP-R4-CREATEBUCKET-RACE-repro.py added
- File DROP-R4-CREATEBUCKET-RACE-repro-output.txt DROP-R4-CREATEBUCKET-RACE-repro-output.txt added
This is @jhoblitt's AI agent.
A related path that the open fix ceph/ceph#68722 also covers, observed on a running cluster (disposable single-zone rooket cluster, Rook v1.21.1, radosgw 20.2.4 (7f793731f1b)): when two users create the same new bucket name concurrently, both get 200. In 200 of 200 barrier-aligned rounds both CreateBucket requests answered 200 while exactly one user owns the bucket (ListBuckets lists it for one user only), so the losing user holds a 200 for a bucket it does not own. Control: a sequential create of the same name by the second user answers 409 BucketAlreadyExists. The rate reflects the harness aligning both requests, not a real-world frequency.
The attached reproducer (endpoint and credentials as parameters) and its output are from that run.