Fix panic in getNpdPodStat

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas 2024-02-28 10:22:09 -05:00
parent 30a68e4ad4
commit fa44b9ca15
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59

View File

@ -384,9 +384,17 @@ func getNpdPodStat(ctx context.Context, f *framework.Framework, nodeName string)
if !strings.HasPrefix(pod.PodRef.Name, "node-problem-detector") {
continue
}
cpuUsage = float64(*pod.CPU.UsageNanoCores) * 1e-9
rss = float64(*pod.Memory.RSSBytes) / 1024 / 1024
workingSet = float64(*pod.Memory.WorkingSetBytes) / 1024 / 1024
if pod.CPU != nil && pod.CPU.UsageNanoCores != nil {
cpuUsage = float64(*pod.CPU.UsageNanoCores) * 1e-9
}
if pod.Memory != nil {
if pod.Memory.RSSBytes != nil {
rss = float64(*pod.Memory.RSSBytes) / 1024 / 1024
}
if pod.Memory.WorkingSetBytes != nil {
workingSet = float64(*pod.Memory.WorkingSetBytes) / 1024 / 1024
}
}
hasNpdPod = true
break
}