Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
43c2a5cd
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
43c2a5cd
编写于
10月 23, 2020
作者:
M
Medya Gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dont pass mtu if 0
上级
4993dc6e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
8 deletion
+23
-8
pkg/drivers/kic/oci/network_create.go
pkg/drivers/kic/oci/network_create.go
+23
-8
未找到文件。
pkg/drivers/kic/oci/network_create.go
浏览文件 @
43c2a5cd
...
...
@@ -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
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录