Add pod restart count to details pane

This commit is contained in:
Alfonso Acosta
2017-07-27 13:15:53 +00:00
parent 7e38069fc7
commit 3e4b3cbbf5
2 changed files with 14 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
package kubernetes
import (
"strconv"
"github.com/weaveworks/scope/report"
apiv1 "k8s.io/client-go/pkg/api/v1"
@@ -10,6 +12,7 @@ import (
const (
State = "kubernetes_state"
IsInHostNetwork = "kubernetes_is_in_host_network"
RestartCount = "kubernetes_restart_count"
StateDeleted = "deleted"
)
@@ -20,6 +23,7 @@ type Pod interface {
AddParent(topology, id string)
NodeName() string
GetNode(probeID string) report.Node
RestartCount() uint
}
type pod struct {
@@ -58,11 +62,20 @@ func (p *pod) NodeName() string {
return p.Spec.NodeName
}
func (p *pod) RestartCount() uint {
count := uint(0)
for _, cs := range p.Status.ContainerStatuses {
count += uint(cs.RestartCount)
}
return count
}
func (p *pod) GetNode(probeID string) report.Node {
latests := map[string]string{
State: p.State(),
IP: p.Status.PodIP,
report.ControlProbeID: probeID,
RestartCount: strconv.FormatUint(uint64(p.RestartCount()), 10),
}
if p.Pod.Spec.HostNetwork {

View File

@@ -32,6 +32,7 @@ var (
report.Container: {ID: report.Container, Label: "# Containers", From: report.FromCounters, Datatype: "number", Priority: 4},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 5},
Created: {ID: Created, Label: "Created", From: report.FromLatest, Datatype: "datetime", Priority: 6},
RestartCount: {ID: RestartCount, Label: "Restart #", From: report.FromLatest, Priority: 7},
}
PodMetricTemplates = docker.ContainerMetricTemplates