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

fix: manifest-generate-paths with autosync causes an undesirable refresh sync #19799

Merged

Conversation

pasha-codefresh
Copy link
Member

@pasha-codefresh pasha-codefresh commented Sep 5, 2024

Closes: #18326

alreadyAttemptedSync is deciding if self heal should happens or no, and today we just have check app.Status.OperationState.SyncResult.Revision != commitSHA which is not enough, because in monorepo these two revisions can be different.

So i have added additional check, which verify if change actually happened in git for current application or no, and if revisions are different but no changes in git for app, self heal will not be executed

Also i am passing resolved revision from UpdateRevisionForPaths response, because if GenerateManifest will accept revision[i] that in most cases HEAD, resolved revision in UpdateRevisionForPaths and GenerateManifest can be different if commit happens between function execution.

@pasha-codefresh pasha-codefresh requested a review from a team as a code owner September 5, 2024 13:37
Copy link

bunnyshell bot commented Sep 5, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Copy link

bunnyshell bot commented Sep 5, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@pasha-codefresh
Copy link
Member Author

@agaudreault Could you please take a look?

Signed-off-by: pashakostohrys <[email protected]>
@todaywasawesome
Copy link
Contributor

This is a big improvement for monorepos with a lot of activity. Well done!

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.

Thanks @pasha-codefresh for tackling this. The changes looks good to me 🚀

Copy link

@taemery taemery left a comment

Choose a reason for hiding this comment

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

Great win for monorepos!

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.

Waiting for answer because I have trouble understanding the logic if the boolean is always true.

Comment on lines 186 to 187
// by default should be for regular sync, if application has no AnnotationKeyManifestGeneratePaths , it should work as before
revisionUpdated := true
Copy link
Member

Choose a reason for hiding this comment

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

After this point, nothing is setting the boolean back to false 🤔 so it always returns true, except during error. It looks like this return variable is not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, i changed default to true, because it always returned false before for apps that has no AnnotationKeyManifestGeneratePaths annotation. I am reverting it back

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.

LGTM. Default behavior (when there is no annotation set) is to always return true.
When annotations is set, returns true if at least one revision changed relevant files.

Result: Will not perform an initial "selfHeal" on non-relevant commits the first time drift are detected.

Important note: When annotation is not set, even with selfHeal=false, it will always trigger a sync once, the first time drift are detected (if AutoSync=true). If the commit that was made did not cause an outOfSync (e.g. updating a README file), this will be delayed until the first time the app goes OutOfSync (can be caused by cluster changes which will "selfHeal" even if selfHeal=false). So this is fixing the behavior only when annotation is set.

Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 64.61538% with 23 lines in your changes missing coverage. Please review.

Project coverage is 55.82%. Comparing base (3d66b05) to head (842a62e).
Report is 459 commits behind head on master.

Files with missing lines Patch % Lines
controller/state.go 48.57% 16 Missing and 2 partials ⚠️
reposerver/repository/repository.go 78.57% 3 Missing ⚠️
controller/appcontroller.go 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19799      +/-   ##
==========================================
+ Coverage   55.79%   55.82%   +0.02%     
==========================================
  Files         320      320              
  Lines       44223    44250      +27     
==========================================
+ Hits        24675    24703      +28     
- Misses      16995    16996       +1     
+ Partials     2553     2551       -2     

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

@pasha-codefresh
Copy link
Member Author

LGTM. Default behavior (when there is no annotation set) is to always return true. When annotations is set, returns true if at least one revision changed relevant files.

Result: Will not perform an initial "selfHeal" on non-relevant commits the first time drift are detected.

Important note: When annotation is not set, even with selfHeal=false, it will always trigger a sync once, the first time drift are detected (if AutoSync=true). If the commit that was made did not cause an outOfSync (e.g. updating a README file), this will be delayed until the first time the app goes OutOfSync (can be caused by cluster changes which will "selfHeal" even if selfHeal=false). So this is fixing the behavior only when annotation is set.

Yes! thank you! we will cover it with documentation on Monday

@agaudreault agaudreault merged commit 4736657 into argoproj:master Sep 6, 2024
27 of 28 checks passed
@pasha-codefresh
Copy link
Member Author

Thank you for everyone to review. I also going to open PR that will cover argocd.argoproj.io/manifest-generate-paths with e2e

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.

manifest-generate-paths with autosync causes an undesirable refresh sync
6 participants