-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/go: retry failed fetches #28194
Comments
|
@gopherbot, please add label modules |
感觉是并行下载外加网速不好导致的. |
Please write in English. |
In any case, this is indeed a network issue. I was able to reproduce this once out of 3 tries by just running the plain git command (git fetch -f https://code.googlesource.com/google-api-go-client ).
```
$git fetch -f https://code.googlesource.com/google-api-go-client
remote: Sending approximately 87.36 MiB ...
remote: Counting objects: 45, done
remote: Finding sources: 100% (71244/71244)
error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
14:13:31-agniva-~/play/gg$rm -rf .git/
14:13:48-agniva-~/play/gg$git init
Initialized empty Git repository in /home/agniva/play/gg/.git/
14:13:53-agniva-~/play/gg$git fetch -f https://code.googlesource.com/google-api-go-client
remote: Sending approximately 87.36 MiB ...
remote: Counting objects: 45, done
remote: Finding sources: 100% (71244/71244)
remote: Total 71244 (delta 44173), reused 71141 (delta 44173)
Receiving objects: 100% (71244/71244), 86.49 MiB | 999.00 KiB/s, done.
Resolving deltas: 100% (44173/44173), done.
From https://code.googlesource.com/google-api-go-client
* branch HEAD -> FETCH_HEAD
14:15:46-agniva-~/play/gg$rm -rf .git/
14:15:51-agniva-~/play/gg$git init
Initialized empty Git repository in /home/agniva/play/gg/.git/
14:15:52-agniva-~/play/gg$git fetch -f https://code.googlesource.com/google-api-go-client
remote: Sending approximately 87.36 MiB ...
remote: Counting objects: 45, done
remote: Finding sources: 100% (71244/71244)
remote: Total 71244 (delta 44173), reused 71141 (delta 44173)
Receiving objects: 100% (71244/71244), 86.49 MiB | 1.10 MiB/s, done.
Resolving deltas: 100% (44173/44173), done.
From https://code.googlesource.com/google-api-go-client
* branch HEAD -> FETCH_HEAD
```
@chai2010 - Could you run the git command manually as shown above and see if you get any error ? If yes, then it's a network issue. If not, then try to run |
I have the same issue:
I have modified the git buffer:
|
@mvdan Is there any solutions, such as copy the git repository directly to the mod directory? |
@northfun, this issue is about retrying past temporary failures, not permanent ones. If you are unable to download from some origin in general, you may need to set up a proxy for that module. (See https://tip.golang.org/cmd/go/#hdr-Module_proxy_protocol.) |
@bcmills ,thanks for your advice~ |
@northfun would you mind sharing a bit more information on what you did? I'm also hitting this same issue |
It's unclear how to decide what is worth retrying and what is not, especially as it interacts with GOPROXY list fallback as well as executing VCS commands (the example above is git itself failing). Let's at least move this off to Go 1.14. It may be that there's nothing to do anyway, but certainly not for Go 1.13. |
go: finding github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72
go: golang.org/x/[email protected]: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/b44680b3c3708a854d4c89f55aedda0b223beb8d9e30fba969cefb5bd9c1e843: exit status 128:
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
go: golang.org/x/[email protected]: unknown revision 11955173bddd
go: golang.org/x/[email protected]: unknown revision 07fd8470d635
go: golang.org/x/[email protected]: unknown revision bf090417da8b
go: golang.org/x/[email protected]: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/5b03666c2d7b526129bad48c5cea095aad8b83badc1daa202e7b0279e3a5d861: exit status 128:
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
go: error loading module requirements for me it was a kind of same problem; using |
Similar issue here, but solved using btw, this is my
|
Would |
This is still a problem in 2022, would it be possible to prioritize this body of work? Retrying module fetches would solve ~6% of our CI failures which is a very large number of jobs for us. |
In full 2022, year of the world cup, and go mod download does not have retry :(. My company's CI/CD suffers a lot from the lack of repetition. Several dependencies are hosted on unstable servers. When building the program or running the tests, there is instability on the server and the dependency cannot be downloaded and the pipeline breaks. If the "go mod download" had retries, it would solve our problem. |
At Uber, we do two things to workaround this issue:
|
@eduardo-mior similar to @linzhp we at FullStory also use a module cache directory that we pre-populate in our CI jobs. You can build a retry loop in your flavor of shell (e.g. https://unix.stackexchange.com/a/82610) and wrap |
@linzhp Your idea with GOPROXY is really good, but it doesn't work for private modules :( @thempatel It seems to be a good idea, I had already tried retries with the SSH command and with the GIT command, but I had not thought about it with the GO MOD DOWNLOAD command. I will try, thanks. |
@thempatel Thanks for the idea. I created this script that uses as a base go mod download to download the dependency and if it fails try again. The script tries to download the dependency 5 times with an interval of 20 seconds. #!/bin/bash
go mod download $@;
status=$?;
attempt=1;
while [ $status -ne 0 ] && [ $attempt -le 5 ]; do
sleep 20;
(( attempt++ ));
go mod download $@;
status=$?;
done; |
Temporary solution until golang/go#28194 is fixed in order to retry failed fetch requests.
Temporary solution until golang/go#28194 is fixed in order to retry failed fetch requests.
Temporary solution until golang/go#28194 is fixed in order to retry failed fetch requests.
Temporary solution until golang/go#28194 is fixed in order to retry failed fetch requests.
The text was updated successfully, but these errors were encountered: