devicemanager

package
v1.30.8 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 34 Imported by: 56

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 DeviceInstances added in v1.21.0

type DeviceInstances map[string]pluginapi.Device

DeviceInstances is a mapping device name -> plugin device data

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
	// The Annotations for the container
	Annotations []kubecontainer.Annotation
	// CDI Devices for the container
	CDIDevices []kubecontainer.CDIDevice
}

DeviceRunContainerOptions contains the combined container runtime settings to consume its allocated devices.

type Manager

type Manager interface {
	// Start starts device plugin registration service.
	Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady, initialContainers containermap.ContainerMap, initialContainerRunningSet sets.Set[string]) error

	// Allocate configures and assigns devices to a container in a pod. From
	// the requested device resources, Allocate will communicate with the
	// owning device plugin to allow setup procedures to take place, and for
	// the device plugin to provide runtime settings to use the device
	// (environment variables, mount points and device files).
	Allocate(pod *v1.Pod, container *v1.Container) error

	// UpdatePluginResources updates node resources based on devices already
	// allocated to pods. The node object is provided for the device manager to
	// update the node capacity to reflect the currently available devices.
	UpdatePluginResources(node *schedulerframework.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error

	// Stop stops the manager.
	Stop() 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, error)

	// GetCapacity returns the amount of available device plugin resource capacity, resource allocatable
	// and inactive device plugin resources previously registered on the node.
	GetCapacity() (v1.ResourceList, v1.ResourceList, []string)
	GetWatcherHandler() cache.PluginHandler

	// GetDevices returns information about the devices assigned to pods and containers
	GetDevices(podUID, containerName string) ResourceDeviceInstances

	// GetAllocatableDevices returns information about all the devices known to the manager
	GetAllocatableDevices() ResourceDeviceInstances

	// ShouldResetExtendedResourceCapacity returns whether the extended resources should be reset or not,
	// depending on the checkpoint file availability. Absence of the checkpoint file strongly indicates
	// the node has been recreated.
	ShouldResetExtendedResourceCapacity() bool

	// TopologyManager HintProvider provider indicates the Device Manager implements the Topology Manager Interface
	// and is consulted to make Topology aware resource alignments
	GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint

	// TopologyManager HintProvider provider indicates the Device Manager implements the Topology Manager Interface
	// and is consulted to make Topology aware resource alignments per Pod
	GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint

	// UpdateAllocatedDevices frees any Devices that are bound to terminated pods.
	UpdateAllocatedDevices()
}

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(topology []cadvisorapi.Node, topologyAffinityStore topologymanager.Store) (*ManagerImpl, error)

NewManagerImpl creates a new manager.

func (*ManagerImpl) Allocate

func (m *ManagerImpl) Allocate(pod *v1.Pod, container *v1.Container) error

Allocate is the call that you can use to allocate a set of devices from the registered device plugins.

func (*ManagerImpl) CleanupPluginDirectory added in v1.25.0

func (m *ManagerImpl) CleanupPluginDirectory(dir string) error

CleanupPluginDirectory is to remove all existing unix sockets from /var/lib/kubelet/device-plugins on Device Plugin Manager start

func (*ManagerImpl) GetAllocatableDevices added in v1.21.0

func (m *ManagerImpl) GetAllocatableDevices() ResourceDeviceInstances

GetAllocatableDevices returns information about all the healthy devices known to the manager

func (*ManagerImpl) GetCapacity

func (m *ManagerImpl) GetCapacity() (v1.ResourceList, v1.ResourceList, []string)

GetCapacity is expected to be called when Kubelet updates its node status. The first returned variable contains the registered device plugin resource capacity. The second returned variable contains the registered device plugin resource allocatable. The third returned variable contains previously registered resources that are no longer active. Kubelet uses this information to update resource capacity/allocatable in its node status. After the call, device plugin can remove the inactive resources from its internal list as the change is already reflected in Kubelet node status. Note in the special case after Kubelet restarts, device plugin resource capacities can temporarily drop to zero till corresponding device plugins re-register. This is OK because cm.UpdatePluginResource() run during predicate Admit guarantees we adjust nodeinfo capacity for already allocated pods so that they can continue to run. However, new pods requiring device plugin resources will not be scheduled till device plugin re-registers.

func (*ManagerImpl) GetDeviceRunContainerOptions

func (m *ManagerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) (*DeviceRunContainerOptions, 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.

func (*ManagerImpl) GetDevices added in v1.13.0

func (m *ManagerImpl) GetDevices(podUID, containerName string) ResourceDeviceInstances

GetDevices returns the devices used by the specified container

func (*ManagerImpl) GetPodTopologyHints added in v1.20.0

func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint

GetPodTopologyHints implements the topologymanager.HintProvider Interface which ensures the Device Manager is consulted when Topology Aware Hints for Pod are created.

func (*ManagerImpl) GetTopologyHints added in v1.16.0

func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint

GetTopologyHints implements the TopologyManager HintProvider Interface which ensures the Device Manager is consulted when Topology Aware Hints for each container are created.

func (*ManagerImpl) GetWatcherHandler added in v1.12.0

func (m *ManagerImpl) GetWatcherHandler() cache.PluginHandler

GetWatcherHandler returns the plugin handler

func (*ManagerImpl) PluginConnected added in v1.25.0

func (m *ManagerImpl) PluginConnected(resourceName string, p plugin.DevicePlugin) error

PluginConnected is to connect a plugin to a new endpoint. This is done as part of device plugin registration.

func (*ManagerImpl) PluginDisconnected added in v1.25.0

func (m *ManagerImpl) PluginDisconnected(resourceName string)

PluginDisconnected is to disconnect a plugin from an endpoint. This is done as part of device plugin deregistration.

func (*ManagerImpl) PluginListAndWatchReceiver added in v1.25.0

func (m *ManagerImpl) PluginListAndWatchReceiver(resourceName string, resp *pluginapi.ListAndWatchResponse)

PluginListAndWatchReceiver receives ListAndWatchResponse from a device plugin and ensures that an upto date state (e.g. number of devices and device health) is captured. Also, registered device and device to container allocation information is checkpointed to the disk.

func (*ManagerImpl) ShouldResetExtendedResourceCapacity added in v1.14.9

func (m *ManagerImpl) ShouldResetExtendedResourceCapacity() bool

ShouldResetExtendedResourceCapacity returns whether the extended resources should be zeroed or not, depending on whether the node has been recreated. Absence of the checkpoint file strongly indicates the node has been recreated.

func (*ManagerImpl) Start

func (m *ManagerImpl) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady, initialContainers containermap.ContainerMap, initialContainerRunningSet sets.Set[string]) error

Start starts the Device Plugin Manager and start initialization of podDevices and allocatedDevices information from checkpointed state and starts device plugin registration service.

func (*ManagerImpl) Stop

func (m *ManagerImpl) Stop() error

Stop is the function that can stop the plugin server. Can be called concurrently, more than once, and is safe to call without a prior Start.

func (*ManagerImpl) UpdateAllocatedDevices added in v1.16.11

func (m *ManagerImpl) UpdateAllocatedDevices()

UpdateAllocatedDevices frees any Devices that are bound to terminated pods.

func (*ManagerImpl) UpdatePluginResources added in v1.18.0

func (m *ManagerImpl) UpdatePluginResources(node *schedulerframework.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error

UpdatePluginResources updates node resources based on devices already allocated to pods.

type PodReusableDevices added in v1.18.0

type PodReusableDevices map[string]map[string]sets.Set[string]

PodReusableDevices is a map by pod name of devices to reuse.

type ResourceDeviceInstances added in v1.21.0

type ResourceDeviceInstances map[string]DeviceInstances

ResourceDeviceInstances is a mapping resource name -> DeviceInstances

func NewResourceDeviceInstances added in v1.21.0

func NewResourceDeviceInstances() ResourceDeviceInstances

NewResourceDeviceInstances returns a new ResourceDeviceInstances

func (ResourceDeviceInstances) Clone added in v1.21.0

Clone returns a clone of ResourceDeviceInstances

func (ResourceDeviceInstances) Filter added in v1.23.0

Filter takes a condition set expressed as map[string]sets.Set[string] and returns a new ResourceDeviceInstances with only the devices matching the condition set.

Directories

Path Synopsis
plugin

Jump to

Keyboard shortcuts

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