From 9f5ed67de7d2efe76d1a8e0c198dd463300996fb Mon Sep 17 00:00:00 2001 From: Igor Bezukh Date: Thu, 21 Nov 2024 12:04:04 +0200 Subject: [PATCH] pod_stats_collector: add missing memory allocations for default values also fixed a bug in swap stats where swap usage stat was assigned with swap available bytes. Signed-off-by: Igor Bezukh --- pkg/wasp/stats-collector/pod_stats_collector.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/wasp/stats-collector/pod_stats_collector.go b/pkg/wasp/stats-collector/pod_stats_collector.go index 05dec2c9..7dec93fa 100644 --- a/pkg/wasp/stats-collector/pod_stats_collector.go +++ b/pkg/wasp/stats-collector/pod_stats_collector.go @@ -138,7 +138,7 @@ func (psc *PodStatsCollectorImpl) GetPodSummary(pod *v1.Pod) (PodSummary, error) summary.Containers[containerName] = ContainerSummary{ MemorySwapMaxBytes: cinfo.Spec.Memory.SwapLimit, MemoryWorkingSetBytes: containerStats.Memory.WorkingSetBytes, - MemorySwapCurrentBytes: containerStats.Swap.SwapAvailableBytes, + MemorySwapCurrentBytes: containerStats.Swap.SwapUsageBytes, } } } @@ -514,7 +514,9 @@ func cadvisorInfoToCPUandMemoryStats(info *cadvisorapiv2.ContainerInfo) (*statsa } else { memoryStats = &statsapi.MemoryStats{ Time: metav1.NewTime(cstat.Timestamp), + UsageBytes: uint64Ptr(0), WorkingSetBytes: uint64Ptr(0), + RSSBytes: uint64Ptr(0), } } return cpuStats, memoryStats @@ -555,6 +557,7 @@ func cadvisorInfoToSwapStats(info *cadvisorapiv2.ContainerInfo) *statsapi.SwapSt swapStats = &statsapi.SwapStats{ Time: metav1.NewTime(cstat.Timestamp), SwapUsageBytes: uint64Ptr(0), + SwapAvailableBytes: uint64Ptr(0) } }