Repository navigation
cri: exclude cached layer bytes from image_pulling_throughput_mibps - #13245
Conversation
There was a problem hiding this comment.
Pull request overview
Updates CRI image pulling throughput metrics so image_pulling_throughput reflects only bytes actually fetched from the registry (excluding cached layer bytes), avoiding inflated/near-infinite samples when pulls hit cache.
Changes:
- Plumbs
bytesPulled(bytes actually fetched) from both local-pull and transfer-service pull paths back toPullImage. - Records throughput using fetched bytes over end-to-end pull duration, skipping fully-cached pulls (
bytesPulled == 0). - Adds unit-test coverage for the new throughput recording helper.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/cri/server/images/metrics.go | Adds recordImagePullThroughput helper and updates metric HELP text. |
| internal/cri/server/images/image_pull.go | Returns bytesPulled from both pull implementations and uses it for throughput observation. |
| internal/cri/server/images/image_pull_test.go | Adds tests validating observation behavior and computed MB/s values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| prom "github.com/prometheus/client_golang/prometheus" | ||
| ) | ||
|
|
||
| const mbToByte = 1024 * 1024 |
There was a problem hiding this comment.
I know we had the same thing above in another file, but I agree with the robot. I'd prefer if this was mib, and any comments list as such as well.
|
This makes sense to me, only comments are on the wording of the units being used. |
|
@dcantah would readjusting the prometheus histogram buckets be considered a breaking change here or not? |
|
@ahmetb The existing one I would probably classify as breaking to change. We could add in a new one and "deprecate" the old I suppose: |
|
OK readjusted based on feedback.
I'm not sure how to coordinate the Release Notes/Deprecations process in this project, but probably both can coexist for a while. |
|
cc @dmcgowan as we'd talked about the prom buckets idea |
There was a problem hiding this comment.
LGTM, tested this version and metrics looks correct. Cached images were excluded from the results.
4 cold pulls and 3 warm pulls were reflected in calculation.
Pull throughput speeds calculated from (image size/pod startup time) matched with metric results.
$ curl localhost:16767/v1/metrics | grep image_pulls_total
containerd_cri_sandboxed_image_pulls_total{status="success"} 7
$ curl localhost:16767/v1/metrics | grep containerd_cri_sandboxed_image_pulling_throughput_count
containerd_cri_sandboxed_image_pulling_throughput_count 4
Pods scheduled on host:
22:57:21Z cold-pull
23:00:48Z warm-pull
23:04:44Z warm
23:04:45Z cold
23:04:45Z cold
23:31:08Z warm
23:33:11Z cold
|
/retest |
|
@ahmetb: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
Instructions 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-sigs/prow repository. |
|
@dcantah do you mind doing a /retest on this one? reviews appreciated too |
|
/ok-to-test |
|
/retest |
|
@dcantah do you know why the tests are not running? |
743e8ee to
f599ebb
Compare
|
please take a look again, it would be good to get this in sometime |
b60b759 to
df9a1b1
Compare
There was a problem hiding this comment.
⚠️ Not ready to approve
The transfer-service pull path can deadlock and/or fail to track bytes when image_pull_progress_timeout is configured as 0, and the metric HELP text currently omits the “includes extraction/unpack” duration semantics described in the PR.
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 3
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
| transferProgressReporter.start(rctx) | ||
| log.G(ctx).Debugf("Calling cri transfer service") | ||
| err = c.transferrer.Transfer(rctx, reg, is, transfer.WithProgress(transferProgressReporter.createProgressFunc(rctx))) |
There was a problem hiding this comment.
@ahmetb would you like to tackle this one? Seems a fair argument that this code had a potential config issue. https://github.com/containerd/containerd/blob/main/internal/cri/config/config.go#L544-L549 validation probably needs to be looked at. Some options: 1) report a warning, 2) error if duration is zero, 3) use default (5min) if set to 0, or some other minimum.
df9a1b1 to
f5d4b42
Compare
The image_pulling_throughput histogram divided the full image size (all layers plus config) by wall-clock pull duration. Layers already present in the content store were counted in the numerator, so the reported MB/s came out way higher than what was actually fetched. Fully-cached pulls were the worst case: they "pulled" in milliseconds but reported the full image size, showing up as huge outliers in the histogram. Both pull paths (local client.Pull and the transfer service) already maintain a totalBytesRead counter in pullRequestReporter for progress and timeout checks. Cached blobs never trigger a fetch, so the counter naturally excludes them. Plumb that value out of both helpers and use it in place of image.Size(ctx). Fully-cached pulls (bytesPulled == 0) are not observed, so they don't produce near-infinite samples. Also updates the metric's Help text to say the denominator is the end-to-end pull duration including layer extraction and snapshotter unpack, not just network transfer. Addresses containerd#13244 Signed-off-by: Ahmet Alp Balkan <[email protected]>
…hroughput Address review feedback on the previous commit: - Use MiB/s (binary, 1024^2) consistently. The divisor was already 1024*1024; the constant name (mbToByte) and the Help/comment text mislabeled the unit. - Keep image_pulling_throughput for backwards compatibility but mark it Deprecated. Its prom.DefBuckets top out at 10 MiB/s, which saturates almost immediately on modern hardware. - Add image_pulling_throughput_mibps with buckets covering 0.1 MiB/s through 4000 MiB/s (~31 Gbps), enough for 10G+ NICs. Above that, disk write throughput becomes the bottleneck rather than the network, so finer buckets aren't worth the cardinality. - Both metrics observe the same value (fetched bytes / pull duration, cached layers excluded; fully-cached pulls skipped). Only the buckets and deprecation status differ. Signed-off-by: Ahmet Alp Balkan <[email protected]>
f5d4b42 to
16ff70b
Compare
Addresses #13244.
image_pulling_throughputmetric currently calculatesfull image size / wall-clock pull duration. This inflates the metric when there are cached layers in the content store, and produces near-infinite data points for noop pulls.This change plumbs the bytes actually fetched (
totalBytesReadfrompullRequestReporter, which is already maintained for progress/timeout checks in both pull paths) out ofpullImageWithLocalPullandpullImageWithTransferService, and uses that in place ofimage.Size(ctx). Fully-cached pulls (bytesPulled == 0) are skipped.To prevent a breaking change in time-series buckets, we introduce a new
image_pulling_throughput_mibpsmetric; and deprecate theimage_pulling_throughput.Also updates the metric's
Helptext to note that the denominator spans the whole pull including extraction, not just network transfer.See #13244 for motivation and considered alternatives (zero-sample,
cachedlabel, ingester wrapper).