Skip to content
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

[BUG] rgw/sfs: SFSBucket::merge_and_store_attrs should not drop entries not defined in the new_attrs #750

Closed
giubacc opened this issue Oct 9, 2023 · 5 comments
Assignees
Labels
area/rgw-sfs RGW & SFS related kind/bug Something isn't working priority/1 Should be fixed for next release triage/invalid This doesn't seem right
Milestone

Comments

@giubacc
Copy link

giubacc commented Oct 9, 2023

In SFSBucket::merge_and_store_attrs we should drop this block:

  for (auto& it : attrs) {
    auto it_find = new_attrs.find(it.first);
    if (it_find == new_attrs.end()) {
      // this is an old attr that is not defined in the new_attrs
      // delete it
      attrs.erase(it.first);
    }
  }

The method should only merge and not set the new attributes into the current attributes.

@giubacc giubacc added the area/rgw-sfs RGW & SFS related label Oct 9, 2023
@giubacc giubacc added this to S3GW Oct 9, 2023
@github-project-automation github-project-automation bot moved this to Backlog in S3GW Oct 9, 2023
@github-actions github-actions bot added the triage/waiting Waiting for triage label Oct 9, 2023
@giubacc giubacc added the kind/bug Something isn't working label Oct 9, 2023
@jecluis
Copy link
Contributor

jecluis commented Oct 19, 2023

@giubacc can you provide something that reproduces the behavior, or a set of commands with the final expected state?

@giubacc
Copy link
Author

giubacc commented Oct 19, 2023

Example: supposing current_attrs has the following items:

{A, B, C}

and new_attrs

{A, C, D}

calling the method produces:

{A, C, D}

but, given that this should be a merge the set should be this:

{A, B, C, D}

I haven't a concrete case to report, I stumbled into that code accidentally when looking another thing.
I've talked a bit with @0xavi0 about this and I think the code above was added to make some lifecycle test passing (?)

@jecluis
Copy link
Contributor

jecluis commented Oct 19, 2023

Thanks. This sounds like a potentially low-hanging fruit, so lets see if we can handle it soon.

@jecluis jecluis added priority/1 Should be fixed for next release and removed triage/waiting Waiting for triage labels Oct 19, 2023
@jecluis jecluis added this to the v0.23.0 milestone Oct 19, 2023
@giubacc
Copy link
Author

giubacc commented Nov 13, 2023

Well, I've gone in depth into this and the true reality is that the method: merge_and_store_attrs is actually used as a set_and_store_attrs.

For example, consider this fragment from RGWDeleteBucketTags::execute:

    rgw::sal::Attrs attrs = s->bucket->get_attrs();
    attrs.erase(RGW_ATTR_TAGS);
    op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);

The merge as intended in my previous comment is not the case.
Given that I devoted some time into this I decided to go with a PR simplify the current unnecessary complicated logic and rewrite the method as it should be: a simple set.

@giubacc giubacc added the triage/invalid This doesn't seem right label Nov 13, 2023
@giubacc
Copy link
Author

giubacc commented Nov 13, 2023

Invalid

@giubacc giubacc closed this as completed Nov 13, 2023
@github-project-automation github-project-automation bot moved this from Backlog to Done in S3GW Nov 13, 2023
giubacc referenced this issue in giubacc/ceph Nov 13, 2023
Refactored with a set_and_store_attrs semantics.
The previous implementation was started as if the method should implement a merge but the actual usage suggests set semantics.
The new implementation is more concise and simplified.

Related to: https://github.com/aquarist-labs/s3gw/issues/750
Signed-off-by: Giuseppe Baccini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rgw-sfs RGW & SFS related kind/bug Something isn't working priority/1 Should be fixed for next release triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants