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 more than two child generators for matrix generator #14189

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

Conversation

huynhsontung
Copy link

@huynhsontung huynhsontung commented Jun 23, 2023

Closes #14182

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

Please see Contribution FAQs if you have questions about your pull-request.

@crenshaw-dev
Copy link
Member

I feel like we should have a controller-level configurable max for number of children in a matrix generator. We're close to having ApplicationSets manageable by non-admins, and it would be good to have a way for admins to mitigate denial of service via bonkers-level matrix generators.

@huynhsontung huynhsontung changed the title Support more than two child generators for matrix generator feat: Support more than two child generators for matrix generator Jun 23, 2023
@huynhsontung huynhsontung changed the title feat: Support more than two child generators for matrix generator feat(appset): Support more than two child generators for matrix generator Jun 23, 2023
@codecov
Copy link

codecov bot commented Jun 23, 2023

Codecov Report

Attention: Patch coverage is 86.04651% with 6 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@40c6077). Learn more about missing BASE report.
Report is 318 commits behind head on master.

Files with missing lines Patch % Lines
applicationset/generators/matrix.go 82.35% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #14189   +/-   ##
=========================================
  Coverage          ?   55.80%           
=========================================
  Files             ?      320           
  Lines             ?    44411           
  Branches          ?        0           
=========================================
  Hits              ?    24782           
  Misses            ?    17066           
  Partials          ?     2563           

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

@huynhsontung
Copy link
Author

huynhsontung commented Jun 23, 2023

@crenshaw-dev Sounds reasonable. There is no precedent for generator configuration at the controller level. How about a controller flag called max-matrix-children with the default of 0 for an unlimited number of children? Unless we want it configurable on the fly through a ConfigMap.

@crenshaw-dev
Copy link
Member

I'm wavering between default of 2 (no change of behavior for people upgrading) and default of 0. I think default 2 makes sense if we want people to be able to provide users create/update privileges on appsets as soon as we button down the remaining admin-only features.

We could make it a controller flag/env var and let users set it via argocd-cmd-params-cm.

@huynhsontung
Copy link
Author

huynhsontung commented Jun 24, 2023

Do we allow a value of 1? The code does handle this case but intuitively it doesn't really make sense. If not, any value less than 2 will be parsed as unlimited.

Edit: There is already an error when using a matrix generator with only 1 child. Any value less than 2 will be unlimited then.

@huynhsontung
Copy link
Author

@crenshaw-dev I have made the max matrix children configurable through NewMatrixGenerator() with the default value of 2. Let me know if there is anything that needs changing before I move on to updating the docs.

@crenshaw-dev
Copy link
Member

Sounds reasonable! I'd say carry on with docs.

@huynhsontung huynhsontung marked this pull request as ready for review July 1, 2023 19:16
@huynhsontung
Copy link
Author

@crenshaw-dev I updated the manifest to allow setting the limit in the config map and updated the docs.

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Thanks for your patience on the review! Small things. Targeting this for 2.9.

applicationset/generators/matrix.go Outdated Show resolved Hide resolved
applicationset/generators/matrix.go Outdated Show resolved Hide resolved
@huynhsontung
Copy link
Author

I had to change those messages a bit to also reflect #14573

@huynhsontung
Copy link
Author

@crenshaw-dev Are there any updates on this PR? I can resolve the merge conflicts if it's ready to merge.

Copy link
Member

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

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

One minor comment. Overall code LGTM!!

return nil, ErrLessThanTwoGenerators
}

if len(appSetGenerator.Matrix.Generators) > 2 {
return nil, ErrMoreThanTwoGenerators
if m.maxChildren > 1 && numGens > m.maxChildren {
Copy link
Member

Choose a reason for hiding this comment

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

It might be useful to log a separate configuration error if value of maxChildren is 1 or less.

Copy link
Author

Choose a reason for hiding this comment

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

When maxChildren is 1 or less, it's considered no limit. The default value for maxChildren is 2.

Copy link
Member

@blakepettersson blakepettersson Jun 5, 2024

Choose a reason for hiding this comment

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

Not a showstopper but that sounds un-intuitive IMO - could we not say that no limit only applies if maxChildren < 0?

Copy link
Author

@huynhsontung huynhsontung Jun 5, 2024

Choose a reason for hiding this comment

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

I would prefer to have maxChildren < 1 to avoid using negative values. The param reposerver.git.lsremote.parallelism.limit has the same logic where any values less than 1 mean unlimited.

plus we don't have to update the docs and tests this way

@huynhsontung huynhsontung requested a review from a team as a code owner December 16, 2023 06:15
@jdeus
Copy link

jdeus commented Mar 18, 2024

What's the ETA on this ?

@ptr1120
Copy link

ptr1120 commented Mar 27, 2024

Hello, can we still expect that this support of >2 matrix steps will be reviewed and merged as stated in the roadmap. Since I am having a need for 3 steps and the parameter transfer between nested matrix steps has issues, I am still searching for any solution.

@sathieu
Copy link
Contributor

sathieu commented May 16, 2024

@crenshaw-dev I have made the max matrix children configurable through NewMatrixGenerator() with the default value of 2. Let me know if there is anything that needs changing before I move on to updating the docs.

Can this default be changed to a higher value? Maybe 100 or 10?

@jdeus
Copy link

jdeus commented May 16, 2024

So are we waiting another year here ?

@huynhsontung
Copy link
Author

Can this default be changed to a higher value? Maybe 100 or 10?

@sathieu I chose this default value of 2 to mirror the same limit of the current version of the matrix generator. I'm fine with having a higher value or even unlimited as a default.

@mihaigalos
Copy link

Would this not be easier solved using a Plugin Generator?
One can then programatically compose the generators the way they're required.

Copy link
Member

@blakepettersson blakepettersson left a comment

Choose a reason for hiding this comment

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

Minor comment, but otherwise LGTM

@blakepettersson
Copy link
Member

@crenshaw-dev do you still have concerns about this PR?

@crenshaw-dev
Copy link
Member

Dismissing my review as stale, since I don't have time to re-review right now. At a glance, no major concerns.

@steve-todorov
Copy link

@crenshaw-dev any updates on merging and releasing this feature?

@it2008018
Copy link

Is there any chance of merging this PR? we are looking for this feature to be available asap.

@blakepettersson
Copy link
Member

@it2008018 for that to happen, the merge conflicts need to be fixed from @huynhsontung.

Once that happens, we can push for someone to review and merge it.

Even if this gets merged tomorrow, this would not be "available asap" since this would come into 2.14, which is slated for next February.

@it2008018
Copy link

it2008018 commented Sep 20, 2024

@blakepettersson will look forward for it to be merged :) @huynhsontung will it be possible for you to resolve conflicts?

@blakepettersson
Copy link
Member

@huynhsontung if you do not have time to work on it, I can take on the mantle and get the necessary reviews for it to be merged.

Comment on lines -277 to +278
appSetGenerators := generators.GetGenerators(ctx, s.client, s.k8sClient, namespace, argoCDService, s.dynamicClient, scmConfig)
appSetGenerators := generators.GetGenerators(ctx, s.client, s.k8sClient, namespace, argoCDService, s.dynamicClient, scmConfig, matrixConfig)
Copy link
Author

@huynhsontung huynhsontung Sep 21, 2024

Choose a reason for hiding this comment

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

I don't know how to get the config in this case. This method is used in argocd appset create --dry-run and argocd appset generate. I think not setting a limit here makes sense.

@huynhsontung
Copy link
Author

@blakepettersson I have resolved all the conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review (Due by 2023-3-20)
Development

Successfully merging this pull request may close these issues.

Matrix generator should accept more than two child generators