baseplugin

package
v0.5.41 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GPUPluginStateFileName = "gpu_plugin_state"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePlugin

type BasePlugin struct {
	Conf *config.Configuration

	Emitter    metrics.MetricEmitter
	MetaServer *metaserver.MetaServer
	AgentCtx   *agent.GenericContext

	PodAnnotationKeptKeys []string
	PodLabelKeptKeys      []string

	// Registry of device topology providers
	DeviceTopologyRegistry *machine.DeviceTopologyRegistry

	// Registry of default resource state generators
	DefaultResourceStateGeneratorRegistry *state.DefaultResourceStateGeneratorRegistry
	// contains filtered or unexported fields
}

BasePlugin is a shared plugin that provides common functionalities and fields for GPU resource plugins and custom device plugins.

func NewBasePlugin

func NewBasePlugin(
	agentCtx *agent.GenericContext, conf *config.Configuration, wrappedEmitter metrics.MetricEmitter,
) (*BasePlugin, error)

func (*BasePlugin) GenerateMachineStateFromPodEntries

func (p *BasePlugin) GenerateMachineStateFromPodEntries(
	podResourceEntries state.PodResourceEntries,
) (state.AllocationResourcesMap, error)

func (*BasePlugin) GenerateResourceStateFromPodEntries

func (p *BasePlugin) GenerateResourceStateFromPodEntries(
	resourceName string,
	podEntries state.PodEntries,
) (state.AllocationMap, error)

GenerateResourceStateFromPodEntries returns an AllocationMap of a certain resource based on pod entries 1. If podEntries is nil, it will get pod entries from state 2. If the generator is not found, it will return an error

func (*BasePlugin) GetState

func (p *BasePlugin) GetState() state.State

GetState may return a nil state because the state is only initialized when InitState is called.

func (*BasePlugin) InitState

func (p *BasePlugin) InitState() error

InitState initializes the state of the plugin.

func (*BasePlugin) PackAllocationResponse

func (p *BasePlugin) PackAllocationResponse(
	req *pluginapi.ResourceRequest, allocationInfo *state.AllocationInfo,
	resourceAllocationAnnotations map[string]string, resourceName string,
) (*pluginapi.ResourceAllocationResponse, error)

func (*BasePlugin) RegisterDeviceNameToType

func (p *BasePlugin) RegisterDeviceNameToType(resourceNames []string, deviceType string)

RegisterDeviceNameToType is used to map device name to device type. For example, we may have multiple device names for a same device type, e.g. "nvidia.com/gpu" and "hw.com/npu", so we map them to the same device type, which allows us to allocate them interchangeably.

func (*BasePlugin) RegisterTopologyAffinityProvider

func (p *BasePlugin) RegisterTopologyAffinityProvider(
	deviceType string, deviceAffinityProvider machine.DeviceAffinityProvider,
)

RegisterTopologyAffinityProvider is a hook to set device affinity for a certain device type

func (*BasePlugin) ResolveResourceName

func (p *BasePlugin) ResolveResourceName(resourceName string, fallback bool) string

ResolveResourceName takes in a resourceName and tries to find a mapping of resource type from deviceNameToTypeMap. If no mapping is found, resourceName is returned if fallback is true. If fallback is false, an empty string is returned.

func (*BasePlugin) Run

func (p *BasePlugin) Run(stopCh <-chan struct{})

Run starts the asynchronous tasks of the plugin

func (*BasePlugin) SetState

func (p *BasePlugin) SetState(s state.State)

SetState sets the state only for unit testing purposes.

func (*BasePlugin) UpdateAllocatableAssociatedDevicesByDeviceType

func (p *BasePlugin) UpdateAllocatableAssociatedDevicesByDeviceType(
	request *pluginapi.UpdateAllocatableAssociatedDevicesRequest, deviceType string,
) (*pluginapi.UpdateAllocatableAssociatedDevicesResponse, error)

UpdateAllocatableAssociatedDevicesByDeviceType updates the topology provider with topology information of the given device type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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