Skip to content

Commit b454668

Browse files
committed
rgw: PutObjectLockConfiguration can enable object lock on existing buckets
AWS now allows PutObjectLockConfiguration on existing buckets, even if x-amz-bucket-object-lock-enabled was not specified on bucket creation object lock still requires the bucket to be versioning-enabled, so such requests are rejected otherwise. if the bucket is versioning-enabled but not object-lock-enabled, enable the BUCKET_OBJ_LOCK_ENABLED flag this logic was moved into retry_raced_bucket_write() in case the request races with PutBucketVersioning Fixes: https://tracker.ceph.com/issues/70013 Signed-off-by: Casey Bodley <[email protected]>
1 parent af9e68e commit b454668

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

PendingReleaseNotes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
headers only when the `read-stats` querystring is explicitly included in the
7373
API request.
7474

75+
* RGW: PutObjectLockConfiguration can now be used to enable S3 Object Lock on an
76+
existing versioning-enabled bucket that was not created with Object Lock enabled.
77+
7578
* RADOS: The ceph df command reports incorrect MAX AVAIL for stretch mode pools when
7679
CRUSH rules use multiple take steps for datacenters. PGMap::get_rule_avail
7780
incorrectly calculates available space from only one datacenter.

src/rgw/rgw_op.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8651,8 +8651,9 @@ int RGWPutBucketObjectLock::verify_permission(optional_yield y)
86518651

86528652
void RGWPutBucketObjectLock::execute(optional_yield y)
86538653
{
8654-
if (!s->bucket->get_info().obj_lock_enabled()) {
8655-
s->err.message = "object lock configuration can't be set if bucket object lock not enabled";
8654+
if (!s->bucket->get_info().versioning_enabled()) {
8655+
s->err.message = "Object lock cannot be enabled unless the "
8656+
"bucket has versioning enabled";
86568657
ldpp_dout(this, 4) << "ERROR: " << s->err.message << dendl;
86578658
op_ret = -ERR_INVALID_BUCKET_STATE;
86588659
return;
@@ -8695,6 +8696,17 @@ void RGWPutBucketObjectLock::execute(optional_yield y)
86958696
}
86968697

86978698
op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this, y] {
8699+
if (!s->bucket->get_info().obj_lock_enabled()) {
8700+
// automatically enable object lock if the bucket is versioning-enabled
8701+
if (!s->bucket->get_info().versioning_enabled()) {
8702+
s->err.message = "Object lock cannot be enabled unless the "
8703+
"bucket has versioning enabled";
8704+
ldpp_dout(this, 4) << "ERROR: " << s->err.message << dendl;
8705+
return -ERR_INVALID_BUCKET_STATE;
8706+
}
8707+
s->bucket->get_info().flags |= BUCKET_OBJ_LOCK_ENABLED;
8708+
}
8709+
86988710
s->bucket->get_info().obj_lock = obj_lock;
86998711
op_ret = s->bucket->put_info(this, false, real_time(), y);
87008712
return op_ret;

0 commit comments

Comments
 (0)