From b99495d1d945ea5fa68c6546f43cca8695f68834 Mon Sep 17 00:00:00 2001 From: Yuan Chen Date: Thu, 21 Oct 2021 13:42:59 -0700 Subject: [PATCH] Fix and improve comments on kubelet metrics --- pkg/kubelet/kubelet.go | 5 +++-- pkg/kubelet/metrics/metrics.go | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 6626c70465e..2cde907f57f 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -1542,7 +1542,7 @@ func (kl *Kubelet) syncPod(ctx context.Context, updateType kubetypes.SyncPodType defer klog.V(4).InfoS("syncPod exit", "pod", klog.KObj(pod), "podUID", pod.UID) // Latency measurements for the main workflow are relative to the - // first time the pod was seen by the API server. + // first time the pod was seen by kubelet. var firstSeenTime time.Time if firstSeenTimeStr, ok := pod.Annotations[kubetypes.ConfigFirstSeenAnnotationKey]; ok { firstSeenTime = kubetypes.ConvertToTimestamp(firstSeenTimeStr).Get() @@ -1601,7 +1601,8 @@ func (kl *Kubelet) syncPod(ctx context.Context, updateType kubetypes.SyncPodType } } - // Record the time it takes for the pod to become running. + // Record the time it takes for the pod to become running + // since kubelet first saw the pod if firstSeenTime is set. existingStatus, ok := kl.statusManager.GetPodStatus(pod.UID) if !ok || existingStatus.Phase == v1.PodPending && apiPodStatus.Phase == v1.PodRunning && !firstSeenTime.IsZero() { diff --git a/pkg/kubelet/metrics/metrics.go b/pkg/kubelet/metrics/metrics.go index 8b0a623d0e5..3ebef3b27d1 100644 --- a/pkg/kubelet/metrics/metrics.go +++ b/pkg/kubelet/metrics/metrics.go @@ -132,12 +132,13 @@ var ( }, []string{"operation_type"}, ) - // PodStartDuration is a Histogram that tracks the duration (in seconds) it takes for a single pod to go from pending to running. + // PodStartDuration is a Histogram that tracks the duration (in seconds) it takes for a single pod to run since it's + // first time seen by kubelet. PodStartDuration = metrics.NewHistogram( &metrics.HistogramOpts{ Subsystem: KubeletSubsystem, Name: PodStartDurationKey, - Help: "Duration in seconds for a single pod to go from pending to running.", + Help: "Duration in seconds from kubelet seeing a pod for the first time to the pod starting to run", Buckets: metrics.DefBuckets, StabilityLevel: metrics.ALPHA, }, @@ -154,12 +155,12 @@ var ( }, []string{"operation_type"}, ) - // PodWorkerStartDuration is a Histogram that tracks the duration (in seconds) it takes from seeing a pod to starting a worker. + // PodWorkerStartDuration is a Histogram that tracks the duration (in seconds) it takes from kubelet seeing a pod to starting a worker. PodWorkerStartDuration = metrics.NewHistogram( &metrics.HistogramOpts{ Subsystem: KubeletSubsystem, Name: PodWorkerStartDurationKey, - Help: "Duration in seconds from seeing a pod to starting a worker.", + Help: "Duration in seconds from kubelet seeing a pod to starting a worker.", Buckets: metrics.DefBuckets, StabilityLevel: metrics.ALPHA, },