Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
aae77843
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,发现更多精彩内容 >>
未验证
提交
aae77843
编写于
10月 06, 2020
作者:
P
priyawadhwa
提交者:
GitHub
10月 06, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9383 from priyawadhwa/status-bg
Fix minikube status bug when cluster is paused
上级
111588c7
7d62ce1c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
6 deletion
+58
-6
cmd/minikube/cmd/status.go
cmd/minikube/cmd/status.go
+14
-2
test/integration/status_test.go
test/integration/status_test.go
+44
-4
未找到文件。
cmd/minikube/cmd/status.go
浏览文件 @
aae77843
...
...
@@ -96,6 +96,11 @@ const (
)
var
(
exitCodeToHTTPCode
=
map
[
int
]
int
{
// exit code 26 corresponds to insufficient storage
26
:
507
,
}
codeNames
=
map
[
int
]
string
{
100
:
"Starting"
,
101
:
"Pausing"
,
...
...
@@ -448,14 +453,18 @@ func readEventLog(name string) ([]cloudevents.Event, time.Time, error) {
// clusterState converts Status structs into a ClusterState struct
func
clusterState
(
sts
[]
*
Status
)
ClusterState
{
sc
:=
statusCode
(
sts
[
0
]
.
Host
)
statusName
:=
sts
[
0
]
.
APIServer
if
sts
[
0
]
.
Host
==
codeNames
[
InsufficientStorage
]
{
statusName
=
sts
[
0
]
.
Host
}
sc
:=
statusCode
(
statusName
)
cs
:=
ClusterState
{
BinaryVersion
:
version
.
GetVersion
(),
BaseState
:
BaseState
{
Name
:
ClusterFlagValue
(),
StatusCode
:
sc
,
StatusName
:
st
s
[
0
]
.
Host
,
StatusName
:
st
atusName
,
StatusDetail
:
codeDetails
[
sc
],
},
...
...
@@ -539,6 +548,9 @@ func clusterState(sts []*Status) ClusterState {
glog
.
Errorf
(
"unable to convert exit code to int: %v"
,
err
)
continue
}
if
val
,
ok
:=
exitCodeToHTTPCode
[
exitCode
];
ok
{
exitCode
=
val
}
transientCode
=
exitCode
for
_
,
n
:=
range
cs
.
Nodes
{
n
.
StatusCode
=
transientCode
...
...
test/integration/status_test.go
浏览文件 @
aae77843
...
...
@@ -52,7 +52,7 @@ func TestInsufficientStorage(t *testing.T) {
}
// make sure 'minikube status' has correct output
stdout
:=
runStatusCmd
(
ctx
,
t
,
profile
)
stdout
:=
runStatusCmd
(
ctx
,
t
,
profile
,
true
)
verifyClusterState
(
t
,
stdout
)
// try deleting events.json and make sure this still works
...
...
@@ -60,16 +60,18 @@ func TestInsufficientStorage(t *testing.T) {
if
err
:=
os
.
Remove
(
eventsFile
);
err
!=
nil
{
t
.
Fatalf
(
"removing %s"
,
eventsFile
)
}
stdout
=
runStatusCmd
(
ctx
,
t
,
profile
)
stdout
=
runStatusCmd
(
ctx
,
t
,
profile
,
true
)
verifyClusterState
(
t
,
stdout
)
}
// runStatusCmd runs the status command and returns stdout
func
runStatusCmd
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
)
[]
byte
{
func
runStatusCmd
(
ctx
context
.
Context
,
t
*
testing
.
T
,
profile
string
,
increaseEnv
bool
)
[]
byte
{
// make sure minikube status shows insufficient storage
c
:=
exec
.
CommandContext
(
ctx
,
Target
(),
"status"
,
"-p"
,
profile
,
"--output=json"
,
"--layout=cluster"
)
// artificially set /var to 100% capacity
c
.
Env
=
append
(
os
.
Environ
(),
fmt
.
Sprintf
(
"%s=100"
,
constants
.
TestDiskUsedEnv
))
if
increaseEnv
{
c
.
Env
=
append
(
os
.
Environ
(),
fmt
.
Sprintf
(
"%s=100"
,
constants
.
TestDiskUsedEnv
))
}
rr
,
err
:=
Run
(
t
,
c
)
// status exits non-0 if status isn't Running
if
err
==
nil
{
...
...
@@ -96,3 +98,41 @@ func verifyClusterState(t *testing.T, contents []byte) {
}
}
}
func
TestPauseStatus
(
t
*
testing
.
T
)
{
// run start
profile
:=
UniqueProfileName
(
"pause-status"
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
Minutes
(
5
))
defer
Cleanup
(
t
,
profile
,
cancel
)
startArgs
:=
[]
string
{
"start"
,
"-p"
,
profile
,
"--output=json"
,
"--wait=true"
}
startArgs
=
append
(
startArgs
,
StartArgs
()
...
)
c
:=
exec
.
CommandContext
(
ctx
,
Target
(),
startArgs
...
)
rr
,
err
:=
Run
(
t
,
c
)
if
err
!=
nil
{
t
.
Fatalf
(
"minikube start failed %v
\n
%v"
,
rr
.
Command
(),
err
)
}
// run pause
pauseArgs
:=
[]
string
{
"pause"
,
"-p"
,
profile
}
c
=
exec
.
CommandContext
(
ctx
,
Target
(),
pauseArgs
...
)
rr
,
err
=
Run
(
t
,
c
)
if
err
!=
nil
{
t
.
Fatalf
(
"minikube pause failed %v
\n
%v"
,
rr
.
Command
(),
err
)
}
// run status
statusOutput
:=
runStatusCmd
(
context
.
Background
(),
t
,
profile
,
false
)
var
cs
cmd
.
ClusterState
if
err
:=
json
.
Unmarshal
(
statusOutput
,
&
cs
);
err
!=
nil
{
t
.
Fatalf
(
"unmarshalling: %v"
,
err
)
}
// verify the status looks as we expect
if
cs
.
StatusCode
!=
cmd
.
Paused
{
t
.
Fatalf
(
"incorrect status code: %v"
,
cs
.
StatusCode
)
}
if
cs
.
StatusName
!=
"Paused"
{
t
.
Fatalf
(
"incorrect status name: %v"
,
cs
.
StatusName
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录