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

Automatically add the docker network to no_proxy #628

Merged
merged 4 commits into from Jun 24, 2019

Conversation

amwat
Copy link
Contributor

@amwat amwat commented Jun 19, 2019

fixes #525

Compute the host docker network subnets and plumb through the NO_PROXY env.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 19, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 19, 2019
@tao12345666333
Copy link
Member

/lgtm

Thanks.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 19, 2019
@@ -33,6 +33,14 @@ import (
"sigs.k8s.io/kind/pkg/exec"
)

const (
// Docker default bridge network is named "bridge" (https://docs.docker.com/network/bridge/#use-the-default-bridge-network)
defaultNetwork = "bridge"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be a constant in the docker pkg?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably yes, but this is also mostly a stub to make #484 viable if we go that route so I'm ok to deal with it later.

the docker <-> node coupling needs a lot more work soon, I'm sketching that out in a branch ... 😅


// Specifically add the docker network subnets to NO_PROXY
subnets, err := getSubnets(defaultNetwork)
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ok to ignore the error? just curiosity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I previously had it log the error, but decided to get rid of it since there's not really anything to do if we fail to get the subnets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should probably fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really? everything else would work just fine for users that aren't using a proxy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we didn't detect any proxy info we can elide even querying this instead

subnets, err := getSubnets(defaultNetwork)
if err == nil {
details.Envs[noProxy] = strings.Join(append(subnets, details.Envs[noProxy]), ",")
details.Envs[strings.ToLower(noProxy)] = strings.Join(append(subnets, details.Envs[strings.ToLower(noProxy)]), ",")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are only passing HTTP_PROXY and HTTPS_PROXY, maybe we should pass the lower caps of those too like you are doing here with no_proxy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good point, but would be reasonable to tackle in a different PR.

seperately I'd like to decouple this tooling more later, and I think HTTPS_PROXY will require a bit more finesse :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second though, we seem to be prioritizing the all-caps envs over the lower cased one on line 278 and also masking them to be all caps finally, was that intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the host the user can control this if necessary and we set caps to be higher priority, but on the nodes we should maybe(?) supply the values in both keys since this isn't fully standardized

on the host side, the user can always explicitly set the caps ones when calling kind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems curl only works with lowercase , there are few of stack overflows posts about this. I dont have it clear though

)

// NetworkInspect displays detailed information on one or more networks
func NetworkInspect(networkNames []string, format string) ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO their should be a higher level abstraction that dealing with docker format strings outside this package, but also fine to iterate on this.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 19, 2019
@aojea
Copy link
Contributor

aojea commented Jun 19, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 19, 2019
Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor refactor later. Functionality good and this is currently broken.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amwat, BenTheElder, neolit123

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 Jun 24, 2019
@BenTheElder
Copy link
Member

CI (prow) is flaky today and we have a release to get going...

@BenTheElder
Copy link
Member

/override pull-kind-conformance-parallel

@k8s-ci-robot
Copy link
Contributor

@BenTheElder: Overrode contexts on behalf of BenTheElder: pull-kind-conformance-parallel

In response to this:

/override pull-kind-conformance-parallel

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.

@k8s-ci-robot k8s-ci-robot merged commit 4d1ea76 into kubernetes-sigs:master Jun 24, 2019
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't proxy docker network automatically when using proxies
6 participants