mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
gpu: add log messages for not found cards
Let a user know the plugin can't find any Intel GPU if that's the case. It might be cumbersome to realize that the plugin runs on a host which doesn't have any Intel GPUs. Also make the code less nested for better readability.
This commit is contained in:
parent
b504c6b30e
commit
44ff734be6
@ -85,15 +85,23 @@ func (dp *devicePlugin) scan() (dpapi.DeviceTree, error) {
|
|||||||
|
|
||||||
devTree := dpapi.NewDeviceTree()
|
devTree := dpapi.NewDeviceTree()
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if dp.gpuDeviceReg.MatchString(f.Name()) {
|
var nodes []pluginapi.DeviceSpec
|
||||||
|
|
||||||
|
if !dp.gpuDeviceReg.MatchString(f.Name()) {
|
||||||
|
debug.Print("Not compatible device", f.Name())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
dat, err := ioutil.ReadFile(path.Join(dp.sysfsDir, f.Name(), "device/vendor"))
|
dat, err := ioutil.ReadFile(path.Join(dp.sysfsDir, f.Name(), "device/vendor"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("WARNING: Skipping. Can't read vendor file: ", err)
|
fmt.Println("WARNING: Skipping. Can't read vendor file: ", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.TrimSpace(string(dat)) == vendorString {
|
if strings.TrimSpace(string(dat)) != vendorString {
|
||||||
var nodes []pluginapi.DeviceSpec
|
debug.Print("Non-Intel GPU", f.Name())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
drmFiles, err := ioutil.ReadDir(path.Join(dp.sysfsDir, f.Name(), "device/drm"))
|
drmFiles, err := ioutil.ReadDir(path.Join(dp.sysfsDir, f.Name(), "device/drm"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -130,8 +138,6 @@ func (dp *devicePlugin) scan() (dpapi.DeviceTree, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return devTree, nil
|
return devTree, nil
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,20 @@ func TestScan(t *testing.T) {
|
|||||||
expectedDevs: 1,
|
expectedDevs: 1,
|
||||||
expectedErr: false,
|
expectedErr: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sysfsdirs: []string{"card0/device/drm/card0"},
|
||||||
|
sysfsfiles: map[string][]byte{
|
||||||
|
"card0/device/vendor": []byte("0xbeef"),
|
||||||
|
},
|
||||||
|
devfsdirs: []string{"card0"},
|
||||||
|
expectedDevs: 0,
|
||||||
|
expectedErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sysfsdirs: []string{"non_gpu_card"},
|
||||||
|
expectedDevs: 0,
|
||||||
|
expectedErr: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
testPlugin := newDevicePlugin(sysfs, devfs, 1)
|
testPlugin := newDevicePlugin(sysfs, devfs, 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user