Run
每秒执行一次
func (n *nodeInfoCollector) Run(stopCh <-chan struct{
}) {
go wait.Until(n.collectNodeInfo, n.collectInterval, stopCh)
}
collectNodeInfo()
- 采集node cpu信息
- 采集node numa信息
func (n *nodeInfoCollector) collectNodeInfo() {
started := time.Now()
err := n.collectNodeCPUInfo()
if err != nil {
klog.Warningf("failed to collect node CPU info, err: %s", err)
return
}
err = n.collectNodeNUMAInfo()
if err != nil {
klog.Warningf("failed to collect node NUMA info, err: %s", err)
return
}
n.started.Store(true)
klog.V(4).Infof("collect node info finished, elapsed %s", time.Since(started).String())
}
collectNodeCPUInfo()
- 采集和组装NodeCpuInfo对象
- 缓存到key为node_cpu_info
- 记录到metric,
collect_node_cpu_info_status:status=successed
func (n *nodeInfoCollector) collectNodeCPUInfo() error {
klog.V(6).Info("start collect node cpu info")
localCPUInfo, err := koordletutil.GetLocalCPUInfo()
if err != nil {
metrics.RecordCollectNodeCPUInfoStatus(err)
return err
}
nodeCPUInfo := &metriccache.NodeCPUInfo{
BasicInfo: localCPUInfo.BasicInfo,
ProcessorInfos: localCPUInfo.ProcessorInfos,
TotalInfo: localCPUInfo.TotalInfo,
}
klog.V(6).Infof("collect cpu info finished, info: %+v", nodeCPUInfo)
n.storage.Set(metriccache.NodeCPUInfoKey, nodeCPUInfo)
klog.V(4).Infof("collectNodeCPUInfo finished, processors num %v", len(nodeCPUInfo.ProcessorInfos))
metrics.RecordCollectNodeCPUInfoStatus(nil