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: fetch syncedRevision in UpdateRevisionForPaths (#21014) #21015

Merged
merged 12 commits into from
Feb 25, 2025

Conversation

toyamagu-2021
Copy link
Member

@toyamagu-2021 toyamagu-2021 commented Dec 1, 2024

Signed-off-by: toyamagu2021 toyamagu2021@gmail.com

Closes #21014

Check if syncedRevision exists in a local git repo.
Can be cherry-picked into v2.12 and v2.13.

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).

Copy link

bunnyshell bot commented Dec 1, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@toyamagu-2021 toyamagu-2021 changed the title fix: check syncRevisionCache in UpdateRevisionForPaths fix: check syncRevisionCache in UpdateRevisionForPaths (#21014) Dec 1, 2024
Copy link

codecov bot commented Dec 1, 2024

Codecov Report

Attention: Patch coverage is 70.58824% with 10 lines in your changes missing coverage. Please review.

Project coverage is 55.62%. Comparing base (d183d9c) to head (70e550d).
Report is 54 commits behind head on master.

Files with missing lines Patch % Lines
reposerver/repository/repository.go 70.58% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21015      +/-   ##
==========================================
+ Coverage   55.58%   55.62%   +0.03%     
==========================================
  Files         339      339              
  Lines       56874    56908      +34     
==========================================
+ Hits        31616    31653      +37     
+ Misses      22609    22605       -4     
- Partials     2649     2650       +1     

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

@toyamagu-2021 toyamagu-2021 marked this pull request as ready for review December 1, 2024 17:40
@toyamagu-2021 toyamagu-2021 requested a review from a team as a code owner December 1, 2024 17:40
@toyamagu-2021 toyamagu-2021 changed the title fix: check syncRevisionCache in UpdateRevisionForPaths (#21014) fix: check syncedRevision in UpdateRevisionForPaths (#21014) Dec 1, 2024
@@ -2851,6 +2884,10 @@ func (s *Service) UpdateRevisionForPaths(_ context.Context, request *apiclient.U
}
defer io.Close(closer)

if err := s.fetch(gitClient, []string{syncedRevision, revision}); err != nil {
return nil, status.Errorf(codes.Internal, "unable to fetch git repo %s with revisions (%s, %s): %v", repo.Repo, syncedRevision, revision, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How would locking above work with both revisions being used here? Can we lock for multiple revisions?

Copy link
Member Author

@toyamagu-2021 toyamagu-2021 Dec 2, 2024

Choose a reason for hiding this comment

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

Should we take a lock to fetch from the remote? If we checkout we need to take a lock, but for fetch I think we don't need to lock.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know

@@ -2851,6 +2895,10 @@ func (s *Service) UpdateRevisionForPaths(_ context.Context, request *apiclient.U
}
defer io.Close(closer)

if err := s.fetch(gitClient, []string{syncedRevision}); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We lock on revision above, but use syncedRevision here. Should it be consistent?

Copy link
Member Author

Choose a reason for hiding this comment

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

To exec git diff syncRevision..targetRevision we only need to fetch from remote, so I think we needn't take a lock.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Maybe we can release the lock earlier then.

@toyamagu-2021 toyamagu-2021 changed the title fix: check syncedRevision in UpdateRevisionForPaths (#21014) fix: fetch syncedRevision in UpdateRevisionForPaths (#21014) Dec 2, 2024
return err
}

func fetch(gitClient git.Client, targetRevisions []string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func fetch(gitClient git.Client, targetRevisions []string) error {
func fetchRevision(gitClient git.Client, targetRevisions []string) error {

Is there a specific reason behind using the same func name as fetch? If not, we can probably change the func name to avoid confusion.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not being particular, but it is the same naming convention as checkoutRevision.

https://github.com/toyamagu-2021/argo-cd/blob/514df2c77c58c8bc5f4da1000e09af0e8e4fb552/reposerver/repository/repository.go#L2554

Copy link
Member

@nitishfy nitishfy left a comment

Choose a reason for hiding this comment

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

PTAL

Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
@yash-asana
Copy link

@toyamagu-2021 Are you still working on this PR?

Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Copy link
Member

@gdsoumya gdsoumya left a comment

Choose a reason for hiding this comment

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

LGTM

@gdsoumya gdsoumya merged commit 49a4b7f into argoproj:master Feb 25, 2025
27 checks passed
@gdsoumya
Copy link
Member

/cherry-pick release-2.14

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Feb 25, 2025
Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
gdsoumya pushed a commit that referenced this pull request Feb 26, 2025
…pick #21015) (#22011)

Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Co-authored-by: gussan <83329336+toyamagu-2021@users.noreply.github.com>
kingbj940429 pushed a commit to kingbj940429/argo-cd that referenced this pull request Feb 26, 2025
…rgoproj#21015)

Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: kingbj0429 <kingbj0429@lunit.io>
chzar pushed a commit to chzar/argo-cd that referenced this pull request Mar 3, 2025
…rgoproj#21015)

Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
kingbj940429 pushed a commit to kingbj940429/argo-cd that referenced this pull request Mar 4, 2025
…rgoproj#21015)

Signed-off-by: toyamagu2021 <toyamagu2021@gmail.com>
Signed-off-by: toyamagu-2021 <toyamagu2021@gmail.com>
Signed-off-by: kingbj0429 <kingbj0429@lunit.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
6 participants