Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
d8151730
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,发现更多精彩内容 >>
提交
d8151730
编写于
4月 01, 2020
作者:
S
Sharif Elgamal
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
retry anytime node.Start fails, not just in minikube start
上级
673922c8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
40 addition
and
30 deletion
+40
-30
cmd/minikube/cmd/node_add.go
cmd/minikube/cmd/node_add.go
+4
-9
cmd/minikube/cmd/node_start.go
cmd/minikube/cmd/node_start.go
+2
-2
cmd/minikube/cmd/start.go
cmd/minikube/cmd/start.go
+34
-18
pkg/minikube/node/node.go
pkg/minikube/node/node.go
+0
-1
未找到文件。
cmd/minikube/cmd/node_add.go
浏览文件 @
d8151730
...
...
@@ -18,10 +18,8 @@ package cmd
import
(
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/mustload"
"k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
...
...
@@ -56,7 +54,7 @@ var nodeAddCmd = &cobra.Command{
}
if
err
:=
node
.
Add
(
cc
,
n
);
err
!=
nil
{
exit
.
WithError
(
"Error adding node to cluster"
,
err
)
maybeDeleteAndRetry
(
*
cc
,
n
,
nil
,
err
)
}
out
.
T
(
out
.
Ready
,
"Successfully added {{.name}} to {{.cluster}}!"
,
out
.
V
{
"name"
:
name
,
"cluster"
:
cc
.
Name
})
...
...
@@ -64,13 +62,10 @@ var nodeAddCmd = &cobra.Command{
}
func
init
()
{
//We should figure out which minikube start flags to actually import
nodeAddCmd
.
Flags
()
.
BoolVar
(
&
cp
,
"control-plane"
,
false
,
"If true, the node added will also be a control plane in addition to a worker."
)
nodeAddCmd
.
Flags
()
.
BoolVar
(
&
worker
,
"worker"
,
true
,
"If true, the added node will be marked for work. Defaults to true."
)
//We should figure out which of these flags to actually import
startCmd
.
Flags
()
.
Visit
(
func
(
f
*
pflag
.
Flag
)
{
nodeAddCmd
.
Flags
()
.
AddFlag
(
f
)
},
)
nodeAddCmd
.
Flags
()
.
Bool
(
deleteOnFailure
,
false
,
"If set, delete the current cluster if start fails and try again. Defaults to false."
)
nodeCmd
.
AddCommand
(
nodeAddCmd
)
}
cmd/minikube/cmd/node_start.go
浏览文件 @
d8151730
...
...
@@ -49,15 +49,15 @@ var nodeStartCmd = &cobra.Command{
exit
.
WithError
(
"retrieving node"
,
err
)
}
// Start it up baby
_
,
err
=
node
.
Start
(
*
cc
,
*
n
,
nil
,
false
)
if
err
!=
nil
{
exit
.
WithError
(
"starting node"
,
err
)
maybeDeleteAndRetry
(
*
cc
,
*
n
,
nil
,
err
)
}
},
}
func
init
()
{
nodeStartCmd
.
Flags
()
.
String
(
"name"
,
""
,
"The name of the node to start"
)
nodeStartCmd
.
Flags
()
.
Bool
(
deleteOnFailure
,
false
,
"If set, delete the current cluster if start fails and try again. Defaults to false."
)
nodeCmd
.
AddCommand
(
nodeStartCmd
)
}
cmd/minikube/cmd/start.go
浏览文件 @
d8151730
...
...
@@ -356,24 +356,8 @@ func runStart(cmd *cobra.Command, args []string) {
}
kubeconfig
,
err
:=
node
.
Start
(
cc
,
n
,
existingAddons
,
true
)
if
err
!=
nil
&&
viper
.
GetBool
(
deleteOnFailure
)
{
out
.
T
(
out
.
Warning
,
"Node {{.name}} failed to start, deleting and trying again."
,
out
.
V
{
"name"
:
n
.
Name
})
// Start failed, delete the cluster and try again
profile
,
err
:=
config
.
LoadProfile
(
cc
.
Name
)
if
err
!=
nil
{
out
.
ErrT
(
out
.
Meh
,
`"{{.name}}" profile does not exist, trying anyways.`
,
out
.
V
{
"name"
:
cc
.
Name
})
}
err
=
deleteProfile
(
profile
)
if
err
!=
nil
{
out
.
WarningT
(
"Failed to delete cluster {{.name}}, proceeding with retry anyway."
,
out
.
V
{
"name"
:
cc
.
Name
})
}
kubeconfig
,
err
=
node
.
Start
(
cc
,
n
,
existingAddons
,
true
)
if
err
!=
nil
{
// Ok we failed again, let's bail
exit
.
WithError
(
"Start failed after cluster deletion"
,
err
)
}
kubeconfig
=
maybeDeleteAndRetry
(
cc
,
n
,
existingAddons
,
err
)
}
numNodes
:=
viper
.
GetInt
(
nodes
)
...
...
@@ -488,6 +472,38 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string, machineName st
return
nil
}
func
maybeDeleteAndRetry
(
cc
config
.
ClusterConfig
,
n
config
.
Node
,
existingAddons
map
[
string
]
bool
,
originalErr
error
)
*
kubeconfig
.
Settings
{
if
viper
.
GetBool
(
deleteOnFailure
)
{
out
.
T
(
out
.
Warning
,
"Node {{.name}} failed to start, deleting and trying again."
,
out
.
V
{
"name"
:
n
.
Name
})
// Start failed, delete the cluster and try again
profile
,
err
:=
config
.
LoadProfile
(
cc
.
Name
)
if
err
!=
nil
{
out
.
ErrT
(
out
.
Meh
,
`"{{.name}}" profile does not exist, trying anyways.`
,
out
.
V
{
"name"
:
cc
.
Name
})
}
err
=
deleteProfile
(
profile
)
if
err
!=
nil
{
out
.
WarningT
(
"Failed to delete cluster {{.name}}, proceeding with retry anyway."
,
out
.
V
{
"name"
:
cc
.
Name
})
}
var
kubeconfig
*
kubeconfig
.
Settings
for
_
,
v
:=
range
cc
.
Nodes
{
k
,
err
:=
node
.
Start
(
cc
,
v
,
existingAddons
,
v
.
ControlPlane
)
if
v
.
ControlPlane
{
kubeconfig
=
k
}
if
err
!=
nil
{
// Ok we failed again, let's bail
exit
.
WithError
(
"Start failed after cluster deletion"
,
err
)
}
}
return
kubeconfig
}
// Don't delete the cluster unless they ask
exit
.
WithError
(
"startup failed"
,
originalErr
)
return
nil
}
func
selectDriver
(
existing
*
config
.
ClusterConfig
)
registry
.
DriverState
{
// Technically unrelated, but important to perform before detection
driver
.
SetLibvirtURI
(
viper
.
GetString
(
kvmQemuURI
))
...
...
pkg/minikube/node/node.go
浏览文件 @
d8151730
...
...
@@ -39,7 +39,6 @@ func Add(cc *config.ClusterConfig, n config.Node) error {
return
errors
.
Wrap
(
err
,
"save node"
)
}
// TODO: Start should return an error rather than calling exit!
_
,
err
:=
Start
(
*
cc
,
n
,
nil
,
false
)
return
err
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录