Adds DeviceMountablePlugin.CanDeviceMount check when retrieving plugins

This commit is contained in:
Vladimir Vivien
2019-03-28 10:39:32 -04:00
parent 1514bb2141
commit 3777514f83
15 changed files with 68 additions and 1 deletions

View File

@@ -241,6 +241,8 @@ type DeviceMountableVolumePlugin interface {
NewDeviceMounter() (DeviceMounter, error)
NewDeviceUnmounter() (DeviceUnmounter, error)
GetDeviceMountRefs(deviceMountPath string) ([]string, error)
// CanDeviceMount determines if device in volume.Spec is mountable
CanDeviceMount(spec *Spec) (bool, error)
}
// ExpandableVolumePlugin is an extended interface of VolumePlugin and is used for volumes that can be
@@ -902,7 +904,11 @@ func (pm *VolumePluginMgr) FindDeviceMountablePluginBySpec(spec *Spec) (DeviceMo
return nil, err
}
if deviceMountableVolumePlugin, ok := volumePlugin.(DeviceMountableVolumePlugin); ok {
return deviceMountableVolumePlugin, nil
if canMount, err := deviceMountableVolumePlugin.CanDeviceMount(spec); err != nil {
return nil, err
} else if canMount {
return deviceMountableVolumePlugin, nil
}
}
return nil, nil
}