]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc: send pool transition notifications too
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 19 May 2024 16:42:32 +0000 (12:42 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 2 Jan 2025 18:18:49 +0000 (13:18 -0500)
Fixes: https://tracker.ceph.com/issues/66111
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_lc.cc

index c9fb4765d59d728cab1bf0943b0c0862644f2700..fb7eb26b17923d47e4047ab231385e5462285a37 100644 (file)
@@ -1456,6 +1456,49 @@ public:
       return 0;
     }
 
+    /* notifications */
+    auto& bucket = oc.bucket;
+    auto& obj = oc.obj;
+
+    string etag;
+    r = obj->load_obj_state(oc.dpp, null_yield, true);
+    if (r < 0) {
+      ldpp_dout(oc.dpp, 0) <<
+       fmt::format("ERROR: get_obj_state() failed on transition of object k={} error r={}",
+                   oc.o.key.to_string(), r) << dendl;
+      return r;
+    }
+
+    auto attrset = obj->get_attrs();
+    auto iter = attrset.find(RGW_ATTR_ETAG);
+    if (iter != attrset.end()) {
+      etag = rgw_bl_str(iter->second);
+    }
+
+    rgw::notify::EventTypeList event_types;
+    event_types.insert(event_types.end(), {rgw::notify::LifecycleTransition});
+    if ((!bucket->versioned()) ||
+       (bucket->versioned() && oc.o.is_current() && !oc.o.is_delete_marker())) {
+      event_types.push_back(rgw::notify::ObjectTransitionCurrent);
+    } else {
+      event_types.push_back(rgw::notify::ObjectTransitionNoncurrent);
+    }
+
+    std::unique_ptr<rgw::sal::Notification> notify =
+        oc.driver->get_notification(
+            oc.dpp, obj.get(), nullptr, event_types, bucket, lc_id,
+            const_cast<std::string&>(oc.bucket->get_tenant()), lc_req_id,
+            null_yield);
+    auto version_id = oc.o.key.instance;
+
+    r = notify->publish_reserve(oc.dpp, nullptr);
+    if (r < 0) {
+      ldpp_dout(oc.dpp, 1)
+       << "WARNING: notify reservation failed for transition of object k="
+       << oc.o.key
+       << dendl;
+    }
+
     std::string tier_type = ""; 
     rgw::sal::ZoneGroup& zonegroup = oc.driver->get_zone()->get_zonegroup();
 
@@ -1503,6 +1546,16 @@ public:
         return r;
       }
     }
+
+    // send request to notification manager
+    int publish_ret =
+      notify->publish_commit(oc.dpp, obj->get_size(), ceph::real_clock::now(),
+                            etag, version_id);
+    if (publish_ret < 0) {
+      ldpp_dout(oc.dpp, 5) <<
+       "WARNING: notify publish_commit failed, with error: " << publish_ret << dendl;
+    }
+
     ldpp_dout(oc.dpp, 2) << "TRANSITIONED:" << oc.bucket
                         << ":" << o.key << " -> "
                         << transition.storage_class