提交 e73c9594 编写于 作者: P Piotr Bryk

Merge pull request #835 from floreks/deployment-fix

Fix deployment detail not loading and showing wrong old replica sets
......@@ -182,4 +182,4 @@
<translation id="270964281826728358" key="MSG_TIME_UNIT_YEARS_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Time units label, many years (plural).">years</translation>
<translation id="6450429370516938913" key="MSG_TIME_NOT_YET_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label saying that a certain action has not happened yet.">didn't happen yet</translation>
<translation id="3299077321377208801" key="MSG_TIME_NOW_LABEL" source="/home/mirchev/go_workspace/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label saying that a certain action happened just now.">just now</translation>
</translationbundle>
</translationbundle>
\ No newline at end of file
......@@ -291,13 +291,20 @@ type ReplicaSetListChannel struct {
// errors that both must be read numReads times.
func GetReplicaSetListChannel(client client.ReplicaSetsNamespacer,
nsQuery *NamespaceQuery, numReads int) ReplicaSetListChannel {
return GetReplicaSetListChannelWithOptions(client, nsQuery, listEverything, numReads)
}
// GetReplicaSetListChannelWithOptions returns a pair of channels to a ReplicaSet list filtered
// by provided options and errors that both must be read numReads times.
func GetReplicaSetListChannelWithOptions(client client.ReplicaSetsNamespacer,
nsQuery *NamespaceQuery, options api.ListOptions, numReads int) ReplicaSetListChannel {
channel := ReplicaSetListChannel{
List: make(chan *extensions.ReplicaSetList, numReads),
Error: make(chan error, numReads),
}
go func() {
list, err := client.ReplicaSets(nsQuery.ToRequestParam()).List(listEverything)
list, err := client.ReplicaSets(nsQuery.ToRequestParam()).List(options)
var filteredItems []extensions.ReplicaSet
for _, item := range list.Items {
if nsQuery.Matches(item.ObjectMeta.Namespace) {
......
......@@ -6,6 +6,7 @@ import (
"github.com/kubernetes/dashboard/resource/common"
"github.com/kubernetes/dashboard/resource/replicaset"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
client "k8s.io/kubernetes/pkg/client/unversioned"
deploymentutil "k8s.io/kubernetes/pkg/util/deployment"
......@@ -45,7 +46,7 @@ type DeploymentDetail struct {
// The deployment strategy to use to replace existing pods with new ones.
// Valid options: Recreate, RollingUpdate
Strategy string `json:"strategy"`
Strategy extensions.DeploymentStrategyType `json:"strategy"`
// Min ready seconds
MinReadySeconds int32 `json:"minReadySeconds"`
......@@ -69,34 +70,39 @@ func GetDeploymentDetail(client client.Interface, namespace string,
log.Printf("Getting details of %s deployment in %s namespace", name, namespace)
deploymentData, err := client.Extensions().Deployments(namespace).Get(name)
deployment, err := client.Extensions().Deployments(namespace).Get(name)
if err != nil {
return nil, err
}
selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector)
if err != nil {
return nil, err
}
options := api.ListOptions{LabelSelector: selector}
channels := &common.ResourceChannels{
ReplicaSetList: common.GetReplicaSetListChannel(client.Extensions(),
common.NewSameNamespaceQuery(namespace), 1),
PodList: common.GetPodListChannel(client, common.NewSameNamespaceQuery(namespace), 1),
ReplicaSetList: common.GetReplicaSetListChannelWithOptions(client.Extensions(),
common.NewSameNamespaceQuery(namespace), options, 1),
PodList: common.GetPodListChannelWithOptions(client,
common.NewSameNamespaceQuery(namespace), options, 1),
}
replicaSetList := <-channels.ReplicaSetList.List
rsList := <-channels.ReplicaSetList.List
if err := <-channels.ReplicaSetList.Error; err != nil {
return nil, err
}
pods := <-channels.PodList.List
podList := <-channels.PodList.List
if err := <-channels.PodList.Error; err != nil {
return nil, err
}
oldReplicaSets, _, err := deploymentutil.FindOldReplicaSets(
deploymentData, replicaSetList.Items, pods)
oldReplicaSets, _, err := deploymentutil.FindOldReplicaSets(deployment, rsList.Items, podList)
if err != nil {
return nil, err
}
newReplicaSet, err := deploymentutil.FindNewReplicaSet(deploymentData, replicaSetList.Items)
newReplicaSet, err := deploymentutil.FindNewReplicaSet(deployment, rsList.Items)
if err != nil {
return nil, err
}
......@@ -106,16 +112,19 @@ func GetDeploymentDetail(client client.Interface, namespace string,
return nil, err
}
return getDeploymentDetail(deploymentData, oldReplicaSets, newReplicaSet,
pods.Items, events), nil
return getDeploymentDetail(deployment, oldReplicaSets, newReplicaSet,
podList.Items, events), nil
}
func getDeploymentDetail(deployment *extensions.Deployment,
oldRs []*extensions.ReplicaSet, newRs *extensions.ReplicaSet,
pods []api.Pod, events *common.EventList) *DeploymentDetail {
var newReplicaSet replicaset.ReplicaSet
newRsPodInfo := common.GetPodInfo(newRs.Status.Replicas, newRs.Spec.Replicas, pods)
newReplicaSet := replicaset.ToReplicaSet(newRs, &newRsPodInfo)
if newRs != nil {
newRsPodInfo := common.GetPodInfo(newRs.Status.Replicas, newRs.Spec.Replicas, pods)
newReplicaSet = replicaset.ToReplicaSet(newRs, &newRsPodInfo)
}
oldReplicaSets := make([]extensions.ReplicaSet, len(oldRs))
for i, replicaSet := range oldRs {
......@@ -129,7 +138,7 @@ func getDeploymentDetail(deployment *extensions.Deployment,
TypeMeta: common.NewTypeMeta(common.ResourceKindDeployment),
Selector: deployment.Spec.Selector.MatchLabels,
StatusInfo: GetStatusInfo(&deployment.Status),
Strategy: string(deployment.Spec.Strategy.Type),
Strategy: deployment.Spec.Strategy.Type,
MinReadySeconds: deployment.Spec.MinReadySeconds,
RollingUpdateStrategy: RollingUpdateStrategy{
MaxSurge: deployment.Spec.Strategy.RollingUpdate.MaxSurge.IntValue(),
......
......@@ -3,6 +3,24 @@
<md-tabs md-border-bottom md-dynamic-height>
<md-tab label="Overview">
<kd-deployment-info deployment="::ctrl.deploymentDetail"></kd-deployment-info>
<kd-content-card>
<kd-title>New Replica Set</kd-title>
<kd-content>
<kd-replica-set-card-list
replica-sets="::[ctrl.deploymentDetail.newReplicaSet]">
</kd-replica-set-card-list>
</kd-content>
</kd-content-card>
<kd-content-card>
<kd-title>Old Replica Sets</kd-title>
<kd-content>
<kd-replica-set-card-list
replica-sets="::ctrl.deploymentDetail.oldReplicaSetList.replicaSets">
</kd-replica-set-card-list>
</kd-content>
</kd-content-card>
</md-tab>
<md-tab label="Events">
<kd-event-card-list events="::ctrl.deploymentDetail.eventList.events"></kd-event-card-list>
......
......@@ -27,26 +27,11 @@
Max Unavailable: {{::$ctrl.deployment.rollingUpdateStrategy.maxUnavailable}}
</kd-info-card-entry>
</kd-info-card-section>
<kd-info-card-section>
<kd-info-card-entry title="Status">
{{::$ctrl.deployment.statusInfo.updated}} updated,
{{::$ctrl.deployment.statusInfo.replicas}} total,
{{::$ctrl.deployment.statusInfo.available}} available,
{{::$ctrl.deployment.statusInfo.unavailable}} unavailable
</kd-info-card-entry>
<kd-info-card-entry title="New Replica Set">
<kd-middle-ellipsis display-string="{{$ctrl.deployment.newReplicaSet.objectMeta.name}}">
</kd-middle-ellipsis>
</kd-info-card-entry>
<kd-info-card-entry title="Old Replica Sets">
<div ng-repeat="rs in $ctrl.deployment.oldReplicaSets.replicaSets">
{{rs.objectMeta.name}}
</div>
<div ng-if="!$ctrl.deployment.oldReplicaSets.replicaSets.length">
None
</div>
{{::$ctrl.deployment.statusInfo.updated}} updated,
{{::$ctrl.deployment.statusInfo.replicas}} total,
{{::$ctrl.deployment.statusInfo.available}} available,
{{::$ctrl.deployment.statusInfo.unavailable}} unavailable
</kd-info-card-entry>
</kd-info-card-section>
</kd-info-card>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册