deviceplugin

package
v1.10.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivePodsFunc

type ActivePodsFunc func() []*v1.Pod

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

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

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

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

type MonitorCallback func(resourceName string, added, updated, deleted []pluginapi.Device)

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

func NewDevicePluginStub(devs []*pluginapi.Device, socket string) *Stub

NewDevicePluginStub returns an initialized DevicePlugin Stub.

func (*Stub) Allocate

Allocate does a mock allocation

func (*Stub) ListAndWatch

ListAndWatch lists devices and update that list according to the Update call

func (*Stub) Register

func (m *Stub) Register(kubeletEndpoint, resourceName string) error

Register registers the device plugin for the given resourceName with Kubelet.

func (*Stub) Start

func (m *Stub) Start() error

Start starts the gRPC server of the device plugin

func (*Stub) Stop

func (m *Stub) Stop() error

Stop stops the gRPC server

func (*Stub) Update

func (m *Stub) Update(devs []*pluginapi.Device)

Update allows the device plugin to send new devices through ListAndWatch

Jump to

Keyboard shortcuts

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