Skip to content

Commit

Permalink
pod_stats_collector: add missing memory allocations for default values
Browse files Browse the repository at this point in the history
also fixed a bug in swap stats where swap usage stat was
assigned with swap available bytes.

Signed-off-by: Igor Bezukh <[email protected]>
  • Loading branch information
enp0s3 committed Nov 21, 2024
1 parent 31791ca commit 9f5ed67
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/wasp/stats-collector/pod_stats_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 9f5ed67

Please sign in to comment.