]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notification: remove non x-amz-meta-* attributes from the metadata section of... 53376/head
authorJane Zhu <jzhu116@bloomberg.net>
Mon, 1 May 2023 23:09:18 +0000 (19:09 -0400)
committerJuan Zhu <jzhu4@dev-10-34-20-139.pw1.bcc.bloomberg.com>
Mon, 11 Sep 2023 03:02:16 +0000 (23:02 -0400)
Signed-off-by: Juan Zhu <jzhu4@dev-10-34-20-139.pw1.bcc.bloomberg.com>
(cherry picked from commit 4ca7643bf623b4dd18e112956af36fcb0c86d30a)

 Conflicts:
src/rgw/rgw_notify.cc

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

index 8d86b493bd37c07b0f8718d1338002bd8e49d6ec..1f859dc52ac75cfd59fe05f751af2339eeace463 100644 (file)
@@ -630,6 +630,14 @@ rgw::sal::RGWObject* get_object_with_atttributes(const req_state* s, rgw::sal::R
   return src_obj;
 }
 
+static inline void filter_amz_meta(meta_map_t& dest, const meta_map_t& src) {
+  std::copy_if(src.cbegin(), src.cend(),
+               std::inserter(dest, dest.end()),
+               [](const auto& m) {
+                 return (boost::algorithm::starts_with(m.first, RGW_AMZ_META_PREFIX));
+               });
+}
+
 void metadata_from_attributes(const req_state* s, rgw::sal::RGWObject* obj, KeyValueMap& metadata) {
   const auto src_obj = get_object_with_atttributes(s, obj);
   if (!src_obj) {
@@ -726,7 +734,7 @@ bool notification_match(reservation_t& res, const rgw_pubsub_topic_filter& filte
   const auto s = res.s;
   if (!filter.s3_filter.metadata_filter.kv.empty()) {
     // metadata filter exists
-    res.cached_metadata = s->info.x_meta_map;
+    filter_amz_meta(res.cached_metadata, s->info.x_meta_map);
     metadata_from_attributes(s, obj, res.cached_metadata);
     if (!match(filter.s3_filter.metadata_filter, res.cached_metadata)) {
       return false;
@@ -929,6 +937,15 @@ int publish_abort(const DoutPrefixProvider *dpp, reservation_t& res) {
   return 0;
 }
 
+reservation_t::reservation_t(const DoutPrefixProvider *_dpp,
+                             rgw::sal::RGWRadosStore* _store,
+                             const req_state* _s,
+                             rgw::sal::RGWObject* _object,
+                             const std::string* _object_name) :
+  dpp(_dpp), store(_store), s(_s), object(_object), object_name(_object_name) {
+  filter_amz_meta(cached_metadata, _s->info.x_meta_map);
+}
+
 reservation_t::~reservation_t() {
   publish_abort(dpp, *this);
 }
index 4aa8f0855501e54efecfe43a262b75cfe33909c2..9aee8fafe01ae411c25cf0bf55a451ebe45a7a48 100644 (file)
@@ -62,8 +62,7 @@ struct reservation_t {
   KeyValueMap cached_metadata;
 
   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) {}
+                rgw::sal::RGWObject* _object, const std::string* _object_name=nullptr);
 
   // dtor doing resource leak guarding
   // aborting the reservation if not already committed or aborted