From 38971a062eb0d7afab430d50c66879957152ebe7 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 25 Apr 2025 13:38:50 -0400 Subject: [PATCH] rgw/lc: stop using merge_and_store_attrs in remove_bucket_config merge_and_store_attrs() is no longer able to remove xattrs. change the sal::Bucket's attrs manually and call put_info() to write them back Fixes: https://tracker.ceph.com/issues/71083 Signed-off-by: Casey Bodley (cherry picked from commit f3cc52124c650d32be2adf3cf540167142423c42) --- src/rgw/driver/rados/rgw_bucket.cc | 3 ++- src/rgw/driver/rados/rgw_sal_rados.cc | 4 ++-- src/rgw/rgw_lc.cc | 14 ++++++-------- src/rgw/rgw_lc.h | 6 +++--- src/rgw/rgw_op.cc | 4 +++- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/rgw/driver/rados/rgw_bucket.cc b/src/rgw/driver/rados/rgw_bucket.cc index 42c5aea82db0f..fb020601b4665 100644 --- a/src/rgw/driver/rados/rgw_bucket.cc +++ b/src/rgw/driver/rados/rgw_bucket.cc @@ -2974,7 +2974,8 @@ int RGWBucketInstanceMetadataHandler::put_post( lc_it = old_bci->attrs.find(RGW_ATTR_LC); if (lc_it != old_bci->attrs.end()) { ldpp_dout(dpp, 20) << "remove lc config for " << old_bci->info.bucket.name << dendl; - ret = lc->remove_bucket_config(dpp, y, bucket.get(), old_bci->attrs, false /* cannot merge attrs */); + constexpr bool update_attrs = false; + ret = lc->remove_bucket_config(dpp, y, bucket.get(), update_attrs); if (ret < 0) { ldpp_dout(dpp, 0) << __func__ << " failed to remove lc config for " << old_bci->info.bucket.name diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 7b6ab57524e27..9a719bcbd9460 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -413,9 +413,9 @@ int RadosBucket::remove(const DoutPrefixProvider* dpp, // remove lifecycle config, if any (XXX note could be made generic) if (get_attrs().count(RGW_ATTR_LC)) { - constexpr bool merge_attrs = false; // don't update xattrs, we're deleting + constexpr bool update_attrs = false; // don't update xattrs, we're deleting (void) store->getRados()->get_lc()->remove_bucket_config( - dpp, y, this, get_attrs(), merge_attrs); + dpp, y, this, update_attrs); } // remove bucket-topic mapping diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index de9dd1bfa2bc2..a18fbc0e5f0c6 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -2719,18 +2719,16 @@ int RGWLC::set_bucket_config(const DoutPrefixProvider* dpp, optional_yield y, } int RGWLC::remove_bucket_config(const DoutPrefixProvider* dpp, optional_yield y, - rgw::sal::Bucket* bucket, - const rgw::sal::Attrs& bucket_attrs, - bool merge_attrs) + rgw::sal::Bucket* bucket, bool update_attrs) { - rgw::sal::Attrs attrs = bucket_attrs; rgw_bucket& b = bucket->get_key(); int ret{0}; - if (merge_attrs) { - attrs.erase(RGW_ATTR_LC); - ret = bucket->merge_and_store_attrs(dpp, attrs, y); - + // remove the lifecycle attr if present. if not, try to remove from + // the 'lc list' anyway + rgw::sal::Attrs& attrs = bucket->get_attrs(); + if (update_attrs && attrs.erase(RGW_ATTR_LC)) { + ret = bucket->put_info(dpp, false, real_time(), y); if (ret < 0) { ldpp_dout(dpp, 0) << "RGWLC::RGWDeleteLC() failed to set attrs on bucket=" << b.name << " returned err=" << ret << dendl; diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 0cdba1365ca20..a813a7c28ac25 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -657,10 +657,10 @@ public: rgw::sal::Bucket* bucket, const rgw::sal::Attrs& bucket_attrs, RGWLifecycleConfiguration *config); + // remove a bucket from the lc list, and optionally update the bucket + // instance metadata to remove RGW_ATTR_LC int remove_bucket_config(const DoutPrefixProvider* dpp, optional_yield y, - rgw::sal::Bucket* bucket, - const rgw::sal::Attrs& bucket_attrs, - bool merge_attrs = true); + rgw::sal::Bucket* bucket, bool update_attrs); CephContext *get_cct() const override { return cct; } rgw::sal::Lifecycle* get_lc() const { return sal_lc.get(); } diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 75b38f09afabc..6ae09bd19790b 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -6393,8 +6393,10 @@ void RGWDeleteLC::execute(optional_yield y) return; } + // remove RGW_ATTR_LC and remove the bucket from the 'lc list' + constexpr bool update_attrs = true; op_ret = driver->get_rgwlc()->remove_bucket_config(this, y, s->bucket.get(), - s->bucket_attrs); + update_attrs); if (op_ret < 0) { return; } -- 2.39.5