fetch: honor HTTP_PROXY and tighten failure modes#27
Merged
Conversation
- Set Transport.Proxy to http.ProxyFromEnvironment so HTTP_PROXY, HTTPS_PROXY and NO_PROXY env vars are honored on artifact downloads. Without this, the custom http.Transport silently ignored proxy env vars while the metadata client (using http.DefaultTransport) honored them, causing artifact downloads to hang behind corporate proxies. - Wrap the last underlying dial error instead of returning an opaque "failed to dial any resolved IP" message. - Add a 60s ResponseHeaderTimeout so hung upstreams fail fast rather than waiting the full 5 minute client timeout. - Make the DNS refresh goroutine stoppable via a new Fetcher.Close method to avoid leaking a goroutine per Fetcher.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The custom
http.Transportinfetch.NewFetcherwas constructed withoutProxy: http.ProxyFromEnvironment, so it silently ignoredHTTP_PROXY,HTTPS_PROXYandNO_PROXY. The metadata client inclient/client.gouseshttp.DefaultTransportso metadata requests were unaffected, but every ecosystem's artifact download path runs through this Fetcher and would hang behind corporate proxies until the 5 minute client timeout. Reported ingit-pkgs/proxy#118for PyPI; the same bug affected all ecosystems.This PR also tightens a few other things in the same client:
failed to dial any resolved IP, so future network failures self-diagnose.ResponseHeaderTimeoutso an upstream that accepts the TCP connection but never replies fails in 60s instead of 5min.Fetcher.Closeso the DNS refresh goroutine can be stopped. Previously eachNewFetcherleaked one goroutine for the process lifetime.