Skip to content

Commit a84a5a6

Browse files
authored
Merge pull request ceph#62186 from linuxbox2/wip-rgw-cb409
rgw: introduce rgw_bucket_eexist_override
2 parents dd7948a + d3009d4 commit a84a5a6

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

doc/radosgw/s3/bucketops.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ HTTP Response
5959
~~~~~~~~~~~~~
6060

6161
If the bucket name is unique, within constraints and unused, the operation will succeed.
62-
If a bucket with the same name already exists and the user is the bucket owner, the operation will succeed.
62+
If a bucket with the same name already exists and the user is the
63+
bucket owner, the operation will succeed unless non-default option
64+
``rgw_bucket_eexist_override`` is `true`.
6365
If the bucket name is already in use, the operation will fail.
6466

6567
+---------------+-----------------------+----------------------------------------------------------+

src/common/options/rgw.yaml.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4349,3 +4349,12 @@ options:
43494349
flags:
43504350
- startup
43514351
with_legacy: true
4352+
- name: rgw_bucket_eexist_override
4353+
type: bool
4354+
level: advanced
4355+
desc: CreateBucket on an existing bucket of the same owner returns 409/EEXIST, regardless of region.
4356+
long_desc: Overrides the documented RGW behavior that treats multiple CreateBucket operations by the same
4357+
owner as idempotent
4358+
default: false
4359+
services:
4360+
- rgw

src/rgw/rgw_common.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ rgw_http_errors rgw_http_s3_errors({
112112
{ ERR_METHOD_NOT_ALLOWED, {405, "MethodNotAllowed" }},
113113
{ ETIMEDOUT, {408, "RequestTimeout" }},
114114
{ EEXIST, {409, "BucketAlreadyExists" }},
115+
{ ERR_BUCKET_EXISTS, {409, "BucketAlreadyExists" }},
115116
{ ERR_USER_EXIST, {409, "UserAlreadyExists" }},
116117
{ ERR_EMAIL_EXIST, {409, "EmailExists" }},
117118
{ ERR_KEY_EXIST, {409, "KeyExists"}},

src/rgw/rgw_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,8 +3889,8 @@ void RGWCreateBucket::execute(optional_yield y)
38893889
if (op_ret >= 0) {
38903890
op_ret = -ERR_BUCKET_EXISTS;
38913891
}
3892-
}
3893-
}
3892+
} /* if (need_metadata_upload() && existed) */
3893+
} /* RGWCreateBucket::execute() */
38943894

38953895
int RGWDeleteBucket::verify_permission(optional_yield y)
38963896
{

src/rgw/rgw_rest_s3.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,10 +2692,18 @@ int RGWCreateBucket_ObjStore_S3::get_params(optional_yield y)
26922692

26932693
void RGWCreateBucket_ObjStore_S3::send_response()
26942694
{
2695-
if (op_ret == -ERR_BUCKET_EXISTS)
2696-
op_ret = 0;
2697-
if (op_ret)
2695+
if (op_ret == -ERR_BUCKET_EXISTS) {
2696+
const auto eexist_override = s->cct->_conf.get_val<bool>("rgw_bucket_eexist_override");
2697+
if (! eexist_override) [[likely]] {
2698+
op_ret = 0;
2699+
} else {
2700+
s->err.message = "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.";
2701+
}
2702+
}
2703+
2704+
if (op_ret) {
26982705
set_req_state_err(s, op_ret);
2706+
}
26992707
dump_errno(s);
27002708
end_header(s);
27012709

0 commit comments

Comments
 (0)