diff --git a/integration/client/container_linux_test.go b/integration/client/container_linux_test.go index a4a44bd27e6bf..50fdb7b9b2f8f 100644 --- a/integration/client/container_linux_test.go +++ b/integration/client/container_linux_test.go @@ -114,7 +114,7 @@ func TestTaskUpdate(t *testing.T) { if err != nil { t.Fatal(err) } - stat, err := cgroup2.Stat() + stat, err := cgroup2.StatFiltered(cgroupsv2.StatMemory) if err != nil { t.Fatal(err) } @@ -144,7 +144,7 @@ func TestTaskUpdate(t *testing.T) { } // check that the task has a limit of 64mb if cgroups.Mode() == cgroups.Unified { - stat, err := cgroup2.Stat() + stat, err := cgroup2.StatFiltered(cgroupsv2.StatMemory) if err != nil { t.Fatal(err) } diff --git a/integration/container_update_resources_test.go b/integration/container_update_resources_test.go index a489c48ff645a..8eb6cc0c28e77 100644 --- a/integration/container_update_resources_test.go +++ b/integration/container_update_resources_test.go @@ -78,7 +78,7 @@ func getCgroupSwapLimitForTask(t *testing.T, task containerd.Task) uint64 { if err != nil { t.Fatal(err) } - stat, err := cgroup2.Stat() + stat, err := cgroup2.StatFiltered(cgroupsv2.StatMemory) if err != nil { t.Fatal(err) } @@ -105,7 +105,7 @@ func getCgroupMemoryLimitForTask(t *testing.T, task containerd.Task) uint64 { if err != nil { t.Fatal(err) } - stat, err := cgroup2.Stat() + stat, err := cgroup2.StatFiltered(cgroupsv2.StatMemory) if err != nil { t.Fatal(err) } diff --git a/internal/cri/server/sandbox_stats_linux.go b/internal/cri/server/sandbox_stats_linux.go index 65ed106a69444..2954ddc757243 100644 --- a/internal/cri/server/sandbox_stats_linux.go +++ b/internal/cri/server/sandbox_stats_linux.go @@ -201,7 +201,7 @@ func cgroupMetricsForSandbox(sandbox sandboxstore.Sandbox) (*cgroupMetrics, erro if err != nil { return nil, fmt.Errorf("failed to load sandbox cgroup: %v: %w", cgroupPath, err) } - stats, err := cg.Stat() + stats, err := cg.StatFiltered(cgroupsv2.StatCPU | cgroupsv2.StatMemory) if err != nil { return nil, fmt.Errorf("failed to get stats for cgroup: %v: %w", cgroupPath, err) } diff --git a/internal/cri/server/stats_collector.go b/internal/cri/server/stats_collector.go index 706435b41a769..c89608f76e7b3 100644 --- a/internal/cri/server/stats_collector.go +++ b/internal/cri/server/stats_collector.go @@ -231,7 +231,7 @@ func (c *StatsCollector) getCgroupCPUUsage(ctx context.Context, cgroupPath strin log.G(ctx).WithError(err).Debugf("StatsCollector: failed to load cgroupv2: %s", cgroupPath) return 0, false } - stats, err := cg.Stat() + stats, err := cg.StatFiltered(cgroupsv2.StatCPU) if err != nil { log.G(ctx).WithError(err).Debugf("StatsCollector: failed to get cgroupv2 stats: %s", cgroupPath) return 0, false