]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
fix rgw lc does not delete objects that do not have exactly the same tags as the... 35002/head
authorOr Friedmann <ofriedma@redhat.com>
Wed, 4 Sep 2019 13:34:52 +0000 (16:34 +0300)
committerNathan Cutler <ncutler@suse.com>
Mon, 11 May 2020 16:36:15 +0000 (18:36 +0200)
It is possible that object will have multiple tags more than the rule that applied on.
Object is not being deleted if not all tags exactly the same as in the rule.

S3-tests: ceph/s3-tests#303
Fixes: https://tracker.ceph.com/issues/41652
Signed-off-by: Or Friedmann <ofriedma@redhat.com>
(cherry picked from commit ebb806ba83fa9d68f14194b1f9886f21f7195a3d)

src/rgw/rgw_lc.cc

index 389e2bc48b6b7324d391f63e9a9a2c063a540bb9..438249a71b60fea98537ac4ca4bf09d6419f6931 100644 (file)
@@ -446,20 +446,21 @@ static bool is_valid_op(const lc_op& op)
 static inline bool has_all_tags(const lc_op& rule_action,
                                const RGWObjTags& object_tags)
 {
+  if(! rule_action.obj_tags)
+    return false;
+  if(object_tags.count() < rule_action.obj_tags->count())
+    return false;
+  size_t tag_count = 0;
   for (const auto& tag : object_tags.get_tags()) {
-
-    if (! rule_action.obj_tags)
-      return false;
-
     const auto& rule_tags = rule_action.obj_tags->get_tags();
     const auto& iter = rule_tags.find(tag.first);
-
-    if ((iter == rule_tags.end()) ||
-       (iter->second != tag.second))
-      return false;
+    if(iter->second == tag.second)
+    {
+      tag_count++;
+    }
+  /* all tags in the rule appear in obj tags */
   }
-  /* all tags matched */
-  return true;
+  return tag_count == rule_action.obj_tags->count();
 }
 
 class LCObjsLister {
@@ -687,7 +688,7 @@ static int check_tags(lc_op_ctx& oc, bool *skip)
     }
 
     if (! has_all_tags(op, dest_obj_tags)) {
-      ldout(oc.cct, 20) << __func__ << "() skipping obj " << oc.obj << " as tags do not match" << dendl;
+      ldout(oc.cct, 20) << __func__ << "() skipping obj " << oc.obj << " as tags do not match in rule: " << op.id << dendl;
       return 0;
     }
   }