Skip to content

Commit e61bfe0

Browse files
committed
rgw/create_bucket: for s3:createbucket calls return immediately if bucket already exists without updating the metadata.
Signed-off-by: kchheda3 <[email protected]>
1 parent 202275a commit e61bfe0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/rgw/rgw_op.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3798,6 +3798,24 @@ void RGWCreateBucket::execute(optional_yield y)
37983798
return;
37993799
}
38003800

3801+
// prevent re-creation with different index type or shard count
3802+
if ((createparams.index_type && *createparams.index_type !=
3803+
info.layout.current_index.layout.type) ||
3804+
(createparams.index_shards && *createparams.index_shards !=
3805+
info.layout.current_index.layout.normal.num_shards)) {
3806+
s->err.message =
3807+
"Cannot modify existing bucket's index type or shard count";
3808+
op_ret = -EEXIST;
3809+
return;
3810+
}
3811+
3812+
// don't allow changes to object lock
3813+
if (createparams.obj_lock_enabled != info.obj_lock_enabled()) {
3814+
s->err.message = "Cannot modify existing bucket's object lock";
3815+
op_ret = -EEXIST;
3816+
return;
3817+
}
3818+
38013819
// don't allow changes to the acl policy
38023820
RGWAccessControlPolicy old_policy;
38033821
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)
38083826
op_ret = -EEXIST;
38093827
return;
38103828
}
3829+
3830+
// For s3::CreateBucket just return back if bucket exists, as we do not allow
3831+
// any changes in bucket config param. need_metadata_upload() is always false
3832+
// for S3, so use the check to decide if its s3 request and not swift request.
3833+
if (!need_metadata_upload()) {
3834+
op_ret = -ERR_BUCKET_EXISTS;
3835+
return;
3836+
}
38113837
}
38123838

38133839
s->bucket_owner = policy.get_owner();

0 commit comments

Comments
 (0)