From 7cb19cd2ec85a62ffb7d59a0308756b344593043 Mon Sep 17 00:00:00 2001 From: jiangxin Date: Thu, 8 Jun 2023 14:45:40 +0800 Subject: [PATCH] fix gpu stats panic error (#769) --- ami/kube/kube_collect.go | 4 ++-- ami/native/native.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ami/kube/kube_collect.go b/ami/kube/kube_collect.go index c2eb8c3b..e27f43bc 100644 --- a/ami/kube/kube_collect.go +++ b/ami/kube/kube_collect.go @@ -153,12 +153,12 @@ func (k *kubeImpl) CollectNodeStats() (map[string]interface{}, error) { var nodeStatsMerge map[string]interface{} if len(gpuExts) > 0 { - if ext, ok := gpuExts[node.Name]; ok { + if ext, ok := gpuExts[node.Name]; ok && ext != nil { nodeStatsMerge = ext.(map[string]interface{}) } } if len(nodeExts) > 0 { - if ext, ok := nodeExts[node.Name]; ok { + if ext, ok := nodeExts[node.Name]; ok && ext != nil { if nodeStatsMerge == nil { nodeStatsMerge = make(map[string]interface{}, 0) } diff --git a/ami/native/native.go b/ami/native/native.go index 0660b802..70686997 100644 --- a/ami/native/native.go +++ b/ami/native/native.go @@ -827,7 +827,7 @@ func (impl *nativeImpl) CollectNodeStats() (map[string]interface{}, error) { } var nodeStatsMerge map[string]interface{} if len(gpuExts) > 0 { - if ext, ok := gpuExts[ho.Hostname]; ok { + if ext, ok := gpuExts[ho.Hostname]; ok && ext != nil { nodeStatsMerge = ext.(map[string]interface{}) } }