From fa44b9ca150560683ecaa212b0886b619eae405f Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 28 Feb 2024 10:22:09 -0500 Subject: [PATCH] Fix panic in getNpdPodStat Signed-off-by: Davanum Srinivas --- test/e2e/node/node_problem_detector.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/e2e/node/node_problem_detector.go b/test/e2e/node/node_problem_detector.go index 4780768e903..0d487d19fbc 100644 --- a/test/e2e/node/node_problem_detector.go +++ b/test/e2e/node/node_problem_detector.go @@ -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 }