fix(input.intel_pmt): Handle telem devices without numa_node attribute (#13977)

This commit is contained in:
Ben Allen 2023-09-26 05:03:39 -04:00 committed by GitHub
parent 8feba021ae
commit 9a95ef10cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -177,19 +177,21 @@ func (p *IntelPMT) explorePmtInSysfs() error {
continue
}
numaNodePath := filepath.Join(telemDirPath, "device", "numa_node")
numaNodeSymlink, err := filepath.EvalSymlinks(numaNodePath)
telemDevicePath := filepath.Join(telemDirPath, "device")
telemDeviceSymlink, err := filepath.EvalSymlinks(telemDevicePath)
if err != nil {
return fmt.Errorf("error while evaluating symlink %q: %w", numaNodePath, err)
return fmt.Errorf("error while evaluating symlink %q: %w", telemDeviceSymlink, err)
}
numaNode, err := os.ReadFile(numaNodeSymlink)
numaNodePath := filepath.Join(telemDeviceSymlink, "..", "numa_node")
numaNode, err := os.ReadFile(numaNodePath)
if err != nil {
return fmt.Errorf("error while reading symlink %q: %w", numaNodeSymlink, err)
return fmt.Errorf("error while reading numa_node file %q: %w", numaNodePath, err)
}
numaNodeString := strings.TrimSpace(string(numaNode))
if numaNodeString == "" {
return fmt.Errorf("numa_node file %q is empty", numaNodeSymlink)
return fmt.Errorf("numa_node file %q is empty", numaNodePath)
}
fi := fileInfo{