Add HTTP timeout and retry on TCP connection reset #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PRs tries to address 2 issues
We use Go's default value for the
Timeout
field in our HTTP clients, which is 0. That value actually means that no timeout at all is applied, potentially leading to HTTP calls hanging indefinitely.An optional field is added to the .yml configuration, so that users can individually define a custom timeout (in minutes).
If no timeout value is provided, the default is to apply a 60 min timeout to each HTTP call (this includes also the time it takes to read the response body).
Users can still define a timeout of 0 if they intend to have no timeout on their calls.
Currently, we repeat the sync for a repository up to 20 times when there are errors downloading packages.
The event of a TCP connection being reset was not handled in this loop, leading to an immediate failure for the given repository.
The configuration parsing function and Config structs are also moved to the root command file.