-
Notifications
You must be signed in to change notification settings - Fork 395
Make HTTP client configurable #537
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
Conversation
d88d09e to
4587128
Compare
Add `HTTPClient` field into `types.SystemContext` to configure http client by caller. If the `HTTPClient` filed is set, cert configurations are ignored in `types.SystemContext` on fetching images.
4587128 to
784e349
Compare
|
@vrothberg PTAL |
|
Thanks for the PR. It's an interesting idea to move that into the API! We have a highly related discussion over at containers/buildah. I think we can extend the ideas over there to fit your needs in the API as well. However, we need to be careful to not introduce too many ways of configuring proxies. @ueokande could you have a look at the linked issue and share your thoughts there? |
|
@vrothberg In our scenario, updater tools deployed in the data-center fetches newer container image via HTTP proxy. We currently use |
vrothberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| // newHTTPClient returns new http client for docker client. It returns HTTPClient in SystemContext if set, | ||
| // otherwise returns default client. | ||
| func newHTTPClient(sys *types.SystemContext, registry, hostName, reference string) (*http.Client, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we document the arguments as for newDockerClient?
|
I don’t really like this… in the sense that the vast majority of clients should not need to care at this low level (notably we definitely don’t want If a typical client of c/image needed to set its own Of course, that does not automatically mean that there can’t be exceptional clients that would benefit from this capability — but once we add this option, we will lose the feedback channel because callers who find c/image insufficient can just use its own In this case, wouldn’t it be enough to add a
is true as well. I’m honestly unsure. |
mtrmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just noting smaller issues I have noticed, this does not automatically mean that overall I think this should be merged.)
| var httpClient *http.Client | ||
| if url.Scheme != "unix" { | ||
| if url.Scheme == "http" { | ||
| if sys.HTTPClient != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sys == nil is always valid, and must be treated the same as &types.SystemContext{}.
| DirForceCompress bool | ||
|
|
||
| // HTTPClient is the HTTP client to use. If the HTTPClient field is not nil, | ||
| // the docker client is created with HTTPClient, and the below cert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not apply only to “docker”, and it should be in the “Global configuration overrides” section.
|
|
||
| // HTTPClient is the HTTP client to use. If the HTTPClient field is not nil, | ||
| // the docker client is created with HTTPClient, and the below cert | ||
| // config are ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no options “below” — and while this makes sense in a way, it can lead to surprising behavior changes.
|
After reading the code in more detail: the way That’s another point in favor of a more localized (Still unsure, but leaning much more towards a more targeted option. I’d love to head what others think as well.) |
|
I agree this should be done in containers/image not in any of the packages that use containers/image. |
|
What is the state of this PR? |
|
I'd argue that the primary method of configuring the system to use a HTTP Proxy should be to use the |
|
@ueokande Are you still interested in this PR? |
|
Sorry for replying so late. I noticed that the design is not so good. Adding Additionally, some methods create an HTTP client by Thanks for the duscuttion, but I am inclined to close this PR once. |
I propose that the user can configure HTTP client to access internet by it.
In our case, the http proxy settings is required when the client accesses to Internet.
The HTTP proxy is currently set via environment variable.
image/pkg/tlsclientconfig/tlsclientconfig.go
Line 101 in 63a1cbd
This patch adds filed
HTTPClient *http.ClienttoSystemContextto use on pulling image or fetching informations from the Internet. The docker client useHTTPClientfield if set, and ignores cert configs inSystemContextfields, otherwise it use default http client from cert configs inSystemContext.