Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

BenTheElder
Copy link
Member

fixes #1175

I also wound up needing to fix some things along the way to test this properly:

  • subpar output from our test helpers (couldn't tell nil map vs empty map)
  • bugs versus our interface in cmd helpers
  • needed a simple exec fake (will write a nicer one later when I write some more test with it...)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 18, 2019
@k8s-ci-robot k8s-ci-robot requested review from amwat and aojea December 18, 2019 01:46
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 18, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 18, 2019
// we prefer the proxy env to allow more explicit per-invocation override
// of proxy settings
if len(envs) < 1 {
e, err := getProxyEnvFromDocker(cmder)
Copy link
Member Author

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.

Copy link
Contributor

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?

@BenTheElder
Copy link
Member Author

/hold
sigh. why is this so complicated with docker.
I suppose we may have to identify the config location and parse that too but I'd rather avoid that :|

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 18, 2019
@tao12345666333
Copy link
Member

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.

@BenTheElder
Copy link
Member Author

BenTheElder commented Dec 18, 2019 via email

@BenTheElder
Copy link
Member Author

BenTheElder commented Dec 18, 2019 via email

@tao12345666333
Copy link
Member

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.
I will set the docker daemon use it, this is for the convenience of pulling the image from a registry like gcr.io.

But usually when the container is running, no proxy is needed. Even if I want to use a proxy, it will be configured in ~ /.docker/config, or passed in through env.

Probably we should pick up the config.json options instead of the daemon options then..?

For me, yes.

"docker", "info",
"--format",
// one per line, upper(key)=value
"HTTP_PROXY={{.HTTPProxy}}\nHTTPS_PROXY={{.HTTPSProxy}}\nNO_PROXY={{.NoProxy}}",
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Member Author

@BenTheElder BenTheElder Dec 18, 2019

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)
Copy link
Contributor

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?

Copy link
Member Author

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.

@aojea
Copy link
Contributor

aojea commented Dec 18, 2019

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 ;) ?

@tao12345666333
Copy link
Member

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

@aojea
Copy link
Contributor

aojea commented Dec 18, 2019

/test pull-kind-conformance-parallel-ipv6

@aojea
Copy link
Contributor

aojea commented Dec 18, 2019

ahhg is parallel, the issue is only happening on serial 🤦‍♂️

@k8s-ci-robot
Copy link
Contributor

@BenTheElder: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kind-conformance-parallel-ipv6 77fcadc link /test pull-kind-conformance-parallel-ipv6

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.

@BenTheElder BenTheElder closed this Jan 6, 2020
@BenTheElder BenTheElder deleted the port-maps branch January 6, 2020 23:36
@BenTheElder
Copy link
Member Author

see the issue, this needs a different solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proxy info from docker config is not respected
4 participants