Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
0ba3eb6f
D
dashboard
项目概览
凌波微步_大先生
/
dashboard
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dashboard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0ba3eb6f
编写于
5月 19, 2016
作者:
L
Luiz Felipe G. Pereira
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding old replica sets
上级
b2ebb59f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
105 addition
and
35 deletion
+105
-35
src/app/backend/resource/deployment/deploymentdetail.go
src/app/backend/resource/deployment/deploymentdetail.go
+42
-8
src/test/backend/resource/deployment/deploymentdetail_test.go
...test/backend/resource/deployment/deploymentdetail_test.go
+63
-27
未找到文件。
src/app/backend/resource/deployment/deploymentdetail.go
浏览文件 @
0ba3eb6f
...
@@ -4,9 +4,9 @@ import (
...
@@ -4,9 +4,9 @@ import (
"log"
"log"
"github.com/kubernetes/dashboard/resource/common"
"github.com/kubernetes/dashboard/resource/common"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
deploymentutil
"k8s.io/kubernetes/pkg/util/deployment"
)
)
type
RollingUpdateStrategy
struct
{
type
RollingUpdateStrategy
struct
{
...
@@ -31,15 +31,17 @@ type DeploymentDetail struct {
...
@@ -31,15 +31,17 @@ type DeploymentDetail struct {
// Min ready seconds
// Min ready seconds
MinReadySeconds
int
`json:"minReadySeconds"`
MinReadySeconds
int
`json:"minReadySeconds"`
// Rolling update strategy
// Rolling update strategy containing maxSurge and maxUnavailable
// 1 max unavailable, 1 max surge
RollingUpdateStrategy
`json:"rollingUpdateStrategy,omitempty"`
RollingUpdateStrategy
`json:"rollingUpdateStrategy,omitempty"`
//OldReplicaSets
// OldReplicaSets
OldReplicaSets
[]
extensions
.
ReplicaSet
`json:"oldReplicaSets"`
//NewReplicaSet
// NewReplicaSet
NewReplicaSet
extensions
.
ReplicaSet
`json:"newReplicaSet"`
//Events
// Events
// TODO
}
}
func
GetDeploymentDetail
(
client
client
.
Interface
,
namespace
string
,
name
string
)
(
*
DeploymentDetail
,
error
)
{
func
GetDeploymentDetail
(
client
client
.
Interface
,
namespace
string
,
name
string
)
(
*
DeploymentDetail
,
error
)
{
...
@@ -51,10 +53,40 @@ func GetDeploymentDetail(client client.Interface, namespace string, name string)
...
@@ -51,10 +53,40 @@ func GetDeploymentDetail(client client.Interface, namespace string, name string)
return
nil
,
err
return
nil
,
err
}
}
return
getDeploymentDetail
(
deploymentData
),
nil
channels
:=
&
common
.
ResourceChannels
{
ReplicaSetList
:
common
.
GetReplicaSetListChannel
(
client
.
Extensions
(),
1
),
PodList
:
common
.
GetPodListChannel
(
client
,
1
),
}
replicaSetList
:=
<-
channels
.
ReplicaSetList
.
List
if
err
:=
<-
channels
.
ReplicaSetList
.
Error
;
err
!=
nil
{
return
nil
,
err
}
pods
:=
<-
channels
.
PodList
.
List
if
err
:=
<-
channels
.
PodList
.
Error
;
err
!=
nil
{
return
nil
,
err
}
oldReplicaSets
,
_
,
err
:=
deploymentutil
.
FindOldReplicaSets
(
deploymentData
,
replicaSetList
.
Items
,
pods
)
if
err
!=
nil
{
return
nil
,
err
}
//newReplicaSet, err := deploymentutil.FindNewReplicaSet(deploymentData, replicaSetList.Items)
//if err != nil {
//return nil, err
//}
return
getDeploymentDetail
(
deploymentData
,
oldReplicaSets
),
nil
}
}
func
getDeploymentDetail
(
deployment
*
extensions
.
Deployment
)
*
DeploymentDetail
{
func
getDeploymentDetail
(
deployment
*
extensions
.
Deployment
,
old
[]
*
extensions
.
ReplicaSet
)
*
DeploymentDetail
{
oldReplicaSets
:=
make
([]
extensions
.
ReplicaSet
,
len
(
old
))
for
i
,
replicaSet
:=
range
old
{
oldReplicaSets
[
i
]
=
*
replicaSet
}
return
&
DeploymentDetail
{
return
&
DeploymentDetail
{
ObjectMeta
:
common
.
NewObjectMeta
(
deployment
.
ObjectMeta
),
ObjectMeta
:
common
.
NewObjectMeta
(
deployment
.
ObjectMeta
),
...
@@ -67,5 +99,7 @@ func getDeploymentDetail(deployment *extensions.Deployment) *DeploymentDetail {
...
@@ -67,5 +99,7 @@ func getDeploymentDetail(deployment *extensions.Deployment) *DeploymentDetail {
MaxSurge
:
deployment
.
Spec
.
Strategy
.
RollingUpdate
.
MaxSurge
.
IntValue
(),
MaxSurge
:
deployment
.
Spec
.
Strategy
.
RollingUpdate
.
MaxSurge
.
IntValue
(),
MaxUnavailable
:
deployment
.
Spec
.
Strategy
.
RollingUpdate
.
MaxUnavailable
.
IntValue
(),
MaxUnavailable
:
deployment
.
Spec
.
Strategy
.
RollingUpdate
.
MaxUnavailable
.
IntValue
(),
},
},
OldReplicaSets
:
oldReplicaSets
,
//NewReplicaSet: *newReplicaSet,
}
}
}
}
src/test/backend/resource/deployment/deploymentdetail_test.go
浏览文件 @
0ba3eb6f
...
@@ -8,12 +8,63 @@ import (
...
@@ -8,12 +8,63 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
deploymentutil
"k8s.io/kubernetes/pkg/util/deployment"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/intstr"
"github.com/kubernetes/dashboard/resource/common"
"github.com/kubernetes/dashboard/resource/common"
)
)
func
TestGetDeploymentDetailFromChannels
(
t
*
testing
.
T
)
{
func
TestGetDeploymentDetail
(
t
*
testing
.
T
)
{
podList
:=
&
api
.
PodList
{}
deployment
:=
&
extensions
.
Deployment
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test-name"
,
Labels
:
map
[
string
]
string
{
"track"
:
"beta"
},
},
Spec
:
extensions
.
DeploymentSpec
{
Selector
:
&
unversioned
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}},
Replicas
:
4
,
MinReadySeconds
:
5
,
Strategy
:
extensions
.
DeploymentStrategy
{
Type
:
extensions
.
RollingUpdateDeploymentStrategyType
,
RollingUpdate
:
&
extensions
.
RollingUpdateDeployment
{
MaxSurge
:
intstr
.
FromInt
(
1
),
MaxUnavailable
:
intstr
.
FromString
(
"1"
),
},
},
Template
:
api
.
PodTemplateSpec
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test-pod-name"
,
Labels
:
map
[
string
]
string
{
"track"
:
"beta"
},
},
},
},
Status
:
extensions
.
DeploymentStatus
{
Replicas
:
4
,
UpdatedReplicas
:
2
,
AvailableReplicas
:
3
,
UnavailableReplicas
:
1
,
},
}
podTemplateSpec
:=
deploymentutil
.
GetNewReplicaSetTemplate
(
deployment
)
newReplicaSet
:=
extensions
.
ReplicaSet
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"replica-set-1"
},
Spec
:
extensions
.
ReplicaSetSpec
{
Template
:
podTemplateSpec
,
},
}
replicaSetList
:=
&
extensions
.
ReplicaSetList
{
Items
:
[]
extensions
.
ReplicaSet
{
newReplicaSet
,
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"replica-set-2"
},
},
},
}
cases
:=
[]
struct
{
cases
:=
[]
struct
{
namespace
,
name
string
namespace
,
name
string
...
@@ -23,32 +74,15 @@ func TestGetDeploymentDetailFromChannels(t *testing.T) {
...
@@ -23,32 +74,15 @@ func TestGetDeploymentDetailFromChannels(t *testing.T) {
}{
}{
{
{
"test-namespace"
,
"test-name"
,
"test-namespace"
,
"test-name"
,
[]
string
{
"get"
},
[]
string
{
"get"
,
"list"
,
"list"
},
&
extensions
.
Deployment
{
deployment
,
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test-name"
},
Spec
:
extensions
.
DeploymentSpec
{
Selector
:
&
unversioned
.
LabelSelector
{
MatchLabels
:
map
[
string
]
string
{
"foo"
:
"bar"
}},
Replicas
:
4
,
MinReadySeconds
:
5
,
Strategy
:
extensions
.
DeploymentStrategy
{
Type
:
extensions
.
RollingUpdateDeploymentStrategyType
,
RollingUpdate
:
&
extensions
.
RollingUpdateDeployment
{
MaxSurge
:
intstr
.
FromInt
(
1
),
MaxUnavailable
:
intstr
.
FromString
(
"1"
),
},
},
},
Status
:
extensions
.
DeploymentStatus
{
Replicas
:
4
,
UpdatedReplicas
:
2
,
AvailableReplicas
:
3
,
UnavailableReplicas
:
1
,
},
},
&
DeploymentDetail
{
&
DeploymentDetail
{
ObjectMeta
:
common
.
ObjectMeta
{
Name
:
"test-name"
},
ObjectMeta
:
common
.
ObjectMeta
{
TypeMeta
:
common
.
TypeMeta
{
Kind
:
common
.
ResourceKindDeployment
},
Name
:
"test-name"
,
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Labels
:
map
[
string
]
string
{
"track"
:
"beta"
},
},
TypeMeta
:
common
.
TypeMeta
{
Kind
:
common
.
ResourceKindDeployment
},
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Status
:
extensions
.
DeploymentStatus
{
Status
:
extensions
.
DeploymentStatus
{
Replicas
:
4
,
Replicas
:
4
,
UpdatedReplicas
:
2
,
UpdatedReplicas
:
2
,
...
@@ -61,13 +95,15 @@ func TestGetDeploymentDetailFromChannels(t *testing.T) {
...
@@ -61,13 +95,15 @@ func TestGetDeploymentDetailFromChannels(t *testing.T) {
MaxSurge
:
1
,
MaxSurge
:
1
,
MaxUnavailable
:
1
,
MaxUnavailable
:
1
,
},
},
OldReplicaSets
:
[]
extensions
.
ReplicaSet
{},
//NewReplicaSet: newReplicaSet,
},
},
},
},
}
}
for
_
,
c
:=
range
cases
{
for
_
,
c
:=
range
cases
{
fakeClient
:=
testclient
.
NewSimpleFake
(
c
.
deployment
)
fakeClient
:=
testclient
.
NewSimpleFake
(
c
.
deployment
,
replicaSetList
,
podList
)
actual
,
_
:=
GetDeploymentDetail
(
fakeClient
,
c
.
namespace
,
c
.
name
)
actual
,
_
:=
GetDeploymentDetail
(
fakeClient
,
c
.
namespace
,
c
.
name
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录