kubelet: Record a metric for latency of pod status update#107896
Conversation
e4c2b6c to
ad00f6e
Compare
2b89a36 to
5cf4fb7
Compare
e4d7d0a to
7e3c31a
Compare
|
/remove-sig api-machinery |
|
/assign @dashpole /triage accepted /remove-kind api-change bug |
| } else { | ||
| duration = time.Now().Sub(status.at).Truncate(time.Millisecond) | ||
| } | ||
| metrics.PodStatusSyncDuration.WithLabelValues(strconv.Itoa(0)).Observe(duration.Seconds()) |
There was a problem hiding this comment.
Should we only observe a duration if status.at was non-zero?
There was a problem hiding this comment.
Good question, it's typically an indicator that something unexpected happened, but it would skew the numbers. Let me review.
There was a problem hiding this comment.
I'll only observe if it's set, and then verify there are no wierd cases where a synthetic status is created that somehow escapes time (can't be 100% sure, but log observation in runs should be sufficient).
| podNamespace: pod.Namespace, | ||
| } | ||
|
|
||
| if cachedStatus.at.IsZero() { |
There was a problem hiding this comment.
This happens only when when we don't have a cached status in podStatuses, right?
There was a problem hiding this comment.
Correct, which I'm not actually sure can happen except during some sort of invalidation. Will look though.
There was a problem hiding this comment.
Also during Kubelet restarts we will have a clean cache in status manager until every pod worker has started up and invoked SetPodStatus at least once.
| if cachedStatus.at.IsZero() { | ||
| newStatus.at = time.Now() | ||
| } else { | ||
| newStatus.at = cachedStatus.at |
There was a problem hiding this comment.
This essentially ensures we measure the longest outstanding status update for a pod, right? E.g. if multiple status updates end up batched, we want to measure how long it took from the first update.
Can you add a brief comment?
| Buckets: []float64{0.010, 0.050, 0.100, 0.500, 1, 5, 10, 20, 30, 45, 60}, | ||
| StabilityLevel: metrics.ALPHA, | ||
| }, | ||
| []string{"priority"}, |
There was a problem hiding this comment.
I assume you have a good reason for wanting to breakdown by priority :). Can you document that in the PR description?
There was a problem hiding this comment.
Priority was a follow on concept I was testing (some status updates like transition from unready to ready or running to failed are "more important" than updates like a container message being propagated).
I'll remove it from this PR and introduce it as a separate commit in a subsequent PR.
|
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
|
/remove-sig auth |
|
@smarterclayton: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Track how long it takes for pod updates to propagate from detection to successful change on API server. Will guide future improvements in pod start and shutdown latency. Metric is `kubelet_pod_status_sync_duration_seconds` and is ALPHA stability. Histogram buckets are chosen based on distribution of observed status delays in practice.
|
Ok, I think this is ready for re-review with all comments addressed, PTAL when you have the chance. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BinacsLee, dashpole, smarterclayton The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Track how long it takes for pod updates to propagate from detection to successful change on API server. Will guide future improvements in pod start and shutdown latency. Currently pod status updates have been observed to take 30s or more to propagate to the apiserver even on underutilized nodes, and this metric will help quantify the level of latency for status syncs and help identify the need for improvements.
What type of PR is this?
/kind bug
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: