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 revision only then fallback to default refspec #5605

Merged
merged 2 commits into from
Jan 28, 2022

Conversation

yujunz
Copy link
Contributor

@yujunz yujunz commented Feb 25, 2021

Fixes #4935

@yujunz
Copy link
Contributor Author

yujunz commented Feb 25, 2021

Error messages

 time="2021-02-25T08:10:01Z" level=info msg=Trace args="[git fetch origin --tags --force]" dir="/tmp/argocd@****" operation_name="exec git" time_ms=9547.973753
 time="2021-02-25T08:10:01Z" level=info msg="git checkout --force 45a223fedbb93eeae70820d534257f90a85f961c" dir="/tmp/argocd@****" execID=QfaG4
 time="2021-02-25T08:10:01Z" level=error msg="`git checkout --force 45a223fedbb93eeae70820d534257f90a85f961c` failed exit status 128: fatal: reference is not a tree: 45a223fedbb93e

@yujunz
Copy link
Contributor Author

yujunz commented Feb 25, 2021

If performance is a concern, we can add an explicit setting for each repository.

@yujunz yujunz marked this pull request as ready for review February 25, 2021 08:58
@yujunz
Copy link
Contributor Author

yujunz commented Mar 3, 2021

Any comments? @alexmt

@codecov
Copy link

codecov bot commented May 23, 2021

Codecov Report

Merging #5605 (79998dc) into master (f387ab8) will decrease coverage by 0.01%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5605      +/-   ##
==========================================
- Coverage   41.93%   41.91%   -0.02%     
==========================================
  Files         176      176              
  Lines       22992    22992              
==========================================
- Hits         9641     9637       -4     
- Misses      11966    11972       +6     
+ Partials     1385     1383       -2     
Impacted Files Coverage Δ
reposerver/repository/repository.go 57.64% <20.00%> (-0.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f387ab8...79998dc. Read the comment docs.

@yujunz yujunz changed the title fix: fallback to fetch default only on error (#5320) fix: fetch revision only then fallback to default refspec May 23, 2021
@alexmt
Copy link
Collaborator

alexmt commented Jan 4, 2022

Sorry, PR slip off radar.

@alexmt alexmt self-requested a review January 4, 2022 02:21
@alexmt alexmt self-assigned this Jan 4, 2022
@snuggie12
Copy link

@alexmt apologies if a faux pas, but do you have an ETA on this one? Just wanted to make sure this didn't fall through the cracks again due to the holidays.

@alexmt alexmt added this to the v2.3 milestone Jan 21, 2022
@yujunz
Copy link
Contributor Author

yujunz commented Jan 24, 2022

Flake? The failure seems not related to the change.

2022-01-24T03:00:04.1594119Z time="2022-01-24T03:00:04Z" level=debug msg="Application 'test-hook-before-hook-creation-failure' operation terminating\n" duration=204.602806ms execID=47273
2022-01-24T03:00:04.1595605Z time="2022-01-24T03:00:04Z" level=info msg="expectation succeeded: no error and output contained ''"
2022-01-24T03:00:04.1659029Z time="2022-01-24T03:00:04Z" level=info msg="pending: operation phase should be Failed, is Running"
2022-01-24T03:00:07.1712699Z time="2022-01-24T03:00:07Z" level=info msg="pending: operation phase should be Failed, is Succeeded"
2022-01-24T03:00:10.1777595Z time="2022-01-24T03:00:10Z" level=info msg="pending: operation phase should be Failed, is Succeeded"
2022-01-24T03:00:13.1833939Z time="2022-01-24T03:00:13Z" level=info msg="pending: operation phase should be Failed, is Succeeded"
2022-01-24T03:00:16.1909338Z time="2022-01-24T03:00:16Z" level=info msg="pending: operation phase should be Failed, is Succeeded"
2022-01-24T03:00:19.1918959Z ##[error]    hook_test.go:351: timeout waiting for: operation phase should be Failed, is Succeeded
2022-01-24T03:00:19.1920454Z --- FAIL: TestHookBeforeHookCreationFailure (18.96s)
2022-01-24T03:00:19.1920913Z FAIL
2022-01-24T03:00:19.1983630Z FAIL	github.com/argoproj/argo-cd/v2/test/e2e	651.703s
2022-01-24T03:00:19.2048239Z FAIL

@yujunz
Copy link
Contributor Author

yujunz commented Jan 25, 2022

Failed on the same case

Error:     hook_test.go:351: timeout waiting for: operation phase should be Failed, is Succeeded
--- FAIL: TestHookBeforeHookCreationFailure (18.93s)
FAIL
FAIL	github.com/argoproj/argo-cd/v2/test/e2e	643.169s
FAIL

Is the master branch broken?

err = gitClient.Fetch(revision)

if err != nil {
log.Warnf("Failed to fetch revision %s: %v", revision, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change it to log.Info. We are trying to use 'warning' logs only for something that the operator should act on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -335,7 +335,7 @@ func (m *nativeGitClient) Fetch(revision string) error {

var err error
if revision != "" {
err = m.runCredentialedCmd("git", "fetch", "origin", revision, "--tags", "--force")
err = m.runCredentialedCmd("git", "fetch", "origin", revision)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please clarify why this change is necessary? Can we rollback this line please unless it is really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to fetch tags on explicit revision. This reduce a bit the pack size on large repository with many tags.

Feel free to revert the change though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good. Reverted this change. The rest looks good! Merging once CI is green.

Ignoring commit SHA breaks gerrit when the commit is not merged

Signed-off-by: Yujun Zhang <yujunz@nvidia.com>
Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
@alexmt alexmt merged commit 4aa614d into argoproj:master Jan 28, 2022
pasha-codefresh pushed a commit to pasha-codefresh/argo-cd that referenced this pull request Feb 2, 2022
)

* fix: fallback to fetch default only on error

Ignoring commit SHA breaks gerrit when the commit is not merged

Signed-off-by: Yujun Zhang <yujunz@nvidia.com>

* revert util/git/client.go changes

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

Co-authored-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Signed-off-by: pashavictorovich <pavel@codefresh.io>
@yujunz yujunz deleted the fix-fetch branch February 4, 2022 09:17
@crenshaw-dev
Copy link
Member

If performance is a concern, we can add an explicit setting for each repository.

@yujunz can you expand on this? I'm observing performance issues (lots of large packfiles) for some repos. But I don't know enough about git to understand why this happens.

@yujunz
Copy link
Contributor Author

yujunz commented Mar 25, 2022

Not sure what kind of pack files from your repository. This patch mainly reduces the total refs to fetch. It is not helping when the repository has many large files or long commit history.

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.

Allow referring to non-default remote references
4 participants