]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notifications: support metadata filter in CompleteMultipartUpload events 42566/head
authorYuval Lifshitz <ylifshit@redhat.com>
Sun, 20 Jun 2021 11:26:53 +0000 (14:26 +0300)
committerCory Snyder <csnyder@iland.com>
Fri, 30 Jul 2021 20:35:55 +0000 (16:35 -0400)
Fixes: https://tracker.ceph.com/issues/51261
Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
(cherry picked from commit 93b9f0fb77ca5ed0b5c89d45229732850e0a0c49)

Conflicts:
src/rgw/rgw_notify.h
src/rgw/rgw_op.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h
src/test/rgw/bucket_notification/test_bn.py

Cherry-pick notes:
- differences due to renaming of rgw::sal::RGWObject to rgw::sal::Object
- differences due to use of RadosNotification in master and reservation_t in Pacific

src/rgw/rgw_notify.cc
src/rgw/rgw_notify.h
src/rgw/rgw_op.cc

index 53fac8fd45c230d486db52e296481bd7d4f45389..4b0ea2723919fbbdd457521cb1e65277789cbe50 100644 (file)
@@ -675,7 +675,7 @@ void populate_event_from_request(const reservation_t& res,
   event.bucket_name = s->bucket_name;
   event.bucket_ownerIdentity = s->bucket_owner.get_id().id;
   event.bucket_arn = to_string(rgw::ARN(s->bucket->get_key()));
-  event.object_key = obj->get_name();
+  event.object_key = res.object_name ? *res.object_name : obj->get_name();
   event.object_size = size;
   event.object_etag = etag;
   event.object_versionId = obj->get_instance();
@@ -709,7 +709,8 @@ bool notification_match(reservation_t& res, const rgw_pubsub_topic_filter& filte
     return false;
   }
   const auto obj = res.object;
-  if (!match(filter.s3_filter.key_filter, obj->get_name())) {
+  if (!match(filter.s3_filter.key_filter, 
+        res.object_name ? *res.object_name : obj->get_name())) {
     return false;
   }
 
index a5bdc4d5485dec2d23ccafffeba525c4aa39b79b..4aa8f0855501e54efecfe43a262b75cfe33909c2 100644 (file)
@@ -58,10 +58,12 @@ struct reservation_t {
   const req_state* const s;
   size_t size;
   rgw::sal::RGWObject* const object;
+  const std::string* const object_name;
   KeyValueMap cached_metadata;
 
-  reservation_t(const DoutPrefixProvider *_dpp, rgw::sal::RGWRadosStore* _store, const req_state* _s, rgw::sal::RGWObject* _object) : 
-      dpp(_dpp), store(_store), s(_s), object(_object) {}
+  reservation_t(const DoutPrefixProvider *_dpp, rgw::sal::RGWRadosStore* _store, const req_state* _s,
+                rgw::sal::RGWObject* _object, const std::string* _object_name=nullptr) :
+      dpp(_dpp), store(_store), s(_s), object(_object), object_name(_object_name) {}
 
   // dtor doing resource leak guarding
   // aborting the reservation if not already committed or aborted
index 7f0f17124aeb213a33d3d625d7e12b88697f8dbd..dd2d0b0dcfb49e6723ecadffd309e6a89910a827 100644 (file)
@@ -5926,14 +5926,6 @@ void RGWCompleteMultipart::execute(optional_yield y)
 
   mp.init(s->object->get_name(), upload_id);
 
-  // make reservation for notification if needed
-  rgw::notify::reservation_t res(this, store, s, s->object.get());
-  const auto event_type = rgw::notify::ObjectCreatedCompleteMultipartUpload;
-  op_ret = rgw::notify::publish_reserve(this, event_type, res, nullptr);
-  if (op_ret < 0) {
-    return;
-  }
-
   meta_oid = mp.get_meta();
 
   int total_parts = 0;
@@ -5980,6 +5972,14 @@ void RGWCompleteMultipart::execute(optional_yield y)
   }
   attrs = meta_obj->get_attrs();
 
+  // make reservation for notification if needed
+  rgw::notify::reservation_t res(this, store, s, meta_obj.get(), &s->object->get_name());
+  const auto event_type = rgw::notify::ObjectCreatedCompleteMultipartUpload;
+  op_ret = rgw::notify::publish_reserve(this, event_type, res, nullptr);
+  if (op_ret < 0) {
+      return;
+  }
+
   do {
     op_ret = list_multipart_parts(this, store, s, upload_id, meta_oid, max_parts,
                                  marker, obj_parts, &marker, &truncated);