From 36bc8e4242a352830dce516f4b40e3dfa0de72f5 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) Conflicts: src/rgw/driver/rados/rgw_bucket.cc src/rgw/driver/rados/rgw_sal_rados.cc src/rgw/rgw_lc.cc src/rgw/rgw_lc.h src/rgw/rgw_op.cc mostly because squid doesn't have changes to remove metadata backends --- src/rgw/driver/rados/rgw_bucket.cc | 3 ++- src/rgw/driver/rados/rgw_sal_rados.cc | 4 ++-- src/rgw/rgw_lc.cc | 15 +++++++-------- src/rgw/rgw_lc.h | 7 ++++--- src/rgw/rgw_op.cc | 5 ++++- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/rgw/driver/rados/rgw_bucket.cc b/src/rgw/driver/rados/rgw_bucket.cc index 850e99ba141..ebc452644a4 100644 --- a/src/rgw/driver/rados/rgw_bucket.cc +++ b/src/rgw/driver/rados/rgw_bucket.cc @@ -2863,7 +2863,8 @@ int RGWMetadataHandlerPut_BucketInstance::put_post(const DoutPrefixProvider *dpp } else { ldpp_dout(dpp, 20) << "remove lc config for " << bci.info.bucket.name << dendl; - ret = lc->remove_bucket_config(bucket.get(), 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 " << 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 29e907825ba..65ca6b05d69 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -401,9 +401,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( - 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 5e6b9f182d9..3d7d693f2b6 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -2665,18 +2665,17 @@ int RGWLC::set_bucket_config(rgw::sal::Bucket* bucket, return ret; } -int RGWLC::remove_bucket_config(rgw::sal::Bucket* bucket, - const rgw::sal::Attrs& bucket_attrs, - bool merge_attrs) +int RGWLC::remove_bucket_config(const DoutPrefixProvider* dpp, optional_yield y, + 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(this, attrs, null_yield); - + // 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(this, 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 75244be9a3a..d8873574e9c 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -656,9 +656,10 @@ public: int set_bucket_config(rgw::sal::Bucket* bucket, const rgw::sal::Attrs& bucket_attrs, RGWLifecycleConfiguration *config); - int remove_bucket_config(rgw::sal::Bucket* bucket, - const rgw::sal::Attrs& bucket_attrs, - bool merge_attrs = true); + // 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, 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 83d5554c62b..7bc2be53055 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -6028,7 +6028,10 @@ void RGWDeleteLC::execute(optional_yield y) return; } - op_ret = driver->get_rgwlc()->remove_bucket_config(s->bucket.get(), s->bucket_attrs); + // 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(), + update_attrs); if (op_ret < 0) { return; } -- 2.39.5