mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-14 06:06:12 +00:00
runtime: fix reading cgroup stats of sandboxes
The cgroup stats come from resourcecontrol package in the form of pointers
to structs. The sandbox Stat() method incorrectly was expecting structs.
This caused the cpu and memory stats to always be 0, which in turn caused
incorrect pod overhead metrics.
Fixes #8035
Signed-off-by: Peteris Rudzusiks <rye@stripe.com>
(cherry picked from commit 94e2ccc2d5
)
Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
parent
11e2f2a458
commit
668c8979f0
@ -1720,12 +1720,14 @@ func (s *Sandbox) Stats(ctx context.Context) (SandboxStats, error) {
|
||||
|
||||
// TODO Do we want to aggregate the overhead cgroup stats to the sandbox ones?
|
||||
switch mt := metrics.(type) {
|
||||
case v1.Metrics:
|
||||
case *v1.Metrics:
|
||||
stats.CgroupStats.CPUStats.CPUUsage.TotalUsage = mt.CPU.Usage.Total
|
||||
stats.CgroupStats.MemoryStats.Usage.Usage = mt.Memory.Usage.Usage
|
||||
case v2.Metrics:
|
||||
case *v2.Metrics:
|
||||
stats.CgroupStats.CPUStats.CPUUsage.TotalUsage = mt.CPU.UsageUsec
|
||||
stats.CgroupStats.MemoryStats.Usage.Usage = mt.Memory.Usage
|
||||
default:
|
||||
return SandboxStats{}, fmt.Errorf("unknown metrics type %T", mt)
|
||||
}
|
||||
|
||||
tids, err := s.hypervisor.GetThreadIDs(ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user