Changes to use Docker Desktop proxy#354
Conversation
6794f6c to
404799f
Compare
cmrigney
left a comment
There was a problem hiding this comment.
Thanks for doing this! I think there are a couple things we need to handle first:
- There are other places where we construct an
http.Clientwhere we'd also want to use this proxy. If you search them in the codebase you should find them. - We need a fallback for Docker CE and container contexts, since DD won't be available there. The solution is probably to make
DesktopProxyTransportcheckfeatures.IsRunningInDockerDesktop()and return the default transport if it's not running in DD, instead. All of this can be wrapped in async.Onceso we don't redundantly check DD presence (e.g. check outpkg/validate/validate.gofor an example).
I referred to your PR #118 to patch the http.Client usages. Yes there are few other source files that use http.Client I will update these files as well and use sync.Once(). I do not need to change the http.Client references in |
|
@cmrigney review when you get a chance. In the latest commit. I have done the below changes:
|
|
/share |
e783805 to
d2a0ec8
Compare
|
Hi @cmrigney I have incorporated the changes from your PR. I have tested this and I can see that running the below command creates a log entry in DD backend log httpproxy.log corresponding to that request. which indicates the request is served through DD proxy (172.211.16.3) Also for testing purpose, I had logged a message to a file (in ProxyTransport()) when MCP gateway created the TCP transport to indicate if it was using DD proxy transport. When the above update command was run, this message was logged to my log file: So the changes look good to me. I don't know if mcp gateway is intended to be used with Docker Engine (CE), as the README mentions Install prereq is Docker Desktop. Do let me know if any testing needs to be done against Docker Engine CE. |
cmrigney
left a comment
There was a problem hiding this comment.
This is looking good! Just needs a little log cleanup I think.
I did smoke test this on my Mac and in a container (which works very similar to Docker CE mode) and it looked good from my side. I'll smoke test Windows as well.
|
@karman-docker To answer your question about Docker CE, we do support it, but I don't quite know the test flow for that. I do feel that container mode is roughly equivalent though (for testing DD's absence). If you want to test container mode you can: |
|
Tested the fix: On Windows: With proxy server stopped: that's expected, and it proves, mcp tried to use DD proxy. With proxy server up: |
cmrigney
left a comment
There was a problem hiding this comment.
lgtm! Smoke testing on Windows checked out for me.
|
Hi @cmrigney |
|
DM'd you. |
0b9aa0f to
bc7a41c
Compare
bc7a41c to
f40d8da
Compare
What I did
Changed the default http client transport to use Docker Desktop proxy.
desktopProxyTransportInstwhich uses http.DefaultTransport if Docker Desktop is not running, otherwise creates a transport that forwards the http requests via Docker Desktop proxy.features.IsRunningInDockerDesktop()fromfeaturespackage todesktoppackage. Because I cannot accessfeaturespackage indesktoppackage as it results in a circular dependency between those two packages.Fixes https://docker.atlassian.net/browse/DDB-378
Related issue
https://docker.atlassian.net/browse/DDB-378
(not mandatory) A picture of a cute animal, if possible in relation to what you did