Documentation
¶
Index ¶
- func AddDefaultResourcesToConfig(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interface, ...) error
- type AnnotatedID
- type AnnotatedIDs
- type Device
- type DeviceMap
- type Devices
- func (ds Devices) AlignedAllocationSupported() bool
- func (ds Devices) Contains(ids ...string) bool
- func (ds Devices) Difference(ods Devices) Devices
- func (ds Devices) GetByID(id string) *Device
- func (ds Devices) GetByIndex(index string) *Device
- func (ds Devices) GetIDs() []string
- func (ds Devices) GetIndices() []string
- func (ds Devices) GetPaths() []string
- func (ds Devices) GetPluginDevices() []*pluginapi.Device
- func (ds Devices) GetUUIDs() []string
- func (ds Devices) Subset(ids []string) Devices
- type ResourceManager
- type ResourceManagerMock
- func (mock *ResourceManagerMock) CheckHealth(stop <-chan interface{}, unhealthy chan<- *Device) error
- func (mock *ResourceManagerMock) CheckHealthCalls() []struct{ ... }
- func (mock *ResourceManagerMock) Devices() Devices
- func (mock *ResourceManagerMock) DevicesCalls() []struct{}
- func (mock *ResourceManagerMock) GetDevicePaths(strings []string) []string
- func (mock *ResourceManagerMock) GetDevicePathsCalls() []struct{ ... }
- func (mock *ResourceManagerMock) GetPreferredAllocation(available []string, required []string, size int) ([]string, error)
- func (mock *ResourceManagerMock) GetPreferredAllocationCalls() []struct{ ... }
- func (mock *ResourceManagerMock) Resource() spec.ResourceName
- func (mock *ResourceManagerMock) ResourceCalls() []struct{}
- func (mock *ResourceManagerMock) ValidateRequest(annotatedIDs AnnotatedIDs) error
- func (mock *ResourceManagerMock) ValidateRequestCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnnotatedID ¶
type AnnotatedID string
AnnotatedID represents an ID with a replica number embedded in it.
func NewAnnotatedID ¶
func NewAnnotatedID(id string, replica int) AnnotatedID
NewAnnotatedID creates a new AnnotatedID from an ID and a replica number.
func (AnnotatedID) GetID ¶
func (r AnnotatedID) GetID() string
GetID returns just the ID part of the replicated ID
func (AnnotatedID) HasAnnotations ¶
func (r AnnotatedID) HasAnnotations() bool
HasAnnotations checks if an AnnotatedID has any annotations or not.
func (AnnotatedID) Split ¶
func (r AnnotatedID) Split() (string, int)
Split splits a AnnotatedID into its ID and replica number parts.
type AnnotatedIDs ¶
type AnnotatedIDs []string
AnnotatedIDs can be used to treat a []string as a []AnnotatedID.
func (AnnotatedIDs) AnyHasAnnotations ¶
func (rs AnnotatedIDs) AnyHasAnnotations() bool
AnyHasAnnotations checks if any ID has annotations or not.
func (AnnotatedIDs) GetIDs ¶
func (rs AnnotatedIDs) GetIDs() []string
GetIDs returns just the ID parts of the annotated IDs as a []string
type Device ¶
type Device struct {
pluginapi.Device
Paths []string
Index string
TotalMemory uint64
ComputeCapability string
// Replicas stores the total number of times this device is replicated.
// If this is 0 or 1 then the device is not shared.
Replicas int
}
Device wraps pluginapi.Device with extra metadata and functions.
func BuildDevice ¶ added in v0.13.0
BuildDevice builds an rm.Device with the specified index and deviceInfo
func (Device) AlignedAllocationSupported ¶ added in v0.15.0
AlignedAllocationSupported checks whether the device supports an aligned allocation
func (Device) GetUUID ¶ added in v0.13.0
GetUUID returns the UUID for the device from the annotated ID.
func (Device) IsMigDevice ¶
IsMigDevice returns checks whether d is a MIG device or not.
type DeviceMap ¶ added in v0.13.0
type DeviceMap map[spec.ResourceName]Devices
DeviceMap stores a set of devices per resource name.
type Devices ¶
Devices wraps a map[string]*Device with some functions.
func (Devices) AlignedAllocationSupported ¶ added in v0.15.0
AlignedAllocationSupported checks whether all devices support an aligned allocation
func (Devices) Difference ¶
Difference returns the set of devices contained in ds but not in ods.
func (Devices) GetByID ¶
GetByID returns a reference to the device matching the specified ID (nil otherwise).
func (Devices) GetByIndex ¶
GetByIndex returns a reference to the device matching the specified Index (nil otherwise).
func (Devices) GetIndices ¶
GetIndices returns the Indices from all devices in the Devices
func (Devices) GetPluginDevices ¶
GetPluginDevices returns the plugin Devices from all devices in the Devices
type ResourceManager ¶
type ResourceManager interface {
Resource() spec.ResourceName
Devices() Devices
GetDevicePaths([]string) []string
GetPreferredAllocation(available, required []string, size int) ([]string, error)
CheckHealth(stop <-chan interface{}, unhealthy chan<- *Device) error
ValidateRequest(AnnotatedIDs) error
}
ResourceManager provides an interface for listing a set of Devices and checking health on them
func NewNVMLResourceManagers ¶ added in v0.13.0
func NewNVMLResourceManagers(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interface, config *spec.Config) ([]ResourceManager, error)
NewNVMLResourceManagers returns a set of ResourceManagers, one for each NVML resource in 'config'.
func NewTegraResourceManagers ¶ added in v0.13.0
func NewTegraResourceManagers(config *spec.Config) ([]ResourceManager, error)
NewTegraResourceManagers returns a set of ResourceManagers for tegra resources
type ResourceManagerMock ¶ added in v0.18.0
type ResourceManagerMock struct {
// CheckHealthFunc mocks the CheckHealth method.
CheckHealthFunc func(stop <-chan interface{}, unhealthy chan<- *Device) error
// DevicesFunc mocks the Devices method.
DevicesFunc func() Devices
// GetDevicePathsFunc mocks the GetDevicePaths method.
GetDevicePathsFunc func(strings []string) []string
// GetPreferredAllocationFunc mocks the GetPreferredAllocation method.
GetPreferredAllocationFunc func(available []string, required []string, size int) ([]string, error)
// ResourceFunc mocks the Resource method.
ResourceFunc func() spec.ResourceName
// ValidateRequestFunc mocks the ValidateRequest method.
ValidateRequestFunc func(annotatedIDs AnnotatedIDs) error
// contains filtered or unexported fields
}
ResourceManagerMock is a mock implementation of ResourceManager.
func TestSomethingThatUsesResourceManager(t *testing.T) {
// make and configure a mocked ResourceManager
mockedResourceManager := &ResourceManagerMock{
CheckHealthFunc: func(stop <-chan interface{}, unhealthy chan<- *Device) error {
panic("mock out the CheckHealth method")
},
DevicesFunc: func() Devices {
panic("mock out the Devices method")
},
GetDevicePathsFunc: func(strings []string) []string {
panic("mock out the GetDevicePaths method")
},
GetPreferredAllocationFunc: func(available []string, required []string, size int) ([]string, error) {
panic("mock out the GetPreferredAllocation method")
},
ResourceFunc: func() spec.ResourceName {
panic("mock out the Resource method")
},
ValidateRequestFunc: func(annotatedIDs AnnotatedIDs) error {
panic("mock out the ValidateRequest method")
},
}
// use mockedResourceManager in code that requires ResourceManager
// and then make assertions.
}
func (*ResourceManagerMock) CheckHealth ¶ added in v0.18.0
func (mock *ResourceManagerMock) CheckHealth(stop <-chan interface{}, unhealthy chan<- *Device) error
CheckHealth calls CheckHealthFunc.
func (*ResourceManagerMock) CheckHealthCalls ¶ added in v0.18.0
func (mock *ResourceManagerMock) CheckHealthCalls() []struct { Stop <-chan interface{} Unhealthy chan<- *Device }
CheckHealthCalls gets all the calls that were made to CheckHealth. Check the length with:
len(mockedResourceManager.CheckHealthCalls())
func (*ResourceManagerMock) Devices ¶ added in v0.18.0
func (mock *ResourceManagerMock) Devices() Devices
Devices calls DevicesFunc.
func (*ResourceManagerMock) DevicesCalls ¶ added in v0.18.0
func (mock *ResourceManagerMock) DevicesCalls() []struct { }
DevicesCalls gets all the calls that were made to Devices. Check the length with:
len(mockedResourceManager.DevicesCalls())
func (*ResourceManagerMock) GetDevicePaths ¶ added in v0.18.0
func (mock *ResourceManagerMock) GetDevicePaths(strings []string) []string
GetDevicePaths calls GetDevicePathsFunc.
func (*ResourceManagerMock) GetDevicePathsCalls ¶ added in v0.18.0
func (mock *ResourceManagerMock) GetDevicePathsCalls() []struct { Strings []string }
GetDevicePathsCalls gets all the calls that were made to GetDevicePaths. Check the length with:
len(mockedResourceManager.GetDevicePathsCalls())
func (*ResourceManagerMock) GetPreferredAllocation ¶ added in v0.18.0
func (mock *ResourceManagerMock) GetPreferredAllocation(available []string, required []string, size int) ([]string, error)
GetPreferredAllocation calls GetPreferredAllocationFunc.
func (*ResourceManagerMock) GetPreferredAllocationCalls ¶ added in v0.18.0
func (mock *ResourceManagerMock) GetPreferredAllocationCalls() []struct { Available []string Required []string Size int }
GetPreferredAllocationCalls gets all the calls that were made to GetPreferredAllocation. Check the length with:
len(mockedResourceManager.GetPreferredAllocationCalls())
func (*ResourceManagerMock) Resource ¶ added in v0.18.0
func (mock *ResourceManagerMock) Resource() spec.ResourceName
Resource calls ResourceFunc.
func (*ResourceManagerMock) ResourceCalls ¶ added in v0.18.0
func (mock *ResourceManagerMock) ResourceCalls() []struct { }
ResourceCalls gets all the calls that were made to Resource. Check the length with:
len(mockedResourceManager.ResourceCalls())
func (*ResourceManagerMock) ValidateRequest ¶ added in v0.18.0
func (mock *ResourceManagerMock) ValidateRequest(annotatedIDs AnnotatedIDs) error
ValidateRequest calls ValidateRequestFunc.
func (*ResourceManagerMock) ValidateRequestCalls ¶ added in v0.18.0
func (mock *ResourceManagerMock) ValidateRequestCalls() []struct { AnnotatedIDs AnnotatedIDs }
ValidateRequestCalls gets all the calls that were made to ValidateRequest. Check the length with:
len(mockedResourceManager.ValidateRequestCalls())