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

merge: Allow duplicate keys in lhs #254

Conversation

apelisse
Copy link
Contributor

This not only affects merge but also Compare since they use the same algorithm/code.

Duplicates fields in a set/associative-list will now be treated as an atomic entity within that list, and will be entirely owned by the person who made them duplicates or who changed one of the duplicates.

That's the final fix for #234. This comes with extensive testing of all the scenarios I could think of. None of the existing behavior has changed.

/assign @liggitt @alexzielenski

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 20, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested a review from jpbetz October 20, 2023 17:23
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 20, 2023
@liggitt
Copy link

liggitt commented Oct 20, 2023

/hold to prevent accidental merge until review is done

looks like there are relevant unit test failures

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 20, 2023
@@ -179,7 +179,7 @@ func (s *Updater) Update(liveObject, newObject *typed.TypedValue, version fieldp
ignored = fieldpath.NewSet()
}
managers[manager] = fieldpath.NewVersionedSet(
managers[manager].Set().Union(compare.Modified).Union(compare.Added).Difference(compare.Removed).RecursiveDifference(ignored),
managers[manager].Set().Difference(compare.Removed).Union(compare.Modified).Union(compare.Added).RecursiveDifference(ignored),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the only functional line changing?

I'm trying to figure out why the order change matters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we go from duplicate to non-duplicate and vice versa, we add/remove the managedfields for duplicates and then remove/add the managedfields for the non-duplicated form. That does an add AND a remove, possibly of the same key. Because of how the line was written before, we would add the add and then remove the remove, which doesn't work for fields that are in both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the only functional line changing?

Yes

@apelisse
Copy link
Contributor Author

apelisse commented Oct 20, 2023

looks like there are relevant unit test failures

Yeah, the previous PR somewhat broke the union code that is technically not used. Since we might want to backport that change, I don't want to break the API. Not sure how to proceed. I could remove the internal code and just panic while keeping the actual API.
Or I could try to fix the union code but that doesn't sound like a useful effort.

@liggitt
Copy link

liggitt commented Oct 20, 2023

Yeah, the previous PR somewhat broke the union code that is technically not used

wait... those tests passed on that PR though, right?

@liggitt
Copy link

liggitt commented Oct 20, 2023

oh, these are new tests added in this PR

This not only affects merge but also `Compare` since they use the same
algorithm/code.

Duplicates fields in a set/associative-list will now be treated as an
atomic entity within that list, and will be entirely owned by the person
who made them duplicates or who changed one of the duplicates.
@apelisse apelisse force-pushed the allow-duplicates-in-associative-lists branch from 4c3addd to 29babbc Compare October 26, 2023 16:46
@apelisse
Copy link
Contributor Author

Tests are passing now, ready to merge, PTAL!

@liggitt
Copy link

liggitt commented Oct 27, 2023

/hold cancel
/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Oct 27, 2023
@k8s-ci-robot k8s-ci-robot merged commit cf09e71 into kubernetes-sigs:master Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants