Documentation
¶
Index ¶
- Constants
- type BasePlugin
- func (p *BasePlugin) GenerateMachineStateFromPodEntries(podResourceEntries state.PodResourceEntries) (state.AllocationResourcesMap, error)
- func (p *BasePlugin) GenerateResourceStateFromPodEntries(resourceName string, podEntries state.PodEntries) (state.AllocationMap, error)
- func (p *BasePlugin) GetState() state.State
- func (p *BasePlugin) InitState() error
- func (p *BasePlugin) PackAllocationResponse(req *pluginapi.ResourceRequest, allocationInfo *state.AllocationInfo, ...) (*pluginapi.ResourceAllocationResponse, error)
- func (p *BasePlugin) RegisterDeviceNames(deviceNames []string, deviceType string)
- func (p *BasePlugin) RegisterTopologyAffinityProvider(deviceNames []string, deviceAffinityProvider machine.DeviceAffinityProvider)
- func (p *BasePlugin) ResolveResourceName(resourceName string, fallback bool) string
- func (p *BasePlugin) Run(stopCh <-chan struct{})
- func (p *BasePlugin) SetState(s state.State)
- func (p *BasePlugin) TriggerReporter()
- func (p *BasePlugin) UpdateAllocatableAssociatedDevices(request *pluginapi.UpdateAllocatableAssociatedDevicesRequest) (*pluginapi.UpdateAllocatableAssociatedDevicesResponse, error)
Constants ¶
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) RegisterDeviceNames ¶ added in v0.5.44
func (p *BasePlugin) RegisterDeviceNames(deviceNames []string, deviceType string)
RegisterDeviceNames is used to map device name to device type, and map 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( deviceNames []string, deviceAffinityProvider machine.DeviceAffinityProvider, )
RegisterTopologyAffinityProvider is a hook to set device affinity for given device names
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) TriggerReporter ¶ added in v0.5.44
func (p *BasePlugin) TriggerReporter()
TriggerReporter safely triggers the reporter to generate and send a new report.
func (*BasePlugin) UpdateAllocatableAssociatedDevices ¶ added in v0.5.43
func (p *BasePlugin) UpdateAllocatableAssociatedDevices( request *pluginapi.UpdateAllocatableAssociatedDevicesRequest, ) (*pluginapi.UpdateAllocatableAssociatedDevicesResponse, error)
UpdateAllocatableAssociatedDevices updates the topology provider with topology information of the given device request.