Commit 57d135e2 authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #19017 from yujuhong/relist_latency

Auto commit by PR queue bot
parents 9c5ede63 7d180b33
...@@ -35,6 +35,8 @@ const ( ...@@ -35,6 +35,8 @@ const (
DockerOperationsKey = "docker_operations_latency_microseconds" DockerOperationsKey = "docker_operations_latency_microseconds"
DockerErrorsKey = "docker_errors" DockerErrorsKey = "docker_errors"
PodWorkerStartLatencyKey = "pod_worker_start_latency_microseconds" PodWorkerStartLatencyKey = "pod_worker_start_latency_microseconds"
PLEGRelistLatencyKey = "pleg_relist_latency_microseconds"
PLEGRelistIntervalKey = "pleg_relist_interval_microseconds"
) )
var ( var (
...@@ -105,6 +107,20 @@ var ( ...@@ -105,6 +107,20 @@ var (
}, },
[]string{"operation_type"}, []string{"operation_type"},
) )
PLEGRelistLatency = prometheus.NewSummary(
prometheus.SummaryOpts{
Subsystem: KubeletSubsystem,
Name: PLEGRelistLatencyKey,
Help: "Latency in microseconds for relisting pods in PLEG.",
},
)
PLEGRelistInterval = prometheus.NewSummary(
prometheus.SummaryOpts{
Subsystem: KubeletSubsystem,
Name: PLEGRelistIntervalKey,
Help: "Interval in microseconds between relisting in PLEG.",
},
)
) )
var registerMetrics sync.Once var registerMetrics sync.Once
...@@ -123,6 +139,8 @@ func Register(containerCache kubecontainer.RuntimeCache) { ...@@ -123,6 +139,8 @@ func Register(containerCache kubecontainer.RuntimeCache) {
prometheus.MustRegister(ContainersPerPodCount) prometheus.MustRegister(ContainersPerPodCount)
prometheus.MustRegister(DockerErrors) prometheus.MustRegister(DockerErrors)
prometheus.MustRegister(newPodAndContainerCollector(containerCache)) prometheus.MustRegister(newPodAndContainerCollector(containerCache))
prometheus.MustRegister(PLEGRelistLatency)
prometheus.MustRegister(PLEGRelistInterval)
}) })
} }
......
...@@ -22,6 +22,7 @@ import ( ...@@ -22,6 +22,7 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
) )
...@@ -50,6 +51,8 @@ type GenericPLEG struct { ...@@ -50,6 +51,8 @@ type GenericPLEG struct {
eventChannel chan *PodLifecycleEvent eventChannel chan *PodLifecycleEvent
// The internal cache for container information. // The internal cache for container information.
containers map[string]containerInfo containers map[string]containerInfo
// Time of the last relisting.
lastRelistTime time.Time
} }
type containerInfo struct { type containerInfo struct {
...@@ -101,6 +104,17 @@ func generateEvent(podID types.UID, cid string, oldState, newState kubecontainer ...@@ -101,6 +104,17 @@ func generateEvent(podID types.UID, cid string, oldState, newState kubecontainer
// with the internal pods/containers, and generats events accordingly. // with the internal pods/containers, and generats events accordingly.
func (g *GenericPLEG) relist() { func (g *GenericPLEG) relist() {
glog.V(5).Infof("GenericPLEG: Relisting") glog.V(5).Infof("GenericPLEG: Relisting")
timestamp := time.Now()
if !g.lastRelistTime.IsZero() {
metrics.PLEGRelistInterval.Observe(metrics.SinceInMicroseconds(g.lastRelistTime))
}
defer func() {
// Update the relist time.
g.lastRelistTime = timestamp
metrics.PLEGRelistLatency.Observe(metrics.SinceInMicroseconds(timestamp))
}()
// Get all the pods. // Get all the pods.
pods, err := g.runtime.GetPods(true) pods, err := g.runtime.GetPods(true)
if err != nil { if err != nil {
......
...@@ -74,6 +74,12 @@ var KnownKubeletMetrics = map[string][]string{ ...@@ -74,6 +74,12 @@ var KnownKubeletMetrics = map[string][]string{
"kubelet_generate_pod_status_latency_microseconds": {"quantile"}, "kubelet_generate_pod_status_latency_microseconds": {"quantile"},
"kubelet_generate_pod_status_latency_microseconds_count": {}, "kubelet_generate_pod_status_latency_microseconds_count": {},
"kubelet_generate_pod_status_latency_microseconds_sum": {}, "kubelet_generate_pod_status_latency_microseconds_sum": {},
"kubelet_pleg_relist_latency_microseconds": {"quantile"},
"kubelet_pleg_relist_latency_microseconds_sum": {},
"kubelet_pleg_relist_latency_microseconds_count": {},
"kubelet_pleg_relist_interval_microseconds": {"quantile"},
"kubelet_pleg_relist_interval_microseconds_sum": {},
"kubelet_pleg_relist_interval_microseconds_count": {},
"kubelet_pod_start_latency_microseconds": {"quantile"}, "kubelet_pod_start_latency_microseconds": {"quantile"},
"kubelet_pod_start_latency_microseconds_count": {}, "kubelet_pod_start_latency_microseconds_count": {},
"kubelet_pod_start_latency_microseconds_sum": {}, "kubelet_pod_start_latency_microseconds_sum": {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment