kubelet/stats: fix pid stats for cadvisor stats provider

the process stats aren't correct coming from only the pod stats.
They need to be summed for all of the containers, as cadvisor
is only reading per pid (per container process)

Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
Peter Hunt 2024-03-28 12:41:54 -04:00
parent 7d8ba7849b
commit 5fd7219cf4

View File

@ -139,6 +139,8 @@ func (p *cadvisorStatsProvider) ListPodStats(_ context.Context) ([]statsapi.PodS
}
podStats.Containers = append(podStats.Containers, *containerStat)
}
// Either way, collect process stats
podStats.ProcessStats = mergeProcessStats(podStats.ProcessStats, cadvisorInfoToProcessStats(&cinfo))
}
// Add each PodStats to the result.
@ -154,7 +156,7 @@ func (p *cadvisorStatsProvider) ListPodStats(_ context.Context) ([]statsapi.PodS
podStats.CPU = cpu
podStats.Memory = memory
podStats.Swap = cadvisorInfoToSwapStats(podInfo)
podStats.ProcessStats = cadvisorInfoToProcessStats(podInfo)
// ProcessStats were accumulated as the containers were iterated.
}
status, found := p.statusProvider.GetPodStatus(podUID)