Repository navigation
daemon: fix empty docker stats for Windows containerd runtime - #53101
Conversation
|
@vvoland would you be able to review this? Thanks! |
|
Thanks! Could you also unskip the integration tests? moby/integration/container/stats_test.go Line 105 in 11ee7e0 |
|
Also, please rebase on top of latest master to fix the red CI |
ebc07e9 to
c63dd41
Compare
When the daemon uses the containerd runtime (io.containerd.runhcs.v1), the runhcs shim emits container metrics as the typeurl `containerd.runhcs.stats.v1.Statistics`. moby never imported the package that registers this type, so `typeurl.UnmarshalAny` failed with "type not found" and `docker stats` reported all zeros for running Windows containers. Import the hcsshim runhcs stats package so its proto init registers the typeurl, and handle `*wstats.Statistics` in `InterfaceToStats`, converting the Windows container statistics (processor time is reported in nanoseconds and converted to the 100ns units used by hcsshim.Statistics) into the shape consumed by stats_windows.go. Also replace the bare type assertion with a type switch so unexpected payloads no longer panic. Un-skip TestStatsAllNoStream and TestStatsAllRunningNoStream, and add a unit test for the conversion. Signed-off-by: Dawei Wei <wei.dawei.cn@gmail.com>
c63dd41 to
deef0ea
Compare
On un-skipping TestStatsNetworkStats : this PR fixes CPU/memory/storage but not network stats, which that test asserts. The runhcs shim's metrics ( WindowsContainerStatistics ) carry no network data, so Networks comes back empty on the containerd path. Sourcing network stats for the containerd path looks like a separate, non-trivial piece of work, so I'd prefer to keep it as a follow-up and keep this PR focused. The CPU/memory tests ( TestStatsAllNoStream , TestStatsAllRunningNoStream ) are un-skipped here and pass. Would you be OK with that split? |
Thanks for the review! I've rebased on latest master to fix the red CI. |
One thing I can't do myself: the only remaining red check is check-changelog , which wants an impact/ label whenever there's a changelog note. Could you add the appropriate impact/ label (or let me know if you'd rather I drop the release note)? |
|
Added the label, changelog entry is definitely good to have! For |
I went ahead and implemented the network-stats piece too and validated it end-to-end — I'll open it as a follow-up PR once this one lands. |
Summary
docker statsreported all zeros for running Windows containers under thecontainerd runtime (
io.containerd.runhcs.v1). The runhcs shim emits metricswith the typeurl
containerd.runhcs.stats.v1.Statistics, which the daemonnever registered, so
typeurl.UnmarshalAnyfailed and an empty record wasreturned. This is the failure reported in
#52913 (comment), and addresses
the "stats may be broken on Windows" blocker in #51643.
Changes
statspackage so its protoinit()registers thetypeurl (
go mod vendorpulls it from the vendored hcsshim v0.14.1).*wstats.StatisticsinInterfaceToStats, converting it to theexisting
*hcsshim.Statisticsshape (with ns→100ns scaling) sostats_windows.gois unchanged.TestStatsAllNoStream/TestStatsAllRunningNoStreamand add a unittest for the conversion.
Testing
docker statsnow reports non-zero CPU/memory/block I/Oon a containerd-runtime daemon.
snapshotter+containerd).
Release notes (optional)