Skip to content

fix(ApplicationSet): Check strategy type to verify it's a progressive sync #22563

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

Conversation

fcrespofastly
Copy link
Contributor

@fcrespofastly fcrespofastly commented Apr 3, 2025

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.
  • 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.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

Description

From ArgoCD Progressive-Syncs manual argocd supports two strategies for applicationSets, AllAtOnce or RollingSync. Being AllAtOnce the default when no strategy is selected.

On the other hand, it seems that within the appset controller logic, there's a path in the code: https://github.com/argoproj/argo-cd/blob/master/applicationset/controllers/applicationset_controller.go#L213-L225

Where we do not check exhaustively the strategy type and thus:

strategy:
  type: AllAtOnce

Can cause an infinite reconciliation loop. See:

#14712
#22558

@fcrespofastly fcrespofastly requested a review from a team as a code owner April 3, 2025 21:44
Copy link

bunnyshell bot commented Apr 3, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@rumstead
Copy link
Member

rumstead commented Apr 4, 2025

@fcrespofastly thanks for the PR! some build and linting errors need to be addressed. Additionally, please add some tests, especially one that reproduces the bug.

@jbmothiki
Copy link

Yola

@fcrespofastly
Copy link
Contributor Author

Hey folks! Just a quick not to let you know that I'm still working on it last week with ArgoCon and KubeCon was a bit busy, so didn't have much time to work on this.

Signed-off-by: Fernando Crespo Gravalos <[email protected]>
@fcrespofastly fcrespofastly changed the title Check strategy type to verify it's a progressive sync fix(ApplicationSet): Check strategy type to verify it's a progressive sync Apr 8, 2025
Signed-off-by: Fernando Crespo Gravalos <[email protected]>
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Project coverage is 56.10%. Comparing base (c8c74b5) to head (a4e4b87).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
...cationset/controllers/applicationset_controller.go 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22563      +/-   ##
==========================================
+ Coverage   56.05%   56.10%   +0.04%     
==========================================
  Files         343      343              
  Lines       57547    57551       +4     
==========================================
+ Hits        32259    32288      +29     
+ Misses      22643    22624      -19     
+ Partials     2645     2639       -6     

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

@fcrespofastly
Copy link
Contributor Author

Hey @rumstead 👋🏻

Updated the PR and added some tests. Let me know what you think. Does all of this make sense to you?

@rumstead
Copy link
Member

rumstead commented Apr 8, 2025

Hey @rumstead 👋🏻

Updated the PR and added some tests. Let me know what you think. Does all of this make sense to you?

The code and tests make sense, I think it would be great if we can reproduce the bug via the reconcile loop and have a test that fails before your change and passes after. the current tests pass before and after your change.

@fcrespofastly
Copy link
Contributor Author

fcrespofastly commented Apr 8, 2025

Hey @rumstead 👋🏻
Updated the PR and added some tests. Let me know what you think. Does all of this make sense to you?

The code and tests make sense, I think it would be great if we can reproduce the bug via the reconcile loop and have a test that fails before your change and passes after. the current tests pass before and after your change.

Yeah I've been looking into it as well, it's just going to be tricky. To be clear with my change nothing should fail, it should still reconcile but not in a progressive sync fashion if not explicitly set.

@fcrespofastly
Copy link
Contributor Author

Hey @rumstead !

Sorry for getting back to this late, being a few (good) days off !

Back to you comment I'm not sure how can I provide the tests you're asking. So I do appreciate if you can shed some light 💡

The bug this solves is an infinite reconciliation loop when the strategy type is set to AllAtOnce and no steps, but it does reconcile (nothing really fails, it's just someone could set strategy.type to AllAtOnce. This PR, effectively adds a more strict check, so to skip the progressive sync logic if the strategy type is not set to RollingSync.

Happy to discuss this further.

@rumstead
Copy link
Member

Hey @rumstead !

Sorry for getting back to this late, being a few (good) days off !

Back to you comment I'm not sure how can I provide the tests you're asking. So I do appreciate if you can shed some light 💡

The bug this solves is an infinite reconciliation loop when the strategy type is set to AllAtOnce and no steps, but it does reconcile (nothing really fails, it's just someone could set strategy.type to AllAtOnce. This PR, effectively adds a more strict check, so to skip the progressive sync logic if the strategy type is not set to RollingSync.

Happy to discuss this further.

You can validate that progressive syncs doesn't happen when the AllAtOnce strategy is explicitly set on an applicationset by creating a test using the Reconcile function. You can assert on the values of the ApplicationStatus or even if the performProgressiveSyncs method was called.

@rumstead
Copy link
Member

Hey @rumstead !
Sorry for getting back to this late, being a few (good) days off !
Back to you comment I'm not sure how can I provide the tests you're asking. So I do appreciate if you can shed some light 💡
The bug this solves is an infinite reconciliation loop when the strategy type is set to AllAtOnce and no steps, but it does reconcile (nothing really fails, it's just someone could set strategy.type to AllAtOnce. This PR, effectively adds a more strict check, so to skip the progressive sync logic if the strategy type is not set to RollingSync.
Happy to discuss this further.

You can validate that progressive syncs doesn't happen when the AllAtOnce strategy is explicitly set on an applicationset by creating a test using the Reconcile function. You can assert on the values of the ApplicationStatus or even if the performProgressiveSyncs method was called.

Ok, I was playing around with this today, and it seems too complicated to be worth it. I just have a few nits on comment verbiage, otherwise LGTM.

fcrespofastly and others added 2 commits April 23, 2025 12:38
Add @rumstead suggestion

Co-authored-by: rumstead <[email protected]>
Signed-off-by: Fernando Crespo Grávalos <[email protected]>
@fcrespofastly
Copy link
Contributor Author

Hey @rumstead!

Thanks for the review! much appreciated!

Added your suggestion, not sure if there is anything else you wanted me to tackle/revisit?

@rumstead rumstead merged commit f26b7cd into argoproj:master Apr 23, 2025
27 checks passed
Hapshanko pushed a commit to Hapshanko/argo-cd that referenced this pull request Apr 29, 2025
… sync (argoproj#22563)

Signed-off-by: Fernando Crespo Gravalos <[email protected]>
Signed-off-by: Fernando Crespo Grávalos <[email protected]>
Co-authored-by: rumstead <[email protected]>
Signed-off-by: Hapshanko <[email protected]>
@mubarak-j
Copy link
Contributor

@rumstead is it possible to cherry pick this fix to the current version v2.14?

@rumstead
Copy link
Member

/cherry-pick release-2.14

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Apr 30, 2025
… sync (#22563)

Signed-off-by: Fernando Crespo Gravalos <[email protected]>
Signed-off-by: Fernando Crespo Grávalos <[email protected]>
Co-authored-by: rumstead <[email protected]>
rumstead added a commit that referenced this pull request Apr 30, 2025
… sync (cherry-pick #22563) (#22833)

Signed-off-by: Fernando Crespo Gravalos <[email protected]>
Signed-off-by: Fernando Crespo Grávalos <[email protected]>
Co-authored-by: Fernando Crespo Grávalos <[email protected]>
Co-authored-by: rumstead <[email protected]>
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.

4 participants