]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lc: stop using merge_and_store_attrs in remove_bucket_config 63075/head
authorCasey Bodley <cbodley@redhat.com>
Fri, 25 Apr 2025 17:38:50 +0000 (13:38 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 30 Apr 2025 14:39:44 +0000 (10:39 -0400)
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 <cbodley@redhat.com>
(cherry picked from commit f3cc52124c650d32be2adf3cf540167142423c42)

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

index 42c5aea82db0f7f3f5378ed87599b9a59f187e48..fb020601b46652d0068b22d0875b9b763b2240be 100644 (file)
@@ -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
index 7b6ab57524e274b2fa80422a9492560a7789f978..9a719bcbd946073076fcc5e494c91c3899689cc6 100644 (file)
@@ -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
index de9dd1bfa2bc23614f55e7c9a8e1a8c531bbe73b..a18fbc0e5f0c6eaa9218e79b528b03f1918a3704 100644 (file)
@@ -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;
index 0cdba1365ca20b6b27734b8465aaf7178812336d..a813a7c28ac255f3edb1ab591c54623c1bec2c2e 100644 (file)
@@ -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(); }
index 75b38f09afabca18134002654626091326bd6627..6ae09bd19790bbe481903ad95c74781177011ef7 100644 (file)
@@ -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;
   }