From: Matt Benjamin Date: Sun, 9 Mar 2025 16:30:24 +0000 (-0400) Subject: rgw: introduce rgw_bucket_eexist_override X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eebec76779609d2487a7aeb81cf80fa4b4f89a29;p=ceph-ci.git rgw: introduce rgw_bucket_eexist_override S3: conditionally override 200, OK result for same-owner CreateBucket requests * also send an error message to avoid confusing awscli * maps ERR_BUCKET_EXISTS to the same result, message as EEXIST Fixes: https://tracker.ceph.com/issues/70369 Resolves: rhbz#2336983 Signed-off-by: Matt Benjamin (cherry picked from commit d3009d41bf93a30740db5ca67272b3e303512026) --- diff --git a/doc/radosgw/s3/bucketops.rst b/doc/radosgw/s3/bucketops.rst index 488fd396f54..da0fc29c191 100644 --- a/doc/radosgw/s3/bucketops.rst +++ b/doc/radosgw/s3/bucketops.rst @@ -59,7 +59,9 @@ HTTP Response ~~~~~~~~~~~~~ If the bucket name is unique, within constraints and unused, the operation will succeed. -If a bucket with the same name already exists and the user is the bucket owner, the operation will succeed. +If a bucket with the same name already exists and the user is the +bucket owner, the operation will succeed unless non-default option +``rgw_bucket_eexist_override`` is `true`. If the bucket name is already in use, the operation will fail. +---------------+-----------------------+----------------------------------------------------------+ diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index ec7e6fbbb9f..577f2200d13 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -4421,3 +4421,12 @@ options: flags: - startup with_legacy: true +- name: rgw_bucket_eexist_override + type: bool + level: advanced + desc: CreateBucket on an existing bucket of the same owner returns 409/EEXIST, regardless of region. + long_desc: Overrides the documented RGW behavior that treats multiple CreateBucket operations by the same + owner as idempotent + default: false + services: + - rgw diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 290f73d0c7e..6cd1571100d 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -112,6 +112,7 @@ rgw_http_errors rgw_http_s3_errors({ { ERR_METHOD_NOT_ALLOWED, {405, "MethodNotAllowed" }}, { ETIMEDOUT, {408, "RequestTimeout" }}, { EEXIST, {409, "BucketAlreadyExists" }}, + { ERR_BUCKET_EXISTS, {409, "BucketAlreadyExists" }}, { ERR_USER_EXIST, {409, "UserAlreadyExists" }}, { ERR_EMAIL_EXIST, {409, "EmailExists" }}, { ERR_KEY_EXIST, {409, "KeyExists"}}, diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 6ae80e55d5d..74aff105174 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3920,8 +3920,8 @@ void RGWCreateBucket::execute(optional_yield y) if (op_ret >= 0) { op_ret = -ERR_BUCKET_EXISTS; } - } -} + } /* if (need_metadata_upload() && existed) */ +} /* RGWCreateBucket::execute() */ int RGWDeleteBucket::verify_permission(optional_yield y) { diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 34e8100d437..a6d4bba93b0 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -2696,10 +2696,18 @@ int RGWCreateBucket_ObjStore_S3::get_params(optional_yield y) void RGWCreateBucket_ObjStore_S3::send_response() { - if (op_ret == -ERR_BUCKET_EXISTS) - op_ret = 0; - if (op_ret) + if (op_ret == -ERR_BUCKET_EXISTS) { + const auto eexist_override = s->cct->_conf.get_val("rgw_bucket_eexist_override"); + if (! eexist_override) [[likely]] { + op_ret = 0; + } else { + 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."; + } + } + + if (op_ret) { set_req_state_err(s, op_ret); + } dump_errno(s); end_header(s);