]> git-server-git.apps.pok.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... 30151/head
authorOr Friedmann <ofriedma@redhat.com>
Wed, 4 Sep 2019 13:34:52 +0000 (16:34 +0300)
committerOr Friedmann <ofriedma@redhat.com>
Sun, 8 Sep 2019 13:23:14 +0000 (16:23 +0300)
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>
src/rgw/rgw_lc.cc

index 18cb5aa84ba8a9f279e72214e02cc48e1d1444f6..3929183c499610ff06acc9c18fedc7d2bb863923 100644 (file)
@@ -452,20 +452,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 {
@@ -696,7 +697,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;
     }
   }