Skip to content

cpuload/netlink: report the real error and skip the reader on cgroup v2#3896

Merged
dims merged 2 commits into
google:masterfrom
dims:fix-netlink-cpuload
Jun 21, 2026
Merged

cpuload/netlink: report the real error and skip the reader on cgroup v2#3896
dims merged 2 commits into
google:masterfrom
dims:fix-netlink-cpuload

Conversation

@dims

@dims dims commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

--enable_load_reader breaks all container stats on cgroup v2 — CGROUPSTATS_CMD_GET is cgroup-v1-only, so the kernel returns EINVAL for every cgroup and updateStats aborts, leaving /metrics with only container_scrape_error. Root-cause analysis in #3137.

  • verifyHeader: pass &errno so an NLMSG_ERROR reports the real netlink error instead of masking it as "invalid type int32".
  • netlink.New(): detect the cgroup v2 unified hierarchy and fail cleanly, so the manager skips the reader instead of breaking all container stats.

This doesn't make cpu-load work on v2 (no cgroupstats equivalent; PSI is the path noted in #3137) — it removes the footgun. Verified on a v2 host: --enable_load_reader no longer drops /metrics to scrape-error-only.

dims added 2 commits June 20, 2026 17:31
verifyHeader passed errno to binary.Read by value instead of by pointer,
so binary.Read always failed with "invalid type int32" and masked the
actual netlink error code the kernel returned.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
CGROUPSTATS_CMD_GET (cgroupstats) is implemented only for cgroup v1: the
kernel's cgroupstats_build() rejects a cgroup v2 dentry with EINVAL, and
there is no v2 equivalent. Detect the unified hierarchy in New() and fail
with a clear message. The manager already logs that and runs without the
reader, so -enable_load_reader no longer aborts every container's stats
update on a v2 host (where /metrics previously served only
container_scrape_error).

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@dims dims force-pushed the fix-netlink-cpuload branch from 7f8b0c2 to f229c97 Compare June 20, 2026 21:32
@dims dims merged commit edf3223 into google:master Jun 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants