This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a context.WithTimeout for running
git ls-remote
There are cases that can result in `dep` trying to use `git ls-remote` to talk to a mercurial repository, which can have some really adverse effects due to poor connection handling characteristics of `git ls-remote`. This tries to improve that situation with a timeout. If the git command cannot connect to the remote SCM, it takes 2 minutes for the connection to time out if it's unable to establish the TCP connection. It then tries the next IP, which will also take 2 minutes to time out, and so on and so forth. If `dep` hands `git ls-remote` a Bitbucket repository that's `hg` backed, `git ls-remote` fails to establish the connection and retries all IPs until finally failing. If there are 6 IPs returned, this will take 12 minutes. If you're running a `dep` ensure that's trying to do a lot of different actions, this can add up very quickly. Looking in to the `git ls-remote` manpage there does not seem to be a straightforward way to configure it to fail a bit more aggressively (such as after 2 failed attempts with a 15 second timeout). This change wraps calls to `git ls-remote` in a `context.WithTimeout` that gives it 30 seconds to run. This is a completely arbitrary value and may need tuning, or even to become configurable. Updates #2092
- Loading branch information