]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/create_bucket: for s3:createbucket calls return immediately if bucket already...
authorkchheda3 <kchheda3@bloomberg.net>
Fri, 5 Sep 2025 18:12:05 +0000 (14:12 -0400)
committerkchheda3 <kchheda3@bloomberg.net>
Fri, 5 Sep 2025 18:15:12 +0000 (14:15 -0400)
Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
src/rgw/rgw_op.cc

index 421c266b6d1587f291aafe4d321a0e8056cb36b5..f7a8746f717e9ff2fd80116173741c49636d6e55 100644 (file)
@@ -3798,6 +3798,24 @@ void RGWCreateBucket::execute(optional_yield y)
       return;
     }
 
+    // prevent re-creation with different index type or shard count
+    if ((createparams.index_type && *createparams.index_type !=
+         info.layout.current_index.layout.type) ||
+        (createparams.index_shards && *createparams.index_shards !=
+         info.layout.current_index.layout.normal.num_shards)) {
+      s->err.message =
+          "Cannot modify existing bucket's index type or shard count";
+      op_ret = -EEXIST;
+      return;
+    }
+
+    // don't allow changes to object lock
+    if (createparams.obj_lock_enabled != info.obj_lock_enabled()) {
+      s->err.message = "Cannot modify existing bucket's object lock";
+      op_ret = -EEXIST;
+      return;
+    }
+
     // don't allow changes to the acl policy
     RGWAccessControlPolicy old_policy;
     int r = rgw_op_get_bucket_policy_from_attr(this, s->cct, driver, info.owner,
@@ -3808,6 +3826,14 @@ void RGWCreateBucket::execute(optional_yield y)
       op_ret = -EEXIST;
       return;
     }
+
+    // For s3::CreateBucket just return back if bucket exists, as we do not allow
+    // any changes in bucket config param. need_metadata_upload() is always false
+    // for S3, so use the check to decide if its s3 request and not swift request.
+    if (!need_metadata_upload()) {
+      op_ret = -ERR_BUCKET_EXISTS;
+      return;
+    }
   }
 
   s->bucket_owner = policy.get_owner();