kubernetes: k8s.io/kubernetes/pkg/kubelet/cm/devicemanager Index | Files | Directories

package devicemanager

import "k8s.io/kubernetes/pkg/kubelet/cm/devicemanager"

Index

Package Files

device_plugin_stub.go endpoint.go manager.go manager_stub.go pod_devices.go topology_hints.go types.go

type ActivePodsFunc Uses

type ActivePodsFunc func() []*v1.Pod

ActivePodsFunc is a function that returns a list of pods to reconcile.

type DeviceRunContainerOptions Uses

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
}

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

type Manager Uses

type Manager interface {
    // Start starts device plugin registration service.
    Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error

    // Allocate configures and assigns devices to pods. The pods are provided
    // through the pod admission attributes in the attrs argument. 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). The node object is provided
    // for the device manager to update the node capacity to reflect the
    // currently available devices.
    Allocate(node *schedulernodeinfo.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) []*podresourcesapi.ContainerDevices

    // 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
}

Manager manages all the Device Plugins running on a node.

type ManagerImpl Uses

type ManagerImpl struct {
    // contains filtered or unexported fields
}

ManagerImpl is the structure in charge of managing Device Plugins.

func NewManagerImpl Uses

func NewManagerImpl(numaNodeInfo cputopology.NUMANodeInfo, topologyAffinityStore topologymanager.Store) (*ManagerImpl, error)

NewManagerImpl creates a new manager.

func (*ManagerImpl) Allocate Uses

func (m *ManagerImpl) Allocate(node *schedulernodeinfo.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error

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

func (*ManagerImpl) DeRegisterPlugin Uses

func (m *ManagerImpl) DeRegisterPlugin(pluginName string)

DeRegisterPlugin deregisters the plugin TODO work on the behavior for deregistering plugins e.g: Should we delete the resource

func (*ManagerImpl) GetCapacity Uses

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 Uses

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 Uses

func (m *ManagerImpl) GetDevices(podUID, containerName string) []*podresourcesapi.ContainerDevices

GetDevices returns the devices used by the specified container

func (*ManagerImpl) GetTopologyHints Uses

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 Uses

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

GetWatcherHandler returns the plugin handler

func (*ManagerImpl) Register Uses

func (m *ManagerImpl) Register(ctx context.Context, r *pluginapi.RegisterRequest) (*pluginapi.Empty, error)

Register registers a device plugin.

func (*ManagerImpl) RegisterPlugin Uses

func (m *ManagerImpl) RegisterPlugin(pluginName string, endpoint string, versions []string) error

RegisterPlugin starts the endpoint and registers it TODO: Start the endpoint and wait for the First ListAndWatch call

before registering the plugin

func (*ManagerImpl) ShouldResetExtendedResourceCapacity Uses

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 Uses

func (m *ManagerImpl) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) 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 Uses

func (m *ManagerImpl) Stop() error

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

func (*ManagerImpl) ValidatePlugin Uses

func (m *ManagerImpl) ValidatePlugin(pluginName string, endpoint string, versions []string) error

ValidatePlugin validates a plugin if the version is correct and the name has the format of an extended resource

type ManagerStub Uses

type ManagerStub struct{}

ManagerStub provides a simple stub implementation for the Device Manager.

func NewManagerStub Uses

func NewManagerStub() (*ManagerStub, error)

NewManagerStub creates a ManagerStub.

func (*ManagerStub) Allocate Uses

func (h *ManagerStub) Allocate(node *schedulernodeinfo.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error

Allocate simply returns nil.

func (*ManagerStub) GetCapacity Uses

func (h *ManagerStub) GetCapacity() (v1.ResourceList, v1.ResourceList, []string)

GetCapacity simply returns nil capacity and empty removed resource list.

func (*ManagerStub) GetDeviceRunContainerOptions Uses

func (h *ManagerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) (*DeviceRunContainerOptions, error)

GetDeviceRunContainerOptions simply returns nil.

func (*ManagerStub) GetDevices Uses

func (h *ManagerStub) GetDevices(_, _ string) []*podresourcesapi.ContainerDevices

GetDevices returns nil

func (*ManagerStub) GetTopologyHints Uses

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

GetTopologyHints returns an empty TopologyHint map

func (*ManagerStub) GetWatcherHandler Uses

func (h *ManagerStub) GetWatcherHandler() cache.PluginHandler

GetWatcherHandler returns plugin watcher interface

func (*ManagerStub) ShouldResetExtendedResourceCapacity Uses

func (h *ManagerStub) ShouldResetExtendedResourceCapacity() bool

ShouldResetExtendedResourceCapacity returns false

func (*ManagerStub) Start Uses

func (h *ManagerStub) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error

Start simply returns nil.

func (*ManagerStub) Stop Uses

func (h *ManagerStub) Stop() error

Stop simply returns nil.

type Stub Uses

type Stub struct {
    // contains filtered or unexported fields
}

Stub implementation for DevicePlugin.

func NewDevicePluginStub Uses

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

NewDevicePluginStub returns an initialized DevicePlugin Stub.

func (*Stub) Allocate Uses

func (m *Stub) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error)

Allocate does a mock allocation

func (*Stub) GetDevicePluginOptions Uses

func (m *Stub) GetDevicePluginOptions(ctx context.Context, e *pluginapi.Empty) (*pluginapi.DevicePluginOptions, error)

GetDevicePluginOptions returns DevicePluginOptions settings for the device plugin.

func (*Stub) GetInfo Uses

func (m *Stub) GetInfo(ctx context.Context, req *watcherapi.InfoRequest) (*watcherapi.PluginInfo, error)

GetInfo is the RPC which return pluginInfo

func (*Stub) ListAndWatch Uses

func (m *Stub) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) error

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

func (*Stub) NotifyRegistrationStatus Uses

func (m *Stub) NotifyRegistrationStatus(ctx context.Context, status *watcherapi.RegistrationStatus) (*watcherapi.RegistrationStatusResponse, error)

NotifyRegistrationStatus receives the registration notification from watcher

func (*Stub) PreStartContainer Uses

func (m *Stub) PreStartContainer(ctx context.Context, r *pluginapi.PreStartContainerRequest) (*pluginapi.PreStartContainerResponse, error)

PreStartContainer resets the devices received

func (*Stub) Register Uses

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

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

func (*Stub) SetAllocFunc Uses

func (m *Stub) SetAllocFunc(f stubAllocFunc)

SetAllocFunc sets allocFunc of the device plugin

func (*Stub) Start Uses

func (m *Stub) Start() error

Start starts the gRPC server of the device plugin. Can only be called once.

func (*Stub) Stop Uses

func (m *Stub) Stop() error

Stop stops the gRPC server. Can be called without a prior Start and more than once. Not safe to be called concurrently by different goroutines!

func (*Stub) Update Uses

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

Update allows the device plugin to send new devices through ListAndWatch

Directories

PathSynopsis
checkpoint

Package devicemanager imports 35 packages (graph) and is imported by 27 packages. Updated 2019-11-17. Refresh now. Tools for package owners.