fix(shim): return cgroup v2 stats on unified hierarchy#12807
Open
a7i wants to merge 1 commit intogoogle:masterfrom
Open
fix(shim): return cgroup v2 stats on unified hierarchy#12807a7i wants to merge 1 commit intogoogle:masterfrom
a7i wants to merge 1 commit intogoogle:masterfrom
Conversation
Task Stats must marshal io.containerd.cgroups.v2.Metrics when the host uses unified cgroup v2, even if runsc uses cgroupfs (systemd-cgroup false). Otherwise containerd logs unmarshal v1.Metrics to v2.Metrics errors. Use cgroups.Mode() == Unified, consistent with OOM/cgroup setup in the same package. Add a test that v1 and v2 stats Any type URLs differ.
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.
Problem
On cgroup v2 (unified) hosts, containerd unmarshals task
Statsasio.containerd.cgroups.v2.Metrics. The runsc v2 shim was choosing v1 vs v2 protobuf layout only fromsystemd-cgroup, so with cgroupfs (systemd-cgroupfalse) it returned v1 metrics and containerd logged errors such as:I also realized that I hadn't set system-cgroup in the config so alternatively that would have fixed it
Fix
Use
cgroups.Mode() == cgroups.Unified(same signal as OOM / cgroup load in this package) to pickgetV2StatsvsgetV1Stats.Tests
TestTaskStatsProtobufTypeURLsasserts v1 and v2 marshal to distinct type URLs containingcgroups.v1/cgroups.v2.Risk
Low: stats wire format only; behavior aligns with host cgroup mode and containerd expectations.
Workaround (before this lands)
Run runsc with
systemd-cgroup=trueso the previous logic returns v2-shaped stats on affected nodes.