Documentation ¶
Overview ¶
Package devicemanager is used to manage device plugins
Index ¶
- func New(c *Config) *manager
- func NoopAllStats() []*device.DeviceGroupStats
- func NoopDeviceStats(*structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error)
- func NoopReserve(*structs.AllocatedDeviceResource) (*device.ContainerReservation, error)
- type AllStatsFn
- type Config
- type DeviceStatsFn
- type Manager
- type MockManager
- func (m *MockManager) AllStats() []*device.DeviceGroupStats
- func (m *MockManager) DeviceStats(d *structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error)
- func (m *MockManager) PluginType() string
- func (m *MockManager) Reserve(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error)
- func (m *MockManager) Run()
- func (m *MockManager) Shutdown()
- type ReserveFn
- type StateStorage
- type StorePluginReattachFn
- type UnknownDeviceError
- type UpdateNodeDevicesFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoopAllStats ¶
func NoopAllStats() []*device.DeviceGroupStats
func NoopDeviceStats ¶
func NoopDeviceStats(*structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error)
func NoopReserve ¶
func NoopReserve(*structs.AllocatedDeviceResource) (*device.ContainerReservation, error)
Types ¶
type AllStatsFn ¶
type AllStatsFn func() []*device.DeviceGroupStats
type Config ¶
type Config struct { // Logger is the logger used by the device manager Logger log.Logger // Loader is the plugin loader Loader loader.PluginCatalog // PluginConfig is the config passed to the launched plugins PluginConfig *base.AgentConfig // Updater is used to update the node when device information changes Updater UpdateNodeDevicesFn // StatsInterval is the interval at which to collect statistics StatsInterval time.Duration // State is used to manage the device managers state State StateStorage }
Config is used to configure a device manager
type DeviceStatsFn ¶
type DeviceStatsFn func(d *structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error)
type Manager ¶
type Manager interface { pluginmanager.PluginManager // Reserve is used to reserve a set of devices Reserve(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error) // AllStats is used to retrieve all the latest statistics for all devices. AllStats() []*device.DeviceGroupStats // DeviceStats returns the device statistics for the given device. DeviceStats(d *structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error) }
Manager is the interface used to manage device plugins
type MockManager ¶
type MockManager struct { ReserveF ReserveFn AllStatsF AllStatsFn DeviceStatsF DeviceStatsFn }
func NoopMockManager ¶
func NoopMockManager() *MockManager
func (*MockManager) AllStats ¶
func (m *MockManager) AllStats() []*device.DeviceGroupStats
func (*MockManager) DeviceStats ¶
func (m *MockManager) DeviceStats(d *structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error)
func (*MockManager) PluginType ¶
func (m *MockManager) PluginType() string
func (*MockManager) Reserve ¶
func (m *MockManager) Reserve(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error)
func (*MockManager) Run ¶
func (m *MockManager) Run()
func (*MockManager) Shutdown ¶
func (m *MockManager) Shutdown()
type ReserveFn ¶
type ReserveFn func(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error)
type StateStorage ¶
type StateStorage interface { // GetDevicePluginState is used to retrieve the device manager's plugin // state. GetDevicePluginState() (*state.PluginState, error) // PutDevicePluginState is used to store the device manager's plugin // state. PutDevicePluginState(state *state.PluginState) error }
StateStorage is used to persist the device managers state across agent restarts.
type StorePluginReattachFn ¶
type StorePluginReattachFn func(*plugin.ReattachConfig) error
StorePluginReattachFn is used to store plugin reattachment configurations.
type UnknownDeviceError ¶
UnknownDeviceError is returned when an operation is attempted on an unknown device.
func NewUnknownDeviceError ¶
func NewUnknownDeviceError(err error, name, vendor, devType string, ids []string) *UnknownDeviceError
NewUnknownDeviceError returns a new UnknownDeviceError for the given device.
func UnknownDeviceErrFromAllocated ¶
func UnknownDeviceErrFromAllocated(err string, d *structs.AllocatedDeviceResource) *UnknownDeviceError
UnknownDeviceErrFromAllocated is a helper that returns an UnknownDeviceError populating it via the AllocatedDeviceResource struct.
func (*UnknownDeviceError) Error ¶
func (u *UnknownDeviceError) Error() string
Error returns an error formatting that reveals which unknown devices were requested
type UpdateNodeDevicesFn ¶
type UpdateNodeDevicesFn func(devices []*structs.NodeDeviceResource)
UpdateNodeDevices is a callback for updating the set of devices on a node.