Skip to content

nautilus: rgw: fix lc does not delete objects that do not have exactly the same tags as the rule #35002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/rgw/rgw_lc.cc
Original file line number Diff line number Diff line change
@@ -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;
}
}