V1Beta1 plugin interface has some optional interface members which are not supported with the current device-plugin-manager implementation. my plugin implements these, and my intent is to use PreStartContainer to do some setup of my devices before handing them off to the container.
func (p *MikeDevicePlugin) GetDevicePluginOptions(context.Context, *pluginapi.Empty) (*pluginapi.DevicePluginOptions, error) {
glog.Infof("GetDevicePluginOptions")
return &pluginapi.DevicePluginOptions {
PreStartRequired: true,
}, nil
}
func (p *MikeDevicePlugin) PreStartContainer(context.Context, *pluginapi.PreStartContainerRequest) (*pluginapi.PreStartContainerResponse, error) {
glog.Infof("PreStartContainer: %s", p.mikedevicename)
return &pluginapi.PreStartContainerResponse{}, nil
}
However the way device-plugin-manager is registering with pluginapi, it does not call GetDevicePluginOptions and pass those options during the registration, and because of this, my plugin's PreStartContainer function is never called from pluginapi.
I've fixed this in a fork by calling GetDevicePluginOptions in plugin.go and passing it as part of the RegisterRequest which now results in calls to PreStartContainer.
options, err := dpi.DevicePluginImpl.GetDevicePluginOptions(context.Background(), &pluginapi.Empty{})
reqt := &pluginapi.RegisterRequest{
Version: pluginapi.Version,
Endpoint: path.Base(dpi.Socket),
ResourceName: dpi.ResourceName,
Options: options,
}
I'd like this change to be considered and can prepare a PR if there are no objections.