Merge pull request #54 from zhenyw/gpu

gpu_plugin: skip drm control node
This commit is contained in:
Alexander D. Kanevskiy 2018-07-26 15:03:04 +03:00 committed by GitHub
commit 6c08dbdb64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,8 @@ import (
const (
sysfsDrmDirectory = "/sys/class/drm"
devfsDriDirectory = "/dev/dri"
gpuDeviceRE = `^card[0-9]*$`
gpuDeviceRE = `^card[0-9]+$`
controlDeviceRE = `^controlD[0-9]+$`
vendorString = "0x8086"
// Device plugin settings.
@ -58,6 +59,7 @@ func newDeviceManager() *deviceManager {
// Discovers all GPU devices available on the local node by walking `/sys/class/drm` directory.
func (dm *deviceManager) discoverGPUs(sysfsDrmDir string, devfsDriDir string) error {
reg := regexp.MustCompile(gpuDeviceRE)
ctlReg := regexp.MustCompile(controlDeviceRE)
files, err := ioutil.ReadDir(sysfsDrmDir)
if err != nil {
return fmt.Errorf("Can't read sysfs folder: %v", err)
@ -79,6 +81,10 @@ func (dm *deviceManager) discoverGPUs(sysfsDrmDir string, devfsDriDir string) er
}
for _, drmFile := range drmFiles {
if ctlReg.MatchString(drmFile.Name()) {
//Skipping possible drm control node
continue
}
devPath := path.Join(devfsDriDir, drmFile.Name())
if _, err := os.Stat(devPath); err != nil {
continue