deviceplugins

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AttributeMediaExtensions indicates the MIG profile supports media
	// extensions. This mirrors the upstream constant used in the older
	// controller implementation.
	AttributeMediaExtensions = "me"
)

Variables

This section is empty.

Functions

func BuildCDIDevices

func BuildCDIDevices(kind, sanitizedClass, id string, annotations map[string]string, envVar string) (*cdispec.Spec, string, string, []*pluginapi.CDIDevice)

BuildCDIDevices builds a CDI spec and returns the spec object, spec name, spec path, and the corresponding CDIDevice slice. This helper is exported so that other packages (and tests) can generate CDI specs in a consistent way.

func EnsureNvmlInitialized

func EnsureNvmlInitialized() error

EnsureNvmlInitialized initializes NVML only once. Subsequent calls return the initialization result from the first attempt.

func ShutdownNvml

func ShutdownNvml()

ShutdownNvml shuts down NVML the first time it is called. It can be safely deferred from multiple places.

func StartDevicePlugins

func StartDevicePlugins(ctx context.Context, kubeConfig *rest.Config) error

StartDevicePlugins starts device managers, gRPC servers, and registrars for each resource.

func UpdateAllocationStatus

func UpdateAllocationStatus(ctx context.Context, client versioned.Interface, alloc *instav1.AllocationClaim, status instav1.AllocationClaimState) (*instav1.AllocationClaim, error)

UpdateAllocationStatus safely updates the status of the given AllocationClaim using the provided client while holding the allocation mutex. This prevents multiple goroutines from updating the same object concurrently.

func WriteCDISpecForResource

func WriteCDISpecForResource(resourceName string, id string, annotations map[string]string, envVar string) (string, []*pluginapi.CDIDevice, error)

WriteCDISpecForResource parses the given resource name, generates a CDI spec using BuildCDIDevices and writes it to the CDI cache. It returns the path to the written spec along with the generated CDIDevices.

Types

type EmulatedMigGpuDiscoverer

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

EmulatedMigGpuDiscoverer implements MigGpuDiscoverer for emulated mode.

func (*EmulatedMigGpuDiscoverer) Discover

type Manager

type Manager struct {
	// ResourceName is the extended-resource string (e.g. "mig.das.com/1g.5gb").
	ResourceName string
	// contains filtered or unexported fields
}

Manager tracks and monitors devices for a specific extended-resource. It drives discovery and health monitoring and pushes device updates.

func NewManager

func NewManager(resourceName string, resources instav1.DiscoveredNodeResources) *Manager

NewManager creates a Manager for the given extended-resource name.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start begins device discovery and health monitoring, pushing initial updates and then running until the context is done.

func (*Manager) Updates

func (m *Manager) Updates() <-chan []*pluginapi.Device

Updates returns a channel that emits the latest available devices for ListAndWatch.

type MigGpuDiscoverer

type MigGpuDiscoverer interface {
	Discover() (*instav1.NodeAccelerator, error)
}

MigGpuDiscoverer is an interface for MIG GPU discovery implementations. Discover returns the NodeAccelerator object containing the discovered resources for the node.

type MigProfile

type MigProfile struct {
	C              int
	G              int
	GB             int
	GIProfileID    int
	CIProfileID    int
	CIEngProfileID int
}

MigProfile represents a MIG profile in a human readable format. The NVML library provides integer identifiers which are cumbersome to work with directly.

func NewMigProfile

func NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, giSliceCount, ciSliceCount uint32, migMemorySizeMB, totalDeviceMemoryBytes uint64) *MigProfile

NewMigProfile constructs a new MigProfile using details from the GPU and compute instance profiles.

func (MigProfile) Attributes

func (m MigProfile) Attributes() []string

Attributes returns any attribute strings associated with this profile.

func (MigProfile) String

func (m MigProfile) String() string

String returns the canonical string representation of the MIG profile, e.g. "1g.5gb".

type RealMigGpuDiscoverer

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

RealMigGpuDiscoverer implements MigGpuDiscoverer for real hardware.

func (*RealMigGpuDiscoverer) Discover

type Registrar

type Registrar struct {
	SocketPath   string
	ResourceName string
}

Registrar handles registration of a device-plugin socket with the kubelet.

func NewRegistrar

func NewRegistrar(socketPath, resourceName string) *Registrar

NewRegistrar constructs a Registrar for the given socket and resource.

func (*Registrar) Start

func (r *Registrar) Start(ctx context.Context)

Start registers the device plugin with the kubelet until the context is done.

type Server

type Server struct {
	pluginapi.UnimplementedDevicePluginServer
	Manager          *Manager
	SocketPath       string
	InstasliceClient instaclient.Interface
	KubeClient       kubernetes.Interface
	DynamicClient    dynamic.Interface
	NodeName         string
	EmulatedMode     instav1.EmulatedMode
	// contains filtered or unexported fields
}

func NewServer

func NewServer(mgr *Manager, socketPath string, kubeConfig *rest.Config, emulatedMode instav1.EmulatedMode) (*Server, error)

func (*Server) Allocate

func (*Server) GetDevicePluginOptions

func (s *Server) GetDevicePluginOptions(ctx context.Context, req *pluginapi.Empty) (*pluginapi.DevicePluginOptions, error)

GetDevicePluginOptions returns the options supported by the device plugin.

func (*Server) ListAndWatch

func (s *Server) ListAndWatch(req *pluginapi.Empty, stream pluginapi.DevicePlugin_ListAndWatchServer) error

ListAndWatch streams the list of devices, sending initial list and subsequent updates.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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