Additionally set lower case envs. Propagate network inspect during node creation.

This commit is contained in:
Amit Watve
2019-06-19 14:01:43 -07:00
parent 5f43b70187
commit d2897ef9ab
2 changed files with 21 additions and 8 deletions

View File

@@ -145,7 +145,10 @@ func createNode(name, image, clusterLabel, role string, mounts []cri.Mount, extr
}
// pass proxy environment variables to be used by node's docker deamon
proxyDetails := getProxyDetails()
proxyDetails, err := getProxyDetails()
if err != nil || proxyDetails == nil {
return nil, errors.Wrap(err, "proxy setup error")
}
for key, val := range proxyDetails.Envs {
runArgs = append(runArgs, "-e", fmt.Sprintf("%s=%s", key, val))
}

View File

@@ -264,32 +264,42 @@ type proxyDetails struct {
// getProxyDetails returns a struct with the host environment proxy settings
// that should be passed to the nodes
func getProxyDetails() proxyDetails {
func getProxyDetails() (*proxyDetails, error) {
var proxyEnvs = []string{httpProxy, httpsProxy, noProxy}
var val string
var details proxyDetails
details.Envs = make(map[string]string)
proxySupport := false
for _, name := range proxyEnvs {
val = os.Getenv(name)
if val != "" {
proxySupport = true
details.Envs[name] = val
details.Envs[strings.ToLower(name)] = val
} else {
val = os.Getenv(strings.ToLower(name))
if val != "" {
proxySupport = true
details.Envs[name] = val
details.Envs[strings.ToLower(name)] = val
}
}
}
// Specifically add the docker network subnets to NO_PROXY
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)]), ",")
// Specifically add the docker network subnets to NO_PROXY if we are using proxies
if proxySupport {
subnets, err := getSubnets(defaultNetwork)
if err != nil {
return nil, err
}
noProxyList := strings.Join(append(subnets, details.Envs[noProxy]), ",")
details.Envs[noProxy] = noProxyList
details.Envs[strings.ToLower(noProxy)] = noProxyList
}
return details
return &details, nil
}
// getSubnets returns a slice of subnets for a specified network