package dra

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

Index

Types

type ActivePodsFunc

type ActivePodsFunc func() []*v1.Pod

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

type ClaimInfo

type ClaimInfo struct {
	state.ClaimInfoState
	// contains filtered or unexported fields
}

ClaimInfo holds information required to prepare and unprepare a resource claim. +k8s:deepcopy-gen=true

func (*ClaimInfo) DeepCopy

func (in *ClaimInfo) DeepCopy() *ClaimInfo

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClaimInfo.

func (*ClaimInfo) DeepCopyInto

func (in *ClaimInfo) DeepCopyInto(out *ClaimInfo)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ContainerInfo

type ContainerInfo struct {
	// CDI Devices for the container
	CDIDevices []kubecontainer.CDIDevice
}

ContainerInfo contains information required by the runtime to consume prepared resources.

type GetNodeFunc

type GetNodeFunc func() (*v1.Node, error)

GetNodeFunc is a function that returns the node object using the kubelet's node lister.

type Manager

type Manager interface {
	// GetWatcherHandler returns the plugin handler for the DRA.
	GetWatcherHandler() cache.PluginHandler

	// Start starts the reconcile loop of the manager.
	// This will ensure that all claims are unprepared even if pods get deleted unexpectedly.
	Start(ctx context.Context, activePods ActivePodsFunc, getNode GetNodeFunc, sourcesReady config.SourcesReady) error

	// PrepareResources prepares resources for a pod.
	// It communicates with the DRA resource plugin to prepare resources.
	PrepareResources(ctx context.Context, pod *v1.Pod) error

	// UnprepareResources calls NodeUnprepareResource GRPC from DRA plugin to unprepare pod resources
	UnprepareResources(ctx context.Context, pod *v1.Pod) error

	// GetResources gets a ContainerInfo object from the claimInfo cache.
	// This information is used by the caller to update a container config.
	GetResources(pod *v1.Pod, container *v1.Container) (*ContainerInfo, error)

	// PodMightNeedToUnprepareResources returns true if the pod with the given UID
	// might need to unprepare resources.
	PodMightNeedToUnprepareResources(UID types.UID) bool

	// GetContainerClaimInfos gets Container ClaimInfo objects
	GetContainerClaimInfos(pod *v1.Pod, container *v1.Container) ([]*ClaimInfo, error)
}

Manager manages all the DRA resource plugins running on a node.

type ManagerImpl

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

ManagerImpl is the structure in charge of managing DRA drivers.

func NewManagerImpl

func NewManagerImpl(kubeClient clientset.Interface, stateFileDirectory string, nodeName types.NodeName) (*ManagerImpl, error)

NewManagerImpl creates a new manager.

func (*ManagerImpl) GetContainerClaimInfos

func (m *ManagerImpl) GetContainerClaimInfos(pod *v1.Pod, container *v1.Container) ([]*ClaimInfo, error)

GetContainerClaimInfos gets Container's ClaimInfo

func (*ManagerImpl) GetResources

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

GetResources gets a ContainerInfo object from the claimInfo cache. This information is used by the caller to update a container config.

func (*ManagerImpl) GetWatcherHandler

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

func (*ManagerImpl) PodMightNeedToUnprepareResources

func (m *ManagerImpl) PodMightNeedToUnprepareResources(uid types.UID) bool

PodMightNeedToUnprepareResources returns true if the pod might need to unprepare resources

func (*ManagerImpl) PrepareResources

func (m *ManagerImpl) PrepareResources(ctx context.Context, pod *v1.Pod) error

PrepareResources attempts to prepare all of the required resources for the input container, issue NodePrepareResources rpc requests for each new resource requirement, process their responses and update the cached containerResources on success.

func (*ManagerImpl) Start

func (m *ManagerImpl) Start(ctx context.Context, activePods ActivePodsFunc, getNode GetNodeFunc, sourcesReady config.SourcesReady) error

Start starts the reconcile loop of the manager.

func (*ManagerImpl) UnprepareResources

func (m *ManagerImpl) UnprepareResources(ctx context.Context, pod *v1.Pod) error

UnprepareResources calls a driver's NodeUnprepareResource API for each resource claim owned by a pod. This function is idempotent and may be called multiple times against the same pod. As such, calls to the underlying NodeUnprepareResource API are skipped for claims that have already been successfully unprepared.

Source Files

claiminfo.go manager.go types.go zz_generated.deepcopy.go

Directories

PathSynopsis
pkg/kubelet/cm/dra/plugin
pkg/kubelet/cm/dra/state
Version
v1.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
23 packages
Last checked
3 hours ago

Tools for package owners.