devicemanager

package
v1.6.112 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2023 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package devicemanager is used to manage device plugins

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c *Config) *manager

New returns a new device manager

func NoopAllStats

func NoopAllStats() []*device.DeviceGroupStats

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 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 (*MockManager) PluginType

func (m *MockManager) PluginType() string

func (*MockManager) Reserve

func (*MockManager) Run

func (m *MockManager) Run()

func (*MockManager) Shutdown

func (m *MockManager) Shutdown()

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

type UnknownDeviceError struct {
	Err    error
	Name   string
	Vendor string
	Type   string
	IDs    []string
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL