Merge pull request #123558 from dims/fix-panic-in-getNpdPodStat

Fix panic in getNpdPodStat
This commit is contained in:
Kubernetes Prow Robot 2024-02-28 08:54:07 -08:00 committed by GitHub
commit 756628b3a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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
}