From a6e5fb89d58184285552589632d43162b0112753 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 22 Oct 2020 16:05:06 -0700 Subject: [PATCH 01/10] lower mtu for cloud shell --- pkg/drivers/kic/oci/network_create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index f39e2a52a2a9..3cae4cc25a7b 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -85,7 +85,7 @@ func tryCreateDockerNetwork(subnetAddr string, subnetMask int, name string) (net gateway.To4()[3]++ // first ip for gateway klog.Infof("attempt to create network %s/%d with subnet: %s and gateway %s...", subnetAddr, subnetMask, name, gateway) // options documentation https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options - rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)) + rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), "--mtu=1400", name)) if err != nil { // Pool overlaps with other one on this address space if strings.Contains(rr.Output(), "Pool overlaps") { From bfa83ff602aaa141398eb8fdd17d511295a249d2 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 22 Oct 2020 16:56:13 -0700 Subject: [PATCH 02/10] fix option --- pkg/drivers/kic/oci/network_create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index 3cae4cc25a7b..019135078d4e 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -85,7 +85,7 @@ func tryCreateDockerNetwork(subnetAddr string, subnetMask int, name string) (net gateway.To4()[3]++ // first ip for gateway klog.Infof("attempt to create network %s/%d with subnet: %s and gateway %s...", subnetAddr, subnetMask, name, gateway) // options documentation https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options - rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), "--mtu=1400", name)) + rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", "--mtu=1400", "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)) if err != nil { // Pool overlaps with other one on this address space if strings.Contains(rr.Output(), "Pool overlaps") { From 50a04a49d4afe4c3d52116b596857d7b2c898d91 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Thu, 22 Oct 2020 17:33:33 -0700 Subject: [PATCH 03/10] try --- pkg/drivers/kic/oci/network_create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index 019135078d4e..b87a893abe21 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -85,7 +85,7 @@ func tryCreateDockerNetwork(subnetAddr string, subnetMask int, name string) (net gateway.To4()[3]++ // first ip for gateway klog.Infof("attempt to create network %s/%d with subnet: %s and gateway %s...", subnetAddr, subnetMask, name, gateway) // options documentation https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options - rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", "--mtu=1400", "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)) + rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", "com.docker.network.driver.mtu=1460", "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)) if err != nil { // Pool overlaps with other one on this address space if strings.Contains(rr.Output(), "Pool overlaps") { From cde546ed8046b12441578e30849ae511adf3cd6f Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 23 Oct 2020 12:41:29 -0700 Subject: [PATCH 04/10] detect MTU from docker brdige --- pkg/drivers/kic/oci/network_create.go | 55 +++++++++++++++++---------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index b87a893abe21..a07f54865f1c 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -22,6 +22,7 @@ import ( "fmt" "net" "os/exec" + "strconv" "strings" "github.com/pkg/errors" @@ -36,6 +37,9 @@ const firstSubnetAddr = "192.168.49.0" // big enough for a cluster of 254 nodes const defaultSubnetMask = 24 +// will be used if docker bridge config doesn't exist related issue #9528 +const defaultNetworkMTU = 1500 + // CreateNetwork creates a network returns gateway and error, minikube creates one network per cluster func CreateNetwork(ociBin string, name string) (net.IP, error) { if ociBin != Docker { @@ -46,7 +50,7 @@ func CreateNetwork(ociBin string, name string) (net.IP, error) { func createDockerNetwork(clusterName string) (net.IP, error) { // check if the network already exists - subnet, gateway, err := dockerNetworkInspect(clusterName) + subnet, gateway, mtu, err := dockerNetworkInspect(clusterName) if err == nil { klog.Infof("Found existing network with subnet %s and gateway %s.", subnet, gateway) return gateway, nil @@ -57,7 +61,7 @@ func createDockerNetwork(clusterName string) (net.IP, error) { // Rather than iterate through all of the valid subnets, give up at 20 to avoid a lengthy user delay for something that is unlikely to work. // will be like 192.168.49.0/24 ,...,192.168.239.0/24 for attempts < 20 { - gateway, err = tryCreateDockerNetwork(subnetAddr, defaultSubnetMask, clusterName) + gateway, err = tryCreateDockerNetwork(subnetAddr, defaultSubnetMask, mtu, clusterName) if err == nil { return gateway, nil } @@ -80,12 +84,13 @@ func createDockerNetwork(clusterName string) (net.IP, error) { return gateway, fmt.Errorf("failed to create network after 20 attempts") } -func tryCreateDockerNetwork(subnetAddr string, subnetMask int, name string) (net.IP, error) { +func tryCreateDockerNetwork(subnetAddr string, subnetMask int, mtu int, name string) (net.IP, error) { gateway := net.ParseIP(subnetAddr) gateway.To4()[3]++ // first ip for gateway - klog.Infof("attempt to create network %s/%d with subnet: %s and gateway %s...", subnetAddr, subnetMask, name, gateway) + klog.Infof("attempt to create network %s/%d with subnet: %s and gateway %s and MTU of %d ...", subnetAddr, subnetMask, name, gateway, mtu) // options documentation https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options - rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", "com.docker.network.driver.mtu=1460", "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)) + // adding MTU option because #9528 + rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", fmt.Sprintf("com.docker.network.driver.mtu=%d", mtu), "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)) if err != nil { // Pool overlaps with other one on this address space if strings.Contains(rr.Output(), "Pool overlaps") { @@ -99,32 +104,40 @@ func tryCreateDockerNetwork(subnetAddr string, subnetMask int, name string) (net return gateway, nil } -// returns subnet and gate if exists -func dockerNetworkInspect(name string) (*net.IPNet, net.IP, error) { - cmd := exec.Command(Docker, "network", "inspect", name, "--format", "{{(index .IPAM.Config 0).Subnet}},{{(index .IPAM.Config 0).Gateway}}") +// returns subnet and gate if exists returns subnet, gateway and mtu +func dockerNetworkInspect(name string) (*net.IPNet, net.IP, int, error) { + cmd := exec.Command(Docker, "network", "inspect", name, "--format", `{{(index .IPAM.Config 0).Subnet}},{{(index .IPAM.Config 0).Gateway}},(index .Options "com.docker.network.driver.mtu")`) rr, err := runCmd(cmd) if err != nil { logDockerNetworkInspect(name) if strings.Contains(rr.Output(), "No such network") { - return nil, nil, ErrNetworkNotFound + return nil, nil, defaultNetworkMTU, ErrNetworkNotFound } - return nil, nil, err + return nil, nil, defaultNetworkMTU, err } // results looks like 172.17.0.0/16,172.17.0.1 - ips := strings.Split(strings.TrimSpace(rr.Stdout.String()), ",") - if len(ips) == 0 { - return nil, nil, fmt.Errorf("empty IP list parsed from: %q", rr.Output()) + vals := strings.Split(strings.TrimSpace(rr.Stdout.String()), ",") + if len(vals) == 0 { + return nil, nil, defaultNetworkMTU, fmt.Errorf("empty IP list parsed from: %q", rr.Output()) } - _, subnet, err := net.ParseCIDR(ips[0]) - if err != nil { - return nil, nil, errors.Wrapf(err, "parse subnet for %s", name) - } var gateway net.IP - if len(ips) > 0 { - gateway = net.ParseIP(ips[1]) + mtu := defaultNetworkMTU + if len(vals) > 0 { + gateway = net.ParseIP(vals[1]) + mtu, err := strconv.Atoi(vals[2]) + if err != nil { + klog.Warning("failed to parse docker network %s mtu, will use the default %d : %v", name, defaultNetworkMTU, err) + mtu = defaultNetworkMTU + } } - return subnet, gateway, nil + + _, subnet, err := net.ParseCIDR(vals[0]) + if err != nil { + return nil, nil, defaultNetworkMTU, errors.Wrapf(err, "parse subnet for %s", name) + } + + return subnet, gateway, mtu, nil } func logDockerNetworkInspect(name string) { @@ -157,7 +170,7 @@ func RemoveNetwork(name string) error { } func networkExists(name string) bool { - _, _, err := dockerNetworkInspect(name) + _, _, _, err := dockerNetworkInspect(name) if err != nil && !errors.Is(err, ErrNetworkNotFound) { // log unexpected error klog.Warningf("Error inspecting docker network %s: %v", name, err) } From 94485d5a19a9e9619a7bcfd41ff4ef67e3c5aa59 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 23 Oct 2020 12:47:51 -0700 Subject: [PATCH 05/10] lint --- pkg/drivers/kic/oci/network.go | 2 +- pkg/drivers/kic/oci/network_create.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/drivers/kic/oci/network.go b/pkg/drivers/kic/oci/network.go index 274f01917d10..a3e59092c36c 100644 --- a/pkg/drivers/kic/oci/network.go +++ b/pkg/drivers/kic/oci/network.go @@ -35,7 +35,7 @@ import ( func RoutableHostIPFromInside(ociBin string, clusterName string, containerName string) (net.IP, error) { if ociBin == Docker { if runtime.GOOS == "linux" { - _, gateway, err := dockerNetworkInspect(clusterName) + _, gateway, _, err := dockerNetworkInspect(clusterName) if err != nil { if errors.Is(err, ErrNetworkNotFound) { klog.Infof("The container %s is not attached to a network, this could be because the cluster was created by minikube 0 { gateway = net.ParseIP(vals[1]) - mtu, err := strconv.Atoi(vals[2]) + mtu, err = strconv.Atoi(vals[2]) if err != nil { - klog.Warning("failed to parse docker network %s mtu, will use the default %d : %v", name, defaultNetworkMTU, err) + klog.Warningf("failed to parse docker network %s mtu, will use the default %d : %v", name, defaultNetworkMTU, err) mtu = defaultNetworkMTU } } From aa97aca2ff0baf8a61429ea22cff3c338dad928a Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 23 Oct 2020 13:45:25 -0700 Subject: [PATCH 06/10] make struct for netinfo --- pkg/drivers/kic/oci/network.go | 6 +-- pkg/drivers/kic/oci/network_create.go | 64 +++++++++++++++++---------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/pkg/drivers/kic/oci/network.go b/pkg/drivers/kic/oci/network.go index a3e59092c36c..9ca08fda28d2 100644 --- a/pkg/drivers/kic/oci/network.go +++ b/pkg/drivers/kic/oci/network.go @@ -35,16 +35,16 @@ import ( func RoutableHostIPFromInside(ociBin string, clusterName string, containerName string) (net.IP, error) { if ociBin == Docker { if runtime.GOOS == "linux" { - _, gateway, _, err := dockerNetworkInspect(clusterName) + info, err := dockerNetworkInspect(clusterName) if err != nil { if errors.Is(err, ErrNetworkNotFound) { klog.Infof("The container %s is not attached to a network, this could be because the cluster was created by minikube 0 { - gateway = net.ParseIP(vals[1]) - mtu, err = strconv.Atoi(vals[2]) + info.gateway = net.ParseIP(vals[1]) + mtu, err := strconv.Atoi(vals[2]) if err != nil { - klog.Warningf("failed to parse docker network %s mtu, will use the default %d : %v", name, defaultNetworkMTU, err) - mtu = defaultNetworkMTU + klog.Warningf("failed to parse docker network %s mtu, will use the default %d : %v", name, defaultMTU, err) + } else { + info.mtu = mtu } } - _, subnet, err := net.ParseCIDR(vals[0]) + _, info.subnet, err = net.ParseCIDR(vals[0]) if err != nil { - return nil, nil, defaultNetworkMTU, errors.Wrapf(err, "parse subnet for %s", name) + return info, errors.Wrapf(err, "parse subnet for %s", name) } - return subnet, gateway, mtu, nil + return info, nil } func logDockerNetworkInspect(name string) { @@ -170,7 +188,7 @@ func RemoveNetwork(name string) error { } func networkExists(name string) bool { - _, _, _, err := dockerNetworkInspect(name) + _, err := dockerNetworkInspect(name) if err != nil && !errors.Is(err, ErrNetworkNotFound) { // log unexpected error klog.Warningf("Error inspecting docker network %s: %v", name, err) } From 1dd5583ce33f05a4755f0cf42b7b6ed6c9f20342 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 23 Oct 2020 14:07:20 -0700 Subject: [PATCH 07/10] template --- pkg/drivers/kic/oci/network_create.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index 8b5eba0b7d26..c2d0ed808450 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -111,7 +111,7 @@ func tryCreateDockerNetwork(subnetAddr string, subnetMask int, mtu int, name str return gateway, nil } -// netInfo holds part of a docker or podman network information relevent to kic drivers +// netInfo holds part of a docker or podman network information relevant to kic drivers type netInfo struct { name string subnet *net.IPNet @@ -123,7 +123,7 @@ type netInfo struct { func dockerNetworkInspect(name string) (netInfo, error) { var info = netInfo{name: name} info.mtu = defaultMTU - cmd := exec.Command(Docker, "network", "inspect", name, "--format", `{{(index .IPAM.Config 0).Subnet}},{{(index .IPAM.Config 0).Gateway}},(index .Options "com.docker.network.driver.mtu")`) + cmd := exec.Command(Docker, "network", "inspect", name, "--format", `{{(index .IPAM.Config 0).Subnet}},{{(index .IPAM.Config 0).Gateway}},{{(index .Options "com.docker.network.driver.mtu")}}`) rr, err := runCmd(cmd) if err != nil { logDockerNetworkInspect(name) From 4993dc6ed7fb8caf13b4d84d6c4c0160acc7c1c1 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 23 Oct 2020 14:25:00 -0700 Subject: [PATCH 08/10] log --- pkg/drivers/kic/oci/network_create.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index c2d0ed808450..6a7d8c4e5365 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -122,7 +122,7 @@ type netInfo struct { // if exists returns subnet, gateway and mtu func dockerNetworkInspect(name string) (netInfo, error) { var info = netInfo{name: name} - info.mtu = defaultMTU + inf.mtu = defaultMTU cmd := exec.Command(Docker, "network", "inspect", name, "--format", `{{(index .IPAM.Config 0).Subnet}},{{(index .IPAM.Config 0).Gateway}},{{(index .Options "com.docker.network.driver.mtu")}}`) rr, err := runCmd(cmd) if err != nil { @@ -144,7 +144,7 @@ func dockerNetworkInspect(name string) (netInfo, error) { info.gateway = net.ParseIP(vals[1]) mtu, err := strconv.Atoi(vals[2]) if err != nil { - klog.Warningf("failed to parse docker network %s mtu, will use the default %d : %v", name, defaultMTU, err) + klog.Warningf("couldn't parse mtu for docker network %q wil use default MTU %s : %v", name, defaultMTU, err) } else { info.mtu = mtu } From 43c2a5cd0cb14a317b2875d4c35fc9fe3a02b41e Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 23 Oct 2020 14:54:49 -0700 Subject: [PATCH 09/10] dont pass mtu if 0 --- pkg/drivers/kic/oci/network_create.go | 31 ++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index 6a7d8c4e5365..2003e46e6615 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -37,9 +37,6 @@ const firstSubnetAddr = "192.168.49.0" // big enough for a cluster of 254 nodes const defaultSubnetMask = 24 -// will be used if docker bridge config doesn't exist related issue #9528 -const defaultMTU = 1500 - // name of the bridge network that docker creates by default to be used to get the MTU. ( related issue #9528) const dockerDefaultBridgeName = "bridge" @@ -59,9 +56,11 @@ func createDockerNetwork(clusterName string) (net.IP, error) { return info.gateway, nil } + // will try to get MTU from the docker network to avoid issue with systems with exotic MTU settings. + // related issue #9528 info, err = dockerNetworkInspect(dockerDefaultBridgeName) if err != nil { - info.mtu = defaultMTU + klog.Warningf("failed to get mtu information from the docker's default network %q: %v", dockerDefaultBridgeName, err) } attempts := 0 subnetAddr := firstSubnetAddr @@ -95,9 +94,26 @@ func tryCreateDockerNetwork(subnetAddr string, subnetMask int, mtu int, name str gateway := net.ParseIP(subnetAddr) gateway.To4()[3]++ // first ip for gateway klog.Infof("attempt to create network %s/%d with subnet: %s and gateway %s and MTU of %d ...", subnetAddr, subnetMask, name, gateway, mtu) - // options documentation https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options + args := []string{ + "network", + "create", + "--driver=bridge", + fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), + fmt.Sprintf("--gateway=%s", gateway), + // options documentation https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options + "-o", "--ip-masq", + "-o", "--icc", + fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), + name, + } + // adding MTU option because #9528 - rr, err := runCmd(exec.Command(Docker, "network", "create", "--driver=bridge", fmt.Sprintf("--subnet=%s", fmt.Sprintf("%s/%d", subnetAddr, subnetMask)), fmt.Sprintf("--gateway=%s", gateway), "-o", "--ip-masq", "-o", fmt.Sprintf("com.docker.network.driver.mtu=%d", mtu), "-o", "--icc", fmt.Sprintf("--label=%s=%s", CreatedByLabelKey, "true"), name)) + if mtu != 0 { + args = append(args, "-o") + args = append(args, fmt.Sprintf("com.docker.network.driver.mtu=%d", mtu)) + } + + rr, err := runCmd(exec.Command(Docker, args...)) if err != nil { // Pool overlaps with other one on this address space if strings.Contains(rr.Output(), "Pool overlaps") { @@ -122,7 +138,6 @@ type netInfo struct { // if exists returns subnet, gateway and mtu func dockerNetworkInspect(name string) (netInfo, error) { var info = netInfo{name: name} - inf.mtu = defaultMTU cmd := exec.Command(Docker, "network", "inspect", name, "--format", `{{(index .IPAM.Config 0).Subnet}},{{(index .IPAM.Config 0).Gateway}},{{(index .Options "com.docker.network.driver.mtu")}}`) rr, err := runCmd(cmd) if err != nil { @@ -144,7 +159,7 @@ func dockerNetworkInspect(name string) (netInfo, error) { info.gateway = net.ParseIP(vals[1]) mtu, err := strconv.Atoi(vals[2]) if err != nil { - klog.Warningf("couldn't parse mtu for docker network %q wil use default MTU %s : %v", name, defaultMTU, err) + klog.Warningf("couldn't parse mtu for docker network %q: %v", name, err) } else { info.mtu = mtu } From 9f729ac041b78fe7c776546d5a6f87acfc531948 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Fri, 23 Oct 2020 15:04:13 -0700 Subject: [PATCH 10/10] readability --- pkg/drivers/kic/oci/network_create.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/drivers/kic/oci/network_create.go b/pkg/drivers/kic/oci/network_create.go index 2003e46e6615..2958e90e5a6f 100644 --- a/pkg/drivers/kic/oci/network_create.go +++ b/pkg/drivers/kic/oci/network_create.go @@ -37,8 +37,8 @@ const firstSubnetAddr = "192.168.49.0" // big enough for a cluster of 254 nodes const defaultSubnetMask = 24 -// name of the bridge network that docker creates by default to be used to get the MTU. ( related issue #9528) -const dockerDefaultBridgeName = "bridge" +// name of the default Docker bridge network, used to lookup the MTU (see #9528) +const dockerDefaultBridge = "bridge" // CreateNetwork creates a network returns gateway and error, minikube creates one network per cluster func CreateNetwork(ociBin string, name string) (net.IP, error) { @@ -58,9 +58,9 @@ func createDockerNetwork(clusterName string) (net.IP, error) { // will try to get MTU from the docker network to avoid issue with systems with exotic MTU settings. // related issue #9528 - info, err = dockerNetworkInspect(dockerDefaultBridgeName) + info, err = dockerNetworkInspect(dockerDefaultBridge) if err != nil { - klog.Warningf("failed to get mtu information from the docker's default network %q: %v", dockerDefaultBridgeName, err) + klog.Warningf("failed to get mtu information from the docker's default network %q: %v", dockerDefaultBridge, err) } attempts := 0 subnetAddr := firstSubnetAddr @@ -108,7 +108,7 @@ func tryCreateDockerNetwork(subnetAddr string, subnetMask int, mtu int, name str } // adding MTU option because #9528 - if mtu != 0 { + if mtu > 0 { args = append(args, "-o") args = append(args, fmt.Sprintf("com.docker.network.driver.mtu=%d", mtu)) }