Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions i18n/messages-en.xtb
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,15 @@
<translation id="5143266087600531180" key="MSG_NAMESPACE_SELECT_ARIA_LABEL" source="/usr/local/google/home/bryk/src/github.com/dashboard/.tmp/serve/app-dev.js" desc="Text describing what namespace selector is">Selector for namespaces</translation>
<translation id="7612562063769289643" key="MSG_PODS_ARE_FAILED_TOOLTIP" source="/home/maciaszczykm/workspace/dashboard/.tmp/serve/app-dev.js" desc="tooltip for failed pod card icon">One or more pods have errors.</translation>
<translation id="7471636163011126552" key="MSG_PODS_ARE_PENDING_TOOLTIP" source="/home/maciaszczykm/workspace/dashboard/.tmp/serve/app-dev.js" desc="tooltip for pending pod card icon">One or more pods are in pending state.</translation>
<translation id="5059203627384479637" key="MSG_PET_SET_DETAIL_OVERVIEW_TAB" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Overview tab label on the pet set detail page.">Overview</translation>
<translation id="6998996832659188031" key="MSG_PET_SET_DETAIL_PODS_CARD_TITLE" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Related pods card title on the pet set detail page.">Pods</translation>
<translation id="8707615799932704635" key="MSG_PET_SET_DETAIL_EVENTS_TAB" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Events tab label on the pet set detail page.">Events</translation>
<translation id="1061534452415111025" key="MSG_PET_SET_INFO_DETAILS_SECTION" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section name.">Details</translation>
<translation id="5246158437544347926" key="MSG_PET_SET_INFO_NAME_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section name entry.">Name</translation>
<translation id="1965909741930893667" key="MSG_PET_SET_INFO_NAMESPACE_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section namespace entry.">Namespace</translation>
<translation id="6096611116725653973" key="MSG_PET_SET_INFO_LABELS_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section labels entry.">Labels</translation>
<translation id="1079594048788916996" key="MSG_PET_SET_INFO_IMAGES_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section images entry.">Images</translation>
<translation id="3762856444030194375" key="MSG_PET_SET_INFO_STATUS_SECTION" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info status section name.">Status</translation>
<translation id="1744330140020758003" key="MSG_PET_SET_INFO_PODS_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info status section pods entry.">Pods</translation>
<translation id="6654869080140416303" key="MSG_PET_SET_INFO_PODS_STATUS_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info status section pods status entry.">Pods status</translation>
</translationbundle>
11 changes: 11 additions & 0 deletions i18n/messages-ja.xtb
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,15 @@
<translation id="5143266087600531180" key="MSG_NAMESPACE_SELECT_ARIA_LABEL" source="/usr/local/google/home/bryk/src/github.com/dashboard/.tmp/serve/app-dev.js" desc="Text describing what namespace selector is">Selector for namespaces</translation>
<translation id="7612562063769289643" key="MSG_PODS_ARE_FAILED_TOOLTIP" source="/home/maciaszczykm/workspace/dashboard/.tmp/serve/app-dev.js" desc="tooltip for failed pod card icon">One or more pods have errors.</translation>
<translation id="7471636163011126552" key="MSG_PODS_ARE_PENDING_TOOLTIP" source="/home/maciaszczykm/workspace/dashboard/.tmp/serve/app-dev.js" desc="tooltip for pending pod card icon">One or more pods are in pending state.</translation>
<translation id="5059203627384479637" key="MSG_PET_SET_DETAIL_OVERVIEW_TAB" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Overview tab label on the pet set detail page.">Overview</translation>
<translation id="6998996832659188031" key="MSG_PET_SET_DETAIL_PODS_CARD_TITLE" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Related pods card title on the pet set detail page.">Pods</translation>
<translation id="8707615799932704635" key="MSG_PET_SET_DETAIL_EVENTS_TAB" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Events tab label on the pet set detail page.">Events</translation>
<translation id="1061534452415111025" key="MSG_PET_SET_INFO_DETAILS_SECTION" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section name.">Details</translation>
<translation id="5246158437544347926" key="MSG_PET_SET_INFO_NAME_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section name entry.">Name</translation>
<translation id="1965909741930893667" key="MSG_PET_SET_INFO_NAMESPACE_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section namespace entry.">Namespace</translation>
<translation id="6096611116725653973" key="MSG_PET_SET_INFO_LABELS_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section labels entry.">Labels</translation>
<translation id="1079594048788916996" key="MSG_PET_SET_INFO_IMAGES_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info details section images entry.">Images</translation>
<translation id="3762856444030194375" key="MSG_PET_SET_INFO_STATUS_SECTION" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info status section name.">Status</translation>
<translation id="1744330140020758003" key="MSG_PET_SET_INFO_PODS_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info status section pods entry.">Pods</translation>
<translation id="6654869080140416303" key="MSG_PET_SET_INFO_PODS_STATUS_ENTRY" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Pet set info status section pods status entry.">Pods status</translation>
</translationbundle>
22 changes: 20 additions & 2 deletions src/app/backend/handler/apihandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,15 @@ func CreateHttpApiHandler(client *client.Client, heapsterClient HeapsterClient,
apiV1Ws.Route(
apiV1Ws.GET("/petset").
To(apiHandler.handleGetPetSetList).
Writes(resourceService.ServiceList{}))
Writes(petset.PetSetList{}))
apiV1Ws.Route(
apiV1Ws.GET("/petset/{namespace}").
To(apiHandler.handleGetPetSetList).
Writes(resourceService.ServiceList{}))
Writes(petset.PetSetList{}))
apiV1Ws.Route(
apiV1Ws.GET("/petset/{namespace}/{petset}").
To(apiHandler.handleGetPetSetDetail).
Writes(petset.PetSetDetail{}))

apiV1Ws.Route(
apiV1Ws.DELETE("/{kind}/namespace/{namespace}/name/{name}").
Expand All @@ -308,6 +312,20 @@ func (apiHandler *ApiHandler) handleGetPetSetList(request *restful.Request,
response.WriteHeaderAndEntity(http.StatusCreated, result)
}

// Handles get pet set detail API call.
func (apiHandler *ApiHandler) handleGetPetSetDetail(request *restful.Request,
response *restful.Response) {
namespace := request.PathParameter("namespace")
service := request.PathParameter("petset")
result, err := petset.GetPetSetDetail(apiHandler.client, apiHandler.heapsterClient,
namespace, service)
if err != nil {
handleInternalError(response, err)
return
}
response.WriteHeaderAndEntity(http.StatusCreated, result)
}

// Handles get service list API call.
func (apiHandler *ApiHandler) handleGetServiceList(request *restful.Request, response *restful.Response) {
namespace := parseNamespacePathParameter(request)
Expand Down
13 changes: 13 additions & 0 deletions src/app/backend/resource/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ func FilterPodsBySelector(pods []api.Pod, resourceSelector map[string]string) []
return matchingPods
}

func FilterNamespacedPodsByLabelSelector(pods []api.Pod, namespace string,
labelSelector *unversioned.LabelSelector) []api.Pod {

var matchingPods []api.Pod
for _, pod := range pods {
if pod.ObjectMeta.Namespace == namespace &&
IsLabelSelectorMatching(pod.Labels, labelSelector) {
matchingPods = append(matchingPods, pod)
}
}
return matchingPods
}

func FilterPodsByLabelSelector(pods []api.Pod, labelSelector *unversioned.LabelSelector) []api.Pod {

var matchingPods []api.Pod
Expand Down
6 changes: 3 additions & 3 deletions src/app/backend/resource/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ func IsSelectorMatching(labelSelector map[string]string,
return true
}

// Returns true when a resrouce (Service / Pod) with the given selector targets
// the same Pod (or itself) that a Daemon Set with the given selector.
// Returns true when a resource with the given selector targets the same Resources(or subset)
// that a tested object selector with the given selector.
func IsLabelSelectorMatching(selector map[string]string,
labelSelector *unversioned.LabelSelector) bool {

// If the resrouce has no selectors, then assume it targets different Pods.
// If the resource has no selectors, then assume it targets different Pods.
if len(selector) == 0 {
return false
}
Expand Down
96 changes: 96 additions & 0 deletions src/app/backend/resource/petset/petsetdetail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package petset

import (
"log"

"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/apps"
k8sClient "k8s.io/kubernetes/pkg/client/unversioned"

"github.com/kubernetes/dashboard/client"
"github.com/kubernetes/dashboard/resource/common"
"github.com/kubernetes/dashboard/resource/pod"
)

// PetSetDetail is a presentation layer view of Kubernetes Pet Set resource. This means
// it is Pet Set plus additional augmented data we can get from other sources
// (like services that target the same pods).
type PetSetDetail struct {
ObjectMeta common.ObjectMeta `json:"objectMeta"`
TypeMeta common.TypeMeta `json:"typeMeta"`

// Aggregate information about pods belonging to this Pet Set.
PodInfo common.PodInfo `json:"podInfo"`

// Detailed information about Pods belonging to this Pet Set.
PodList pod.PodList `json:"podList"`

// Container images of the Pet Set.
ContainerImages []string `json:"containerImages"`

// List of events related to this Pet Set.
EventList common.EventList `json:"eventList"`
}

// GetPetSetDetail gets pet set details.
func GetPetSetDetail(client *k8sClient.Client, heapsterClient client.HeapsterClient,
namespace, name string) (*PetSetDetail, error) {

log.Printf("Getting details of %s service in %s namespace", name, namespace)

// TODO(floreks): Use channels.
petSetData, err := client.Apps().PetSets(namespace).Get(name)
if err != nil {
return nil, err
}

channels := &common.ResourceChannels{
PodList: common.GetPodListChannel(client, common.NewSameNamespaceQuery(namespace), 1),
}

pods := <-channels.PodList.List
if err := <-channels.PodList.Error; err != nil {
return nil, err
}

events, err := GetPetSetEvents(client, petSetData.Namespace, petSetData.Name)
if err != nil {
return nil, err
}

petSet := getPetSetDetail(petSetData, heapsterClient, events, pods.Items)
return &petSet, nil
}

func getPetSetDetail(petSet *apps.PetSet, heapsterClient client.HeapsterClient,
events *common.EventList, pods []api.Pod) PetSetDetail {

matchingPods := common.FilterNamespacedPodsByLabelSelector(pods, petSet.ObjectMeta.Namespace,
petSet.Spec.Selector)

podInfo := common.GetPodInfo(int32(petSet.Status.Replicas), int32(petSet.Spec.Replicas),
matchingPods)

return PetSetDetail{
ObjectMeta: common.NewObjectMeta(petSet.ObjectMeta),
TypeMeta: common.NewTypeMeta(common.ResourceKindPetSet),
ContainerImages: common.GetContainerImages(&petSet.Spec.Template.Spec),
PodInfo: podInfo,
PodList: pod.CreatePodList(matchingPods, heapsterClient),
EventList: *events,
}
}
82 changes: 82 additions & 0 deletions src/app/backend/resource/petset/petsetevents.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package petset

import (
"log"

"github.com/kubernetes/dashboard/resource/common"
"github.com/kubernetes/dashboard/resource/event"

"k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned"
)

// GetPetSetEvents gets events associated to pet set.
func GetPetSetEvents(client *client.Client, namespace, petSetName string) (
*common.EventList, error) {

log.Printf("Getting events related to %s pet set in %s namespace", petSetName,
namespace)

// Get events for pet set.
rsEvents, err := event.GetEvents(client, namespace, petSetName)

if err != nil {
return nil, err
}

// Get events for pods in pet set.
podEvents, err := GetPetSetPodsEvents(client, namespace, petSetName)

if err != nil {
return nil, err
}

apiEvents := append(rsEvents, podEvents...)

if !event.IsTypeFilled(apiEvents) {
apiEvents = event.FillEventsType(apiEvents)
}

events := event.AppendEvents(apiEvents, common.EventList{
Namespace: namespace,
Events: make([]common.Event, 0),
})

log.Printf("Found %d events related to %s pet set in %s namespace",
len(events.Events), petSetName, namespace)

return &events, nil
}

// GetPetSetPodsEvents gets events associated to pods in pet set.
func GetPetSetPodsEvents(client *client.Client, namespace, petSetName string) (
[]api.Event, error) {

petSet, err := client.Apps().PetSets(namespace).Get(petSetName)

if err != nil {
return nil, err
}

podEvents, err := event.GetPodsEvents(client, namespace, petSet.Spec.Selector.MatchLabels)

if err != nil {
return nil, err
}

return podEvents, nil
}
4 changes: 2 additions & 2 deletions src/app/backend/resource/replicaset/replicasetdetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func GetReplicaSetDetail(client k8sClient.Interface, heapsterClient client.Heaps
func getReplicaSetDetail(replicaSet *extensions.ReplicaSet, heapsterClient client.HeapsterClient,
events *common.EventList, pods []api.Pod) ReplicaSetDetail {

matchingPods := common.FilterNamespacedPodsBySelector(pods, replicaSet.ObjectMeta.Namespace,
replicaSet.Spec.Selector.MatchLabels)
matchingPods := common.FilterNamespacedPodsByLabelSelector(pods, replicaSet.ObjectMeta.Namespace,
replicaSet.Spec.Selector)

podInfo := getPodInfo(replicaSet, matchingPods)

Expand Down
14 changes: 13 additions & 1 deletion src/app/externs/backendapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,23 @@ backendApi.ReplicaSetList;
* objectMeta: !backendApi.ObjectMeta,
* typeMeta: !backendApi.TypeMeta,
* pods: !backendApi.PodInfo,
* containerImages: !Array<string>,
* containerImages: !Array<string>
* }}
*/
backendApi.PetSet;

/**
* @typedef {{
* objectMeta: !backendApi.ObjectMeta,
* typeMeta: !backendApi.TypeMeta,
* podInfo: !backendApi.PodInfo,
* podList: !backendApi.PodList,
* containerImages: !Array<string>,
* eventList: !backendApi.EventList
* }}
*/
backendApi.PetSetDetail;

/**
* @typedef {{
* petSets: !Array<!backendApi.PetSet>
Expand Down
37 changes: 37 additions & 0 deletions src/app/frontend/petsetdetail/petsetdetail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
Copyright 2015 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<div layout="column">
<md-content>
<md-tabs md-border-bottom md-dynamic-height>
<md-tab label="{{::ctrl.i18n.MSG_PET_SET_DETAIL_OVERVIEW_TAB}}">
<kd-pet-set-info pet-set="::ctrl.petSetDetail"></kd-pet-set-info>

<kd-content-card>
<kd-title>{{::ctrl.i18n.MSG_PET_SET_DETAIL_PODS_CARD_TITLE}}</kd-title>
<kd-content>
<kd-pod-card-list pod-list="::ctrl.petSetDetail.podList"
logs-href-fn="::ctrl.getPodLogsHref(pod)" with-statuses="true">
</kd-pod-card-list>
</kd-content>
</kd-content-card>
</md-tab>
<md-tab label="{{::ctrl.i18n.MSG_PET_SET_DETAIL_EVENTS_TAB}}">
<kd-event-card-list events="::ctrl.petSetDetail.eventList.events"></kd-event-card-list>
</md-tab>
</md-tabs>
</md-content>
</div>
Loading