Check presence of mdev on allocation
This check should ensure we are not allocating
devices that did disapear.
@@ -184,6 +184,16 @@ func (dpi *MediatedDevicePlugin) Allocate(_ context.Context, r *pluginapi.Alloca
if mdevUUID, exist := dpi.iommuToMDEVMap[devID]; exist {
log.DefaultLogger().Infof("Allocate: got devID: %s for uuid: %s", devID, mdevUUID)
allocatedDevices = append(allocatedDevices, mdevUUID)
+
+ // Perform check that node didn't disappear
+ _, err := os.Stat(filepath.Join(dpi.deviceRoot, dpi.devicePath, devID))
+ if err != nil {
+ if os.IsNotExist(err) {
+ log.DefaultLogger().Errorf("Mediated device %s with id %s for resource %s disappeared", mdevUUID, devID, dpi.resourceName)
+ }
+ return resp, fmt.Errorf("Failed to allocate resource %s", dpi.resourceName)
+ }
+
formattedVFIO := formatVFIODeviceSpecs(devID)
log.DefaultLogger().Infof("Allocate: formatted vfio: %v", formattedVFIO)
deviceSpecs = append(deviceSpecs, formattedVFIO...)
