Documentation
¶
Index ¶
- type ActivePodsFunc
- type DeviceRunContainerOptions
- type Handler
- type HandlerImpl
- func (h *HandlerImpl) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
- func (h *HandlerImpl) Devices() map[string][]pluginapi.Device
- func (h *HandlerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
- func (h *HandlerImpl) Start(activePods ActivePodsFunc) error
- type HandlerStub
- func (h *HandlerStub) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
- func (h *HandlerStub) Devices() map[string][]pluginapi.Device
- func (h *HandlerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
- func (h *HandlerStub) Start(activePods ActivePodsFunc) error
- type Manager
- type ManagerImpl
- func (m *ManagerImpl) Allocate(resourceName string, devs []string) (*pluginapi.AllocateResponse, error)
- func (m *ManagerImpl) CheckpointFile() string
- func (m *ManagerImpl) Devices() map[string][]pluginapi.Device
- func (m *ManagerImpl) Register(ctx context.Context, r *pluginapi.RegisterRequest) (*pluginapi.Empty, error)
- func (m *ManagerImpl) Start() error
- func (m *ManagerImpl) Stop() error
- type MonitorCallback
- type Stub
- func (m *Stub) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error)
- func (m *Stub) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) error
- func (m *Stub) Register(kubeletEndpoint, resourceName string) error
- func (m *Stub) Start() error
- func (m *Stub) Stop() error
- func (m *Stub) Update(devs []*pluginapi.Device)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivePodsFunc ¶
ActivePodsFunc is a function that returns a list of pods to reconcile.
type DeviceRunContainerOptions ¶
type DeviceRunContainerOptions struct {
// The environment variables list.
Envs []kubecontainer.EnvVar
// The mounts for the container.
Mounts []kubecontainer.Mount
// The host devices mapped into the container.
Devices []kubecontainer.DeviceInfo
}
DeviceRunContainerOptions contains the combined container runtime settings to consume its allocated devices.
type Handler ¶
type Handler interface {
// Start starts device plugin registration service.
Start(activePods ActivePodsFunc) error
// Devices returns all of registered devices keyed by resourceName.
Devices() map[string][]pluginapi.Device
// Allocate scans through containers in the pod spec
// If it finds the container requires device plugin resource, it:
// 1. Checks whether it already has this information in its cached state.
// 2. If not, it calls Allocate and populate its cached state afterwards.
// 3. If there is no cached state and Allocate fails, it returns an error.
// 4. Otherwise, it updates allocatableResource in nodeInfo if necessary,
// to make sure it is at least equal to the pod's requested capacity for
// any registered device plugin resource
Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
// GetDeviceRunContainerOptions checks whether we have cached containerDevices
// for the passed-in <pod, container> and returns its DeviceRunContainerOptions
// for the found one. An empty struct is returned in case no cached state is found.
GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
}
Handler defines the functions used to manage and access device plugin resources.
type HandlerImpl ¶
type HandlerImpl struct {
// TODO: consider to change this to RWMutex.
sync.Mutex
// contains filtered or unexported fields
}
HandlerImpl implements the actual functionality to manage device plugin resources.
func NewHandlerImpl ¶
func NewHandlerImpl(updateCapacityFunc func(v1.ResourceList)) (*HandlerImpl, error)
NewHandlerImpl creates a HandlerImpl to manage device plugin resources. updateCapacityFunc is called to update ContainerManager capacity when device capacity changes.
func (*HandlerImpl) Allocate ¶
func (h *HandlerImpl) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
Allocate attempts to allocate all of required device plugin resources, and update Allocatable resources in nodeInfo if necessary
func (*HandlerImpl) Devices ¶
func (h *HandlerImpl) Devices() map[string][]pluginapi.Device
Devices returns all of registered devices keyed by resourceName.
func (*HandlerImpl) GetDeviceRunContainerOptions ¶
func (h *HandlerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
GetDeviceRunContainerOptions checks whether we have cached containerDevices for the passed-in <pod, container> and returns its DeviceRunContainerOptions for the found one. An empty struct is returned in case no cached state is found.
func (*HandlerImpl) Start ¶
func (h *HandlerImpl) Start(activePods ActivePodsFunc) error
Start initializes podDevices and allocatedDevices information from checkpoint-ed state and starts device plugin registration service.
type HandlerStub ¶
type HandlerStub struct{}
HandlerStub provides a simple stub implementation for Handler.
func NewHandlerStub ¶
func NewHandlerStub() (*HandlerStub, error)
NewHandlerStub creates a HandlerStub.
func (*HandlerStub) Allocate ¶
func (h *HandlerStub) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
Allocate simply returns nil.
func (*HandlerStub) Devices ¶
func (h *HandlerStub) Devices() map[string][]pluginapi.Device
Devices returns an empty map.
func (*HandlerStub) GetDeviceRunContainerOptions ¶
func (h *HandlerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
GetDeviceRunContainerOptions simply returns nil.
func (*HandlerStub) Start ¶
func (h *HandlerStub) Start(activePods ActivePodsFunc) error
Start simply returns nil.
type Manager ¶
type Manager interface {
// Start starts the gRPC Registration service.
Start() error
// Devices is the map of devices that have registered themselves
// against the manager.
// The map key is the ResourceName of the device plugins.
Devices() map[string][]pluginapi.Device
// Allocate takes resourceName and list of device Ids, and calls the
// gRPC Allocate on the device plugin matching the resourceName.
Allocate(string, []string) (*pluginapi.AllocateResponse, error)
// Stop stops the manager.
Stop() error
// Returns checkpoint file path.
CheckpointFile() string
}
Manager manages all the Device Plugins running on a node.
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
ManagerImpl is the structure in charge of managing Device Plugins.
func NewManagerImpl ¶
func NewManagerImpl(socketPath string, f MonitorCallback) (*ManagerImpl, error)
NewManagerImpl creates a new manager on the socket `socketPath`. f is the callback that is called when a device becomes unhealthy. socketPath is present for testing purposes in production this is pluginapi.KubeletSocket
func (*ManagerImpl) Allocate ¶
func (m *ManagerImpl) Allocate(resourceName string, devs []string) (*pluginapi.AllocateResponse, error)
Allocate is the call that you can use to allocate a set of devices from the registered device plugins.
func (*ManagerImpl) CheckpointFile ¶
func (m *ManagerImpl) CheckpointFile() string
CheckpointFile returns device plugin checkpoint file path.
func (*ManagerImpl) Devices ¶
func (m *ManagerImpl) Devices() map[string][]pluginapi.Device
Devices is the map of devices that are known by the Device Plugin manager with the kind of the devices as key
func (*ManagerImpl) Register ¶
func (m *ManagerImpl) Register(ctx context.Context, r *pluginapi.RegisterRequest) (*pluginapi.Empty, error)
Register registers a device plugin.
func (*ManagerImpl) Start ¶
func (m *ManagerImpl) Start() error
Start starts the Device Plugin Manager
func (*ManagerImpl) Stop ¶
func (m *ManagerImpl) Stop() error
Stop is the function that can stop the gRPC server.
type MonitorCallback ¶
MonitorCallback is the function called when a device's health state changes, or new devices are reported, or old devices are deleted. Updated contains the most recent state of the Device.
type Stub ¶
type Stub struct {
// contains filtered or unexported fields
}
Stub implementation for DevicePlugin.
func NewDevicePluginStub ¶
NewDevicePluginStub returns an initialized DevicePlugin Stub.
func (*Stub) Allocate ¶
func (m *Stub) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error)
Allocate does a mock allocation
func (*Stub) ListAndWatch ¶
ListAndWatch lists devices and update that list according to the Update call