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

feat(appset): Support various merge strategies for merge generator #16080

Open
wants to merge 37 commits into
base: master
Choose a base branch
from

Conversation

sonamkshenoy
Copy link
Member

@sonamkshenoy sonamkshenoy commented Oct 23, 2023

Support for various merge strategies in merge generator. Includes:
left-join, left-join-uniq, inner-join, inner-join-uniq, full-join, full-join-uniq

This PR also allows more than one parameter sets to have the same merge key in the base generator

Fixes #11952, #12837, #14560

@sonamkshenoy sonamkshenoy requested review from a team as code owners October 23, 2023 17:44
@sonamkshenoy
Copy link
Member Author

sonamkshenoy commented Oct 23, 2023

@crenshaw-dev Please review. Thank you!!

Also, do you think it's better to have a more intuitive name for the flag?
Something like allowNonUniqBaseMergeKeys

@crenshaw-dev
Copy link
Member

Actually, I think we should probably have a string field called mergeMode to accommodate new modes as they come up.

@crenshaw-dev crenshaw-dev changed the title Support duplicate merge key-value pairs in base generator (#11952) feat(appset) Support duplicate merge key-value pairs in base generator (#11952) Oct 25, 2023
@sonamkshenoy sonamkshenoy changed the title feat(appset) Support duplicate merge key-value pairs in base generator (#11952) feat(appset) Support various merge strategies for merge generator Nov 6, 2023
@darkradish
Copy link

Hello !
This Pull request can make applicationSets very powerfull !
@sonamkshenoy do you work at it ? do you want some help ?

@sonamkshenoy
Copy link
Member Author

sonamkshenoy commented Dec 1, 2023

Hey @darkradish
Thank you!
Yes, I'm actively working on it. Thanks for your offer to help; I'm actually waiting for a review from one of the maintainers. :)

Copy link

codecov bot commented Dec 21, 2023

Codecov Report

Attention: Patch coverage is 72.22222% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 49.50%. Comparing base (d595550) to head (c35ac69).
Report is 185 commits behind head on master.

❗ Current head c35ac69 differs from pull request most recent head 1548125. Consider uploading reports for the commit 1548125 to get more accurate results

Files Patch % Lines
applicationset/generators/merge.go 72.22% 13 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #16080      +/-   ##
==========================================
+ Coverage   49.48%   49.50%   +0.01%     
==========================================
  Files         271      271              
  Lines       47728    47774      +46     
==========================================
+ Hits        23620    23651      +31     
- Misses      21773    21782       +9     
- Partials     2335     2341       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sonamkshenoy sonamkshenoy changed the title feat(appset) Support various merge strategies for merge generator feat(appset): Support various merge strategies for merge generator Dec 21, 2023
@ptr1120
Copy link

ptr1120 commented Feb 20, 2024

Are there any plans to merge this awesome feature?

@Boeller666
Copy link

Same question here... will this feature be merged in the near future?
This would help a lot!

@alancaldelas
Copy link

I am also very interested in this

Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

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

Code looks good. I think the user documentation needs to be clarified a bit more to explain the results expected by the different modes.

## Merge Modes (Join types)
With the `uniq` merge modes (`left-join-uniq`, `inner-join-uniq`, `full-join-uniq`), all the parameter sets produced by any of the generators under a Merge generator, need to have unique values for the configured merge keys.

However, this behaviour can be changed by using any of the merge modes that do not end with `-uniq`. This will allow more than one parameter sets of (only) the **base generator** to have the same values for the merge keys.
Copy link
Member

Choose a reason for hiding this comment

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

This will allow more than one parameter sets of (only) the base generator

I find it hard to understand the meaning of this sentence. Why is only in parenthesis? what is the base generator?

Choose a reason for hiding this comment

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

would it be helpful to provide the equivalent SQL to explain joins? It seems like the -uniq is kind of like using DISTINCT, but rather, instead of actually doing distinct, it just errors if there are merge keys that are identical.

Copy link
Member

Choose a reason for hiding this comment

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

We cannot expect users to be familiar with SQL. The documentation should be simple enough for a user not familiar with left/inner/full terminology to understand the behavior of these modes.

Something like

With the `uniq` merge modes (`left-join-uniq`, `inner-join-uniq`, `full-join-uniq`), all the parameter sets produced by any generators under a Merge generator need to have unique values for the configured merge keys. An error preventing the generation will be returned when duplicated keys are found.

However, I am still not sure what you are trying to explain with the last sentence of the second paragraph.

docs/operator-manual/applicationset/Generators-Merge.md Outdated Show resolved Hide resolved
docs/operator-manual/applicationset/Generators-Merge.md Outdated Show resolved Hide resolved
redis: 'true'
```
The same behaviour can be obtained with any of the non-uniq merge modes (`left-join`, `inner-join`, `full-join`)
The types of join hold the same meanings as their equivalent SQL joins.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a short explanation on the result of inner and full join with the example above would help the users understand which mode to use better.

Choose a reason for hiding this comment

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

ya, what's the point of the -uniq variants? In this example, if server was added to the mergeKeys list, would left-join-uniq work?

docs/operator-manual/applicationset/Generators-Merge.md Outdated Show resolved Hide resolved
applicationset/generators/merge.go Outdated Show resolved Hide resolved
sonamkshenoy and others added 2 commits March 12, 2024 09:21
Co-authored-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Sonam <[email protected]>
Co-authored-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Sonam <[email protected]>
@ProbstenHias
Copy link

Hi, what is the progress here, I would love to see this working as we have the need for exactly this feature.
I could help out with this if you want.

## Merge Modes (Join types)
With the `uniq` merge modes (`left-join-uniq`, `inner-join-uniq`, `full-join-uniq`), all the parameter sets produced by any of the generators under a Merge generator, need to have unique values for the configured merge keys.

However, this behaviour can be changed by using any of the merge modes that do not end with `-uniq`. This will allow more than one parameter sets of (only) the **base generator** to have the same values for the merge keys.
Copy link

@ProbstenHias ProbstenHias Apr 18, 2024

Choose a reason for hiding this comment

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

Suggested change
However, this behaviour can be changed by using any of the merge modes that do not end with `-uniq`. This will allow more than one parameter sets of (only) the **base generator** to have the same values for the merge keys.
However, this behaviour can be changed by using any of the merge modes that do not end with `-uniq`. Using those, the parameters from a child generator that are used as mergeKeys do no longer have to be unique.

Maybe this is easier to understand regarding the previous comment?

@Boeller666
Copy link

@sonamkshenoy If you would do the signoff for your commits we would be one step further towards getting this cool feature into prod. If you might have problems with signing old commits, you could follow this link

@reedjosh
Copy link

@sonamkshenoy If you would do the signoff for your commits we would be one step further towards getting this cool feature into prod. If you might have problems with signing old commits, you could follow this link

@sonamkshenoy we could really use this feature.

It seems the final commit is signed. Could this be squashed and rebased?

joshfrench added a commit to joshfrench/argo-cd that referenced this pull request Jan 9, 2025
Squashed and rebased version of argoproj#16080
no other changes introduced.

Signed-off-by: Josh French <[email protected]>
@joshfrench
Copy link

I've rebased and squashed this, I'm hoping we can get it into main: #21441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

N:1 left join for Merge generator