diff --git a/pkg/ring-controller/agent/deploymentworker.go b/pkg/ring-controller/agent/deploymentworker.go index 69f830e33e15294fb3d8e83c508b1498247b07e4..04084522470e962251a1c073b400d502e8a6f88c 100644 --- a/pkg/ring-controller/agent/deploymentworker.go +++ b/pkg/ring-controller/agent/deploymentworker.go @@ -16,6 +16,7 @@ package agent import ( "fmt" + "sync" "time" "huawei.com/npu-exporter/v5/common-utils/hwlog" @@ -39,6 +40,7 @@ func NewDeploymentWorker(agent *BusinessAgent, deploy DeployInfo, ranktable rank configmapData: ranktable, statisticStopped: false, cachedPodNum: 0, + cachedPods: &sync.Map{}, taskReplicasTotal: replicasTotal, cachedIndex: newCachedIndex(int(replicasTotal)), }, diff --git a/pkg/ring-controller/agent/vcjobworker.go b/pkg/ring-controller/agent/vcjobworker.go index c9c820665f48ab200c50667fc3b7b76ed66f18ec..308626c35e7c13ceeb5aaef357044983ec37b734 100644 --- a/pkg/ring-controller/agent/vcjobworker.go +++ b/pkg/ring-controller/agent/vcjobworker.go @@ -460,7 +460,9 @@ func (b *WorkerInfo) handleDeleteEvent(podInfo *podIdentifier) error { b.cachedIndex.Store(rankIndex, false) } hwlog.RunLog.Infof("data of pod %s/%s is removed", podInfo.namespace, podInfo.name) - b.cachedPods.Delete(podInfo.uid) + if b.cachedPods != nil { + b.cachedPods.Delete(podInfo.uid) + } b.configmapData.DeletePod(podInfo.uid) b.modifyStatistics(-1) return nil