Merge pull request #979 from GLYASAI/slow-pod-list

拓扑图加载缓慢问题
This commit is contained in:
barnettZQG 2021-05-13 16:27:03 +08:00 committed by GitHub
commit 85409d5dce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1931,25 +1931,9 @@ func (s *ServiceAction) GetMultiServicePods(serviceIDs []string) (*K8sPodInfos,
podInfo.PodIP = v.PodIp
podInfo.PodStatus = v.PodStatus
podInfo.ServiceID = serviceID
containerInfos := make(map[string]map[string]string, 10)
for _, container := range v.Containers {
containerInfos[container.ContainerName] = map[string]string{
"memory_limit": fmt.Sprintf("%d", container.MemoryLimit),
"memory_usage": "0",
}
}
podInfo.Container = containerInfos
podNames = append(podNames, v.PodName)
podsInfoList = append(podsInfoList, &podInfo)
}
containerMemInfo, _ := s.GetPodContainerMemory(podNames)
for _, c := range podsInfoList {
for k := range c.Container {
if info, exist := containerMemInfo[c.PodName][k]; exist {
c.Container[k]["memory_usage"] = info
}
}
}
return podsInfoList
}
var re K8sPodInfos