Skip to content

Commit

Permalink
rank_utils: ignore pod containers whose cadviosr stats are not ready yet
Browse files Browse the repository at this point in the history
there might be a situation where pod ranking is done on a freshly created
pod whose containers stats are not yet ready in cadvisor.

Signed-off-by: Igor Bezukh <[email protected]>
  • Loading branch information
enp0s3 committed Nov 21, 2024
1 parent 7dc3122 commit 31791ca
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/wasp/pod-ranker/rank_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ func exceedMemoryLimits(summary summaryFunc) cmpFunc {
func hasContainerExceedMemoryLimits(pod *v1.Pod, summary stats_collector.PodSummary) bool {
for _, container := range pod.Spec.Containers {
if rQuantity, ok := container.Resources.Limits[v1.ResourceMemory]; ok {
memoryAndSwapSumQuantity := memoryAndSwapUsage(*summary.Containers[container.Name].MemoryWorkingSetBytes, *summary.Containers[container.Name].MemorySwapCurrentBytes)
containerStats, exists := summary.Containers[container.Name]
if !exists {
continue
}
memoryAndSwapSumQuantity :=
memoryAndSwapUsage(*containerStats.MemoryWorkingSetBytes, *containerStats.MemorySwapCurrentBytes)
if memoryAndSwapSumQuantity.Cmp(rQuantity) == 1 {
return true
}
Expand All @@ -143,7 +148,12 @@ func hasContainerExceedMemoryLimits(pod *v1.Pod, summary stats_collector.PodSumm

for _, container := range pod.Spec.InitContainers {
if rQuantity, ok := container.Resources.Limits[v1.ResourceMemory]; ok {
memoryAndSwapSumQuantity := memoryAndSwapUsage(*summary.Containers[container.Name].MemoryWorkingSetBytes, *summary.Containers[container.Name].MemorySwapCurrentBytes)
containerStats, exists := summary.Containers[container.Name]
if !exists {
continue
}
memoryAndSwapSumQuantity :=
memoryAndSwapUsage(*containerStats.MemoryWorkingSetBytes, *containerStats.MemorySwapCurrentBytes)
if memoryAndSwapSumQuantity.Cmp(rQuantity) == 1 {
return true
}
Expand Down

0 comments on commit 31791ca

Please sign in to comment.