From: Or Friedmann Date: Wed, 4 Sep 2019 13:34:52 +0000 (+0300) Subject: fix rgw lc does not delete objects that do not have exactly the same tags as the... X-Git-Tag: v14.2.10~73^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=79ca46089429ec32c9187e9965c252951df328e9;p=ceph.git fix rgw lc does not delete objects that do not have exactly the same tags as the rule 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 (cherry picked from commit ebb806ba83fa9d68f14194b1f9886f21f7195a3d) --- diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 389e2bc48b6b..438249a71b60 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -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; } }