Skip to content

daemon: fix empty docker stats for Windows containerd runtime - #53101

Merged
vvoland merged 1 commit into
moby:masterfrom
rzlink:fix-windows-containerd-stats
Jul 24, 2026
Merged

vvoland merged 1 commit into
moby:masterfrom
rzlink:fix-windows-containerd-stats

Conversation

@rzlink

@rzlink rzlink commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

docker stats reported all zeros for running Windows containers under the
containerd runtime (io.containerd.runhcs.v1). The runhcs shim emits metrics
with the typeurl containerd.runhcs.stats.v1.Statistics, which the daemon
never registered, so typeurl.UnmarshalAny failed and an empty record was
returned. This is the failure reported in
#52913 (comment), and addresses
the "stats may be broken on Windows" blocker in #51643.

Changes

  • Import the hcsshim runhcs stats package so its proto init() registers the
    typeurl (go mod vendor pulls it from the vendored hcsshim v0.14.1).
  • Handle *wstats.Statistics in InterfaceToStats, converting it to the
    existing *hcsshim.Statistics shape (with ns→100ns scaling) so
    stats_windows.go is unchanged.
  • Un-skip TestStatsAllNoStream / TestStatsAllRunningNoStream and add a unit
    test for the conversion.

Testing

  • Unit test covers the conversion, ns→100ns scaling, and the nil payload.
  • Verified manually: docker stats now reports non-zero CPU/memory/block I/O
    on a containerd-runtime daemon.
  • Both un-skipped tests pass on Windows CI (graphdriver+containerd and
    snapshotter+containerd).

Release notes (optional)

Fix `docker stats` reporting all zeros for running Windows containers when using the containerd runtime.

@rzlink

rzlink commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@vvoland would you be able to review this? Thanks!

@vvoland

vvoland commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Thanks!

Could you also unskip the integration tests?

skip.If(t, testEnv.RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination")

@vvoland

vvoland commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Also, please rebase on top of latest master to fix the red CI

@vvoland vvoland added this to the 29.7.0 milestone Jul 20, 2026
@vvoland vvoland added the kind/bugfix PR's that fix bugs label Jul 20, 2026
@vvoland
vvoland self-requested a review July 20, 2026 14:52
@rzlink
rzlink force-pushed the fix-windows-containerd-stats branch from ebc07e9 to c63dd41 Compare July 20, 2026 18:08
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>
@rzlink
rzlink force-pushed the fix-windows-containerd-stats branch from c63dd41 to deef0ea Compare July 20, 2026 18:49
@rzlink

rzlink commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!

Could you also unskip the integration tests?

skip.If(t, testEnv.RuntimeIsWindowsContainerd(), "FIXME: Broken on Windows + containerd combination")

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?

@rzlink

rzlink commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Also, please rebase on top of latest master to fix the red CI

Thanks for the review! I've rebased on latest master to fix the red CI.

@rzlink

rzlink commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Also, please rebase on top of 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)?

@vvoland

vvoland commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Added the label, changelog entry is definitely good to have!

For TestStatsNetworkStats - haven't looked into it yet, but could we split it so that we run the part we already support and skip the network stats for now?

@rzlink

rzlink commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Added the label, changelog entry is definitely good to have!

For TestStatsNetworkStats - haven't looked into it yet, but could we split it so that we run the part we already support and skip the network stats for now?

TestStatsNetworkStats is stays skipped (it's wholly a network-stats test — ping + packet-count assertion — so there's no CPU/mem part to separate out).

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.

@vvoland vvoland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@vvoland
vvoland merged commit 883cbb8 into moby:master Jul 24, 2026
218 of 219 checks passed
@rzlink
rzlink deleted the fix-windows-containerd-stats branch July 24, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants