]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: introduce rgw_bucket_eexist_override
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 9 Mar 2025 16:30:24 +0000 (12:30 -0400)
committerThomas Serlin <tserlin@redhat.com>
Mon, 22 Sep 2025 19:18:18 +0000 (15:18 -0400)
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 <mbenjamin@redhat.com>
(cherry picked from commit d3009d41bf93a30740db5ca67272b3e303512026)

doc/radosgw/s3/bucketops.rst
src/common/options/rgw.yaml.in
src/rgw/rgw_common.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rest_s3.cc

index 488fd396f543b39b57682a2cb1829d5e3ceac74c..da0fc29c1919cfbd90dd3ad89c0f51a507e9db83 100644 (file)
@@ -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.
 
 +---------------+-----------------------+----------------------------------------------------------+
index ec7e6fbbb9f5624c35d9d88094b87119e84c0e86..577f2200d139853b293800791027cbcfdcb8a878 100644 (file)
@@ -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
index 290f73d0c7e1d004467435f172f660ab68fda39b..6cd1571100de8662677f438a290baa329e82e065 100644 (file)
@@ -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"}},
index 6ae80e55d5d9c8f67b4adfe3dcc9d781fdb8eaac..74aff10517486145816f2095099f588e3fd9e4e9 100644 (file)
@@ -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)
 {
index 34e8100d4375185d79e88399fd5b56786c93a23a..a6d4bba93b0cf7bbc75482e3c65815eaabf723d2 100644 (file)
@@ -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<bool>("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);