Documentation
¶
Index ¶
- Constants
- Variables
- func AppliedCPUFingerprint(extra string) (string, error)
- func EncodeAppliedInventory(inventory []GRESInventory) (string, error)
- func NUMASpans(ctx context.Context, registry *Registry, ...) map[string]float64
- func ValidateRequestContainers(requests []ResourceRequest) error
- func ValidateResourceSliceNode(resourceSlice *resourcev1.ResourceSlice) error
- func WithAppliedCPUFingerprint(extra, fingerprint string) (string, error)
- func WithCachedInventory(ctx context.Context, direct client.Client) client.Client
- func WithInventoryReader(ctx context.Context, reader client.Reader) context.Context
- type AppliedInventory
- type AppliedProfileInventory
- type Backend
- type CoreBitmapBackend
- type DeviceIdentity
- type DeviceProfile
- type GRES
- type GRESInventory
- type IndexedGRESBackend
- type NUMASpanCache
- type NodeInventory
- type OverlappingDeviceProfilesError
- type ProfileInventory
- type Registry
- func (r *Registry) LookupByName(name string) (DeviceProfile, bool)
- func (r *Registry) LookupBySelector(selector string) (DeviceProfile, bool)
- func (r *Registry) MatchDeviceClass(deviceClass *resourcev1.DeviceClass) (DeviceProfile, error)
- func (r *Registry) MatchIndexedGRES(gres GRES) (DeviceProfile, bool, error)
- func (r *Registry) ResolvePod(ctx context.Context, reader client.Reader, pod *corev1.Pod) ([]ResourceRequest, error)
- func (r *Registry) SupportsDriver(driver string) bool
- func (r *Registry) WatchDeviceClasses(informer interface{ ... }) error
- type ResourcePoolID
- type ResourceRequest
Constants ¶
const ( // AppliedInventoryExtraPrefix identifies node Extra values owned by the DRA // GRES inventory integration. AppliedInventoryExtraPrefix = "slurm-bridge.dra-gres-map=" )
Variables ¶
var ErrExclusiveCPUAllocation = errors.New("CPU DRA does not support exclusive Slurm allocations; set slurmjob.slinky.slurm.net/exclusive: \"false\" on the Pod")
ErrExclusiveCPUAllocation reports unsupported exclusive CPU requests.
Functions ¶
func AppliedCPUFingerprint ¶
AppliedCPUFingerprint returns the CPU fingerprint, or an empty string for GRES-only inventory.
func EncodeAppliedInventory ¶
func EncodeAppliedInventory(inventory []GRESInventory) (string, error)
EncodeAppliedInventory encodes indexed GRES inventory for a Slurm node Extra field. Slurm starts each GRES name at index zero and assigns indexes across all types which share that name.
func NUMASpans ¶
func NUMASpans(ctx context.Context, registry *Registry, resourceSlices []*resourcev1.ResourceSlice, profileNames []string) map[string]float64
NUMASpans returns the mean number of NUMA nodes per node covered by each named profile's devices. Profiles without NUMA-local devices are absent.
func ValidateRequestContainers ¶
func ValidateRequestContainers(requests []ResourceRequest) error
ValidateRequestContainers enforces the bridge's one-container-per-class allocation model.
func ValidateResourceSliceNode ¶
func ValidateResourceSliceNode(resourceSlice *resourcev1.ResourceSlice) error
ValidateResourceSliceNode requires every device in the slice to belong to the single node explicitly named by spec.nodeName.
func WithAppliedCPUFingerprint ¶
WithAppliedCPUFingerprint adds the CPU topology fingerprint to the GRES inventory.
func WithCachedInventory ¶
WithCachedInventory routes only inventory reads through the manager cache. Claims, Pods, writes and immediate readback retain the direct client's semantics.
Types ¶
type AppliedInventory ¶
type AppliedInventory map[string]AppliedProfileInventory
AppliedInventory records the DRA devices represented by Slurm GRES indexes, keyed by stable DeviceProfile name.
func DecodeAppliedInventory ¶
func DecodeAppliedInventory(extra string) (AppliedInventory, error)
DecodeAppliedInventory decodes the profile-to-index mapping stored in a Slurm node Extra field.
func (AppliedInventory) Devices ¶
func (a AppliedInventory) Devices(profileName string, indexes []int) ([]DeviceIdentity, error)
Devices returns the devices represented by indexes for a DeviceProfile. The order of the returned devices matches the order of indexes.
type AppliedProfileInventory ¶
type AppliedProfileInventory struct {
FirstIndex int
Devices []DeviceIdentity
}
AppliedProfileInventory records the DRA devices represented by a contiguous range of Slurm GRES indexes for one DeviceProfile.
type Backend ¶
Backend describes how Slurm represents and enforces devices in a DeviceProfile.
func NewBackend ¶
NewBackend constructs a backend from its stable type name. gresName is used only by indexed-gres backends. NewRegistry validates the resulting profile.
type CoreBitmapBackend ¶
type CoreBitmapBackend struct{}
CoreBitmapBackend represents devices allocated through Slurm's CPU bitmap.
func (CoreBitmapBackend) String ¶
func (CoreBitmapBackend) String() string
String returns the stable name of the backend.
type DeviceIdentity ¶
type DeviceIdentity = structured.DeviceID
DeviceIdentity is the stable DRA identity of a device.
type DeviceProfile ¶
DeviceProfile describes a disjoint physical device pool that Slurm can enforce. Selector is the canonical CEL expression a DeviceClass must use to resolve to this profile.
func (DeviceProfile) GRES ¶
func (p DeviceProfile) GRES() (GRES, error)
GRES returns the indexed Slurm GRES represented by this DeviceProfile.
func (DeviceProfile) UsesCoreBitmap ¶
func (p DeviceProfile) UsesCoreBitmap() bool
UsesCoreBitmap reports whether Slurm allocates the profile through its CPU bitmap.
func (DeviceProfile) UsesIndexedGRES ¶
func (p DeviceProfile) UsesIndexedGRES() bool
UsesIndexedGRES reports whether Slurm allocates the profile as an indexed generic resource.
type GRESInventory ¶
type GRESInventory struct {
GRES GRES
Devices []DeviceIdentity
NUMANodes map[DeviceIdentity][]int
// Cores holds the Slurm cores local to each device; see WithNUMACores.
Cores map[DeviceIdentity][]int
}
GRESInventory describes one indexed Slurm GRES and its stable DRA device mapping. Devices are ordered within the GRES type; Slurm assigns absolute indexes across all types which share the same GRES name.
func (GRESInventory) SlurmConfig ¶
func (g GRESInventory) SlurmConfig() (string, string, error)
SlurmConfig returns the Gres and GresConf entries for this inventory.
func (GRESInventory) WithNUMACores ¶
func (g GRESInventory) WithNUMACores(numaCores map[int][]int) GRESInventory
WithNUMACores returns a copy of the inventory with each device bound to the union of its NUMA nodes' cores. Slurm takes one core range per device, so devices whose cores are not contiguous stay unbound.
type IndexedGRESBackend ¶
type IndexedGRESBackend struct {
GRESName string
}
IndexedGRESBackend represents devices allocated through an indexed Slurm GRES.
func (IndexedGRESBackend) String ¶
func (IndexedGRESBackend) String() string
String returns the stable name of the backend.
type NUMASpanCache ¶
type NUMASpanCache struct {
// contains filtered or unexported fields
}
NUMASpanCache derives GRES ordering once per observed inventory change. Informer objects are immutable; only references and the derived spans are kept. The registry is fixed for the lifetime of the informer.
func NewNUMASpanCache ¶
func NewNUMASpanCache(registry *Registry, informer resourceSliceInformer) (*NUMASpanCache, error)
func (*NUMASpanCache) OnAdd ¶
func (c *NUMASpanCache) OnAdd(obj any, _ bool)
func (*NUMASpanCache) OnDelete ¶
func (c *NUMASpanCache) OnDelete(obj any)
func (*NUMASpanCache) OnUpdate ¶
func (c *NUMASpanCache) OnUpdate(_, obj any)
type NodeInventory ¶
type NodeInventory struct {
NodeName string
Profiles []ProfileInventory
}
NodeInventory is the profile-classified device inventory computed for one Kubernetes node. It does not describe current allocation availability. Profiles are ordered by DeviceProfile name.
func BuildNodeInventory ¶
func BuildNodeInventory(ctx context.Context, registry *Registry, node *corev1.Node, resourceSlices []resourcev1.ResourceSlice) (NodeInventory, error)
BuildNodeInventory builds the inventory for node from ResourceSlices matching profiles in registry. Matching a profile classifies a device; it does not determine whether that device is currently allocatable.
func (NodeInventory) GRES ¶
func (n NodeInventory) GRES() ([]GRESInventory, error)
GRES translates indexed-GRES profiles into Slurm GRES inventory.
type OverlappingDeviceProfilesError ¶
type OverlappingDeviceProfilesError struct {
Device DeviceIdentity
Profiles [2]string
}
OverlappingDeviceProfilesError reports a device which matched more than one profile. Devices must resolve to exactly one profile so Slurm cannot account for the same physical device through multiple GRES types.
func (*OverlappingDeviceProfilesError) Error ¶
func (e *OverlappingDeviceProfilesError) Error() string
type ProfileInventory ¶
type ProfileInventory struct {
Profile DeviceProfile
Devices []DeviceIdentity
// NUMANodes holds each device's standard numaNode attribute.
NUMANodes map[DeviceIdentity][]int
}
ProfileInventory contains the devices resolved to one DeviceProfile. Devices are ordered within the profile. Their absolute Slurm indexes also account for earlier profiles which use the same GRES name.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry indexes supported DeviceProfiles by name and canonical selector.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns a registry containing the profiles enabled by default.
func NewRegistry ¶
func NewRegistry(profiles []DeviceProfile) (*Registry, error)
NewRegistry validates profiles and indexes them by name and canonical selector.
func (*Registry) LookupByName ¶
func (r *Registry) LookupByName(name string) (DeviceProfile, bool)
LookupByName returns the profile with the given stable profile name.
func (*Registry) LookupBySelector ¶
func (r *Registry) LookupBySelector(selector string) (DeviceProfile, bool)
LookupBySelector returns the profile with the exact canonical CEL selector. Selector matching is deliberately byte-for-byte.
func (*Registry) MatchDeviceClass ¶
func (r *Registry) MatchDeviceClass(deviceClass *resourcev1.DeviceClass) (DeviceProfile, error)
MatchDeviceClass validates a DeviceClass and returns its matching profile.
func (*Registry) MatchIndexedGRES ¶
func (r *Registry) MatchIndexedGRES(gres GRES) (DeviceProfile, bool, error)
MatchIndexedGRES returns the profile which owns gres. Profiles using other backends do not claim the Slurm GRES type namespace. A known indexed-GRES type with the wrong GRES name is rejected.
func (*Registry) ResolvePod ¶
func (r *Registry) ResolvePod(ctx context.Context, reader client.Reader, pod *corev1.Pod) ([]ResourceRequest, error)
ResolvePod resolves each DRA request once, preserving container and resource names for ResourceClaim mappings. Unclaimed names remain device-plugin resources.
func (*Registry) SupportsDriver ¶
SupportsDriver reports whether the registry contains a profile for driver.
func (*Registry) WatchDeviceClasses ¶
func (r *Registry) WatchDeviceClasses(informer interface { AddEventHandler(cache.ResourceEventHandler) (cache.ResourceEventHandlerRegistration, error) }) error
WatchDeviceClasses maintains a resource-name index using an existing informer. Call before starting admission or scheduling workers.
type ResourcePoolID ¶
ResourcePoolID identifies a DRA resource pool within its driver.
func ResourcePoolIDFromSlice ¶
func ResourcePoolIDFromSlice(resourceSlice *resourcev1.ResourceSlice) ResourcePoolID
ResourcePoolIDFromSlice returns the driver and pool identified by a ResourceSlice.
func (ResourcePoolID) String ¶
func (id ResourcePoolID) String() string
String returns the driver/pool key used in cache indexes and diagnostics.
type ResourceRequest ¶
type ResourceRequest struct {
ResourceName corev1.ResourceName
ContainerName string
DeviceClassName string
Profile DeviceProfile
Count int64
}
ResourceRequest retains the Pod's resource name alongside its resolved class.