From: Yuval Lifshitz Date: Sun, 20 Jun 2021 11:26:53 +0000 (+0300) Subject: rgw/notifications: support metadata filter in CompleteMultipartUpload events X-Git-Tag: v16.2.6~84^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a39dcde52d9ab81d2d27fac9f43079190a6c1d35;p=ceph.git rgw/notifications: support metadata filter in CompleteMultipartUpload events Fixes: https://tracker.ceph.com/issues/51261 Signed-off-by: Yuval Lifshitz (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 --- diff --git a/src/rgw/rgw_notify.cc b/src/rgw/rgw_notify.cc index 53fac8fd45c2..4b0ea2723919 100644 --- a/src/rgw/rgw_notify.cc +++ b/src/rgw/rgw_notify.cc @@ -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; } diff --git a/src/rgw/rgw_notify.h b/src/rgw/rgw_notify.h index a5bdc4d5485d..4aa8f0855501 100644 --- a/src/rgw/rgw_notify.h +++ b/src/rgw/rgw_notify.h @@ -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 diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 7f0f17124aeb..dd2d0b0dcfb4 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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);