-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
support docker info proxy details #1176
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BenTheElder The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
29fcc0c
to
1978aeb
Compare
// we prefer the proxy env to allow more explicit per-invocation override | ||
// of proxy settings | ||
if len(envs) < 1 { | ||
e, err := getProxyEnvFromDocker(cmder) |
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.
TODO: probably re-work this so some providers don't do this? need to think about this more, but that shouldn't be hard and it's academic at the moment.
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.
can it be an interface getProxyEnvFromProvider
?
1978aeb
to
77fcadc
Compare
/hold |
We don't need to cover everything, IMO. For me personally, due to my network situation, I have to configure a proxy for the docker daemon, but usually this proxy runs on my local |
Probably we should pick up the config.json options instead of the daemon
options then..?
…On Tue, Dec 17, 2019, 18:54 Jintao Zhang ***@***.***> wrote:
We don't need to cover everything, IMO.
For me personally, due to my network situation, I have to configure a
proxy for the docker daemon, but usually this proxy runs on my local
localhost:8081, and I don't want to proxy this to the cluster created by
kind. Because that doesn't make it works well.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1176?email_source=notifications&email_token=AAHADKYVPG2OSHZMQZMGN3DQZGGHPA5CNFSM4J4EA5GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHEVWXA#issuecomment-566844252>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHADK7FCADYQRKMLSJBN7DQZGGHPANCNFSM4J4EA5GA>
.
|
Those seem to be purpose built as a way to set the env on containers, but
we want to append to it.
…On Tue, Dec 17, 2019, 18:56 Benjamin Elder ***@***.***> wrote:
Probably we should pick up the config.json options instead of the daemon
options then..?
On Tue, Dec 17, 2019, 18:54 Jintao Zhang ***@***.***> wrote:
> We don't need to cover everything, IMO.
>
> For me personally, due to my network situation, I have to configure a
> proxy for the docker daemon, but usually this proxy runs on my local
> localhost:8081, and I don't want to proxy this to the cluster created by
> kind. Because that doesn't make it works well.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#1176?email_source=notifications&email_token=AAHADKYVPG2OSHZMQZMGN3DQZGGHPA5CNFSM4J4EA5GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHEVWXA#issuecomment-566844252>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAHADK7FCADYQRKMLSJBN7DQZGGHPANCNFSM4J4EA5GA>
> .
>
|
Sorry for delay. As I said just now, because of my network environment (basically the same for most users in China), I need to run a proxy locally. But usually when the container is running, no proxy is needed. Even if I want to use a proxy, it will be configured in
For me, yes. |
"docker", "info", | ||
"--format", | ||
// one per line, upper(key)=value | ||
"HTTP_PROXY={{.HTTPProxy}}\nHTTPS_PROXY={{.HTTPSProxy}}\nNO_PROXY={{.NoProxy}}", |
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.
is this format stable?
This is what I have in my local machine
$ docker info --format "HTTP_PROXY={{.HTTPProxy}}\nHTTPS_PROXY={{.HTTPSProxy}}\nNO_PROXY={{.NoProxy}}"
HTTP_PROXY=\nHTTPS_PROXY=\nNO_PROXY=
$
} | ||
// parse out environment settings from the format we specified | ||
envs := make(map[string]string) | ||
for _, line := range lines { |
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.
we should check that the number of lines is 3 and the names of the variables []string{HTTPProxy, HTTPSProxy, NOProxy}
to be more robust.
If docker outputs whatever message instead of the variables we are going to return this wrong info
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.
- we control the format
- error output goes to stderr, not stdout
@@ -62,8 +62,8 @@ func RunErrorForError(err error) *RunError { | |||
// stderr + stdout, it scans these for lines and returns a slice of output lines | |||
func CombinedOutputLines(cmd Cmd) (lines []string, err error) { | |||
var buff bytes.Buffer | |||
cmd.SetStdout(&buff) | |||
cmd.SetStderr(&buff) | |||
cmd = cmd.SetStdout(&buff) |
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 curious, we need the assignment to make the code testable with the new fakeCmder
?
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.
At one point we did. This is more correct regardless.
aghh, I've just read now @tao12345666333 comments, is better to document that you MUST use environment variables if you want to use a proxy instead of open this new can of worms ;) ? |
yes, I think so. providing available solutions (use environment variables) is simpler and more effective than covering all possibilities |
/test pull-kind-conformance-parallel-ipv6 |
ahhg is parallel, the issue is only happening on serial 🤦♂️ |
@BenTheElder: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
see the issue, this needs a different solution. |
fixes #1175
I also wound up needing to fix some things along the way to test this properly: