fix(agent): emit blob download RPS metric even on failure#599
Merged
Anton-Kalpakchiev merged 2 commits intoApr 16, 2026
Conversation
sambhav-jain-16
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current QPS metric for agent downloads is in the ro_transferer's
Downloadmethod, which does not always get called on blob downloads. This PR moves it into the P2P scheduler'sDownloadmethod, which is always called when a blob is downloaded, unless there's a cache hit.Reasoning
Container runtimes (e.g. containerd) usually call the HEAD API on an image layer, before calling GET, for various reasons. However, agent has implemented its API, such that even the HEAD API triggers a P2P image download. This means that the HEAD API is blocked by agent downloading the full blob (might be 10+GB). If that blob download errors out or times out, containerd doesn't reach the GET API step, meaning that the QPS metric in the ro_transferer's Download method is never called, while kraken-agent started a blob download.
Emitting QPS in the scheduler instead of the transferer has 1 downside, which is that cache hits against the agent's disk cache do not emit the metric. I am making this trade-off consciously, as
I explored other approaches, where we emit the data in Stat, but containerd and dockerd are inconsistent with when they call HEAD and when they skip it, so such a metric would be unreliable and very bug-prone, so I opted for the simpler, error-free approach.