mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Add SwapStats to summary API through CRI
Signed-off-by: Itamar Holder <iholder@redhat.com>
This commit is contained in:
parent
87ff9c4525
commit
59e3e3897e
@ -206,6 +206,7 @@ func (p *criStatsProvider) listPodStatsPartiallyFromCRI(ctx context.Context, upd
|
||||
cs := p.makeContainerStats(stats, container, rootFsInfo, fsIDtoInfo, podSandbox.GetMetadata(), updateCPUNanoCoreUsage)
|
||||
p.addPodNetworkStats(ps, podSandboxID, caInfos, cs, containerNetworkStats[podSandboxID])
|
||||
p.addPodCPUMemoryStats(ps, types.UID(podSandbox.Metadata.Uid), allInfos, cs)
|
||||
p.addSwapStats(ps, types.UID(podSandbox.Metadata.Uid), allInfos, cs)
|
||||
p.addProcessStats(ps, types.UID(podSandbox.Metadata.Uid), allInfos, cs)
|
||||
|
||||
// If cadvisor stats is available for the container, use it to populate
|
||||
@ -548,6 +549,31 @@ func (p *criStatsProvider) addPodCPUMemoryStats(
|
||||
}
|
||||
}
|
||||
|
||||
func (p *criStatsProvider) addSwapStats(
|
||||
ps *statsapi.PodStats,
|
||||
podUID types.UID,
|
||||
allInfos map[string]cadvisorapiv2.ContainerInfo,
|
||||
cs *statsapi.ContainerStats,
|
||||
) {
|
||||
// try get cpu and memory stats from cadvisor first.
|
||||
podCgroupInfo := getCadvisorPodInfoFromPodUID(podUID, allInfos)
|
||||
if podCgroupInfo != nil {
|
||||
ps.Swap = cadvisorInfoToSwapStats(podCgroupInfo)
|
||||
return
|
||||
}
|
||||
|
||||
// Sum Pod cpu and memory stats from containers stats.
|
||||
if cs.Swap != nil {
|
||||
if ps.Swap == nil {
|
||||
ps.Swap = &statsapi.SwapStats{Time: cs.Swap.Time}
|
||||
}
|
||||
swapAvailableBytes := getUint64Value(cs.Swap.SwapAvailableBytes) + getUint64Value(ps.Swap.SwapAvailableBytes)
|
||||
swapUsageBytes := getUint64Value(cs.Swap.SwapUsageBytes) + getUint64Value(ps.Swap.SwapUsageBytes)
|
||||
ps.Swap.SwapAvailableBytes = &swapAvailableBytes
|
||||
ps.Swap.SwapUsageBytes = &swapUsageBytes
|
||||
}
|
||||
}
|
||||
|
||||
func (p *criStatsProvider) addProcessStats(
|
||||
ps *statsapi.PodStats,
|
||||
podUID types.UID,
|
||||
|
Loading…
Reference in New Issue
Block a user