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(repo-server): excess git requests, resolveReferencedSources and runManifestGenAsync not using cache (Issue #14725) #16410

Merged
merged 2 commits into from
Nov 30, 2023

Conversation

nromriell
Copy link
Contributor

@nromriell nromriell commented Nov 21, 2023

Partially Fixes #14725

First part of a split of the initial PR. Starts the fixes required to remove the excess git requests when using multi-source and ref sources.

Issue:
When resolveReferencedSources and runManifestGenAsync call newClientResolveRevision they currently do not pass the git options to use the cache when enabled, because of this when newClientResolveRevision creates a new git client and calls LsRemote the cache is always skipped

Changes:
Updated the ls-remote calls from resolveReferencedSources and runManifestGenAsync to have access to the cache

Impact:
On its own this does not fix the issue. This will reduce the number of ls-remote currently being made by preventing multiple calls inside the same goroutine or slightly time offset calls from missing cache, however due to the fact that a large number of calls are made by nearly simultaneous processes when the cache expires this is only a partial fix.

This also does not fix the large number of fetch calls being made to ref-only repos.

These two remaining items will be addressed in follow PRs

Baseline v2.9.0 with 200 multi-source applications with a ref only source:
Screenshot from 2023-11-18 18-24-30

With the changes in this PR under the same conditions:
Screenshot from 2023-11-21 00-43-54

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.

@nromriell nromriell requested a review from a team as a code owner November 21, 2023 08:45
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (819f0b3) 49.53% compared to head (131ce0c) 49.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #16410      +/-   ##
==========================================
+ Coverage   49.53%   49.56%   +0.02%     
==========================================
  Files         269      269              
  Lines       47222    47223       +1     
==========================================
+ Hits        23392    23405      +13     
+ Misses      21530    21517      -13     
- Partials     2300     2301       +1     

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

@crenshaw-dev
Copy link
Member

Nice, looks like this massively mitigates the issue with a relatively lightweight change. Very safe and easy to cherry-pick back. Thanks for splitting up the PRs!

…s and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>
@nromriell
Copy link
Contributor Author

Nice, looks like this massively mitigates the issue with a relatively lightweight change. Very safe and easy to cherry-pick back. Thanks for splitting up the PRs!

Of course! Definitely was a great idea to split them, much easier to follow the changes

Signed-off-by: nromriell <nateromriell@gmail.com>
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 @nromriell for breaking the huge PR into smaller chunks. The change is really effective.

The code looks good to me overall.

@nromriell
Copy link
Contributor Author

Thanks @nromriell for breaking the huge PR into smaller chunks. The change is really effective.

The code looks good to me overall.

Of course, thanks for taking the time to review!

Copy link
Collaborator

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

Tks a lot for breaking the original PR.
Please check my comment.

@@ -300,6 +300,7 @@ func (s *Service) runRepoOperation(
var gitClient git.Client
var helmClient helm.Client
var err error
gitClientOpts := git.WithCache(s.cache, !settings.noRevisionCache && !settings.noCache)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that the repository.Service.cache is just Redis based and doesn't leverage the twolevel cache client. Can you please confirm my understanding of this part of the code? If so, it means that we are moving the chatty communication from Git to Redis which can bring new problems.

I don't want to push for a premature optimization as long as we are aware of this possible behaviour and have a plan B if we want to go with this implementation which I am not opposed to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right, overall redis requests are down after the change due to not having to try and get and set the values for each application each time.

I do however have the optimization for moving this to a two level cache as part of the original PR and in the final part of the PR split nromriell#3

Copy link
Collaborator

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

LGTM
Awesome job @nromriell !

@leoluz leoluz merged commit 5c187a1 into argoproj:master Nov 30, 2023
25 checks passed
@crenshaw-dev
Copy link
Member

/cherry-pick release-2.9

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Nov 30, 2023
…unManifestGenAsync not using cache (Issue #14725) (#16410)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>

* fix: remove unnecessary settings instantiation

Signed-off-by: nromriell <nateromriell@gmail.com>

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
crenshaw-dev pushed a commit that referenced this pull request Nov 30, 2023
…unManifestGenAsync not using cache (Issue #14725) (#16410) (#16494)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync



* fix: remove unnecessary settings instantiation



---------

Signed-off-by: nromriell <nateromriell@gmail.com>
Co-authored-by: Nathan Romriell <nateromriell@gmail.com>
irinam0992 pushed a commit to irinam0992/argo-cd that referenced this pull request Nov 30, 2023
…unManifestGenAsync not using cache (Issue argoproj#14725) (argoproj#16410)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>

* fix: remove unnecessary settings instantiation

Signed-off-by: nromriell <nateromriell@gmail.com>

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
Signed-off-by: irinam0992 <irinam0992@gmail.com>
@nromriell
Copy link
Contributor Author

Thanks @crenshaw-dev @ishitasequeira @leoluz for taking the time to review!

vladfr pushed a commit to vladfr/argo-cd that referenced this pull request Dec 13, 2023
…unManifestGenAsync not using cache (Issue argoproj#14725) (argoproj#16410)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>

* fix: remove unnecessary settings instantiation

Signed-off-by: nromriell <nateromriell@gmail.com>

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
tesla59 pushed a commit to tesla59/argo-cd that referenced this pull request Dec 16, 2023
…unManifestGenAsync not using cache (Issue argoproj#14725) (argoproj#16410)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>

* fix: remove unnecessary settings instantiation

Signed-off-by: nromriell <nateromriell@gmail.com>

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
JulienFuix pushed a commit to JulienFuix/argo-cd that referenced this pull request Feb 6, 2024
…unManifestGenAsync not using cache (Issue argoproj#14725) (argoproj#16410)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>

* fix: remove unnecessary settings instantiation

Signed-off-by: nromriell <nateromriell@gmail.com>

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
lyda pushed a commit to lyda/argo-cd that referenced this pull request Mar 28, 2024
…unManifestGenAsync not using cache (Issue argoproj#14725) (argoproj#16410)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>

* fix: remove unnecessary settings instantiation

Signed-off-by: nromriell <nateromriell@gmail.com>

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
Signed-off-by: Kevin Lyda <kevin@lyda.ie>
Hariharasuthan99 pushed a commit to AmadeusITGroup/argo-cd that referenced this pull request Jun 16, 2024
…unManifestGenAsync not using cache (Issue argoproj#14725) (argoproj#16410)

* fix(repo-server): excess git requests part 1, resolveReferencedSources and runManifestGenAsync

Signed-off-by: nromriell <nateromriell@gmail.com>

* fix: remove unnecessary settings instantiation

Signed-off-by: nromriell <nateromriell@gmail.com>

---------

Signed-off-by: nromriell <nateromriell@gmail.com>
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.

Excessive requests to git repository on commit to monorepo w/ multi-source apps
4 participants