Documentation
¶
Overview ¶
Package structured contains code for working with structured parameters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator calculates how to allocate a set of unallocated claims which use structured parameters.
It needs as input the node where the allocated claims are meant to be available and the current state of the cluster (claims, classes, resource slices).
func NewAllocator ¶
func NewAllocator(ctx context.Context, adminAccessEnabled bool, claimsToAllocate []*resourceapi.ResourceClaim, allocatedDevices sets.Set[DeviceID], classLister deviceClassLister, slices []*resourceapi.ResourceSlice, celCache *cel.Cache, ) (*Allocator, error)
NewAllocator returns an allocator for a certain set of claims or an error if some problem was detected which makes it impossible to allocate claims.
The returned Allocator can be used multiple times and is thread-safe.
func (*Allocator) Allocate ¶
func (a *Allocator) Allocate(ctx context.Context, node *v1.Node) (finalResult []resourceapi.AllocationResult, finalErr error)
Allocate calculates the allocation(s) for one particular node.
It returns an error only if some fatal problem occurred. These are errors caused by invalid input data, like for example errors in CEL selectors, so a scheduler should abort and report that problem instead of trying to find other nodes where the error doesn't occur.
In the future, special errors will be defined which enable the caller to identify which object (like claim or class) caused the problem. This will enable reporting the problem as event for those objects.
If the claims cannot be allocated, it returns nil. This includes the situation where the resource slices are incomplete at the moment.
If the claims can be allocated, then it prepares one allocation result for each unallocated claim. It is the responsibility of the caller to persist those allocations, if desired.
Allocate is thread-safe. If the caller wants to get the node name included in log output, it can use contextual logging and add the node as an additional value. A name can also be useful because log messages do not have a common prefix. V(5) is used for one-time log entries, V(6) for important progress reports, and V(7) for detailed debug output.
func (*Allocator) ClaimsToAllocate ¶
func (a *Allocator) ClaimsToAllocate() []*resourceapi.ResourceClaim
ClaimsToAllocate returns the claims that the allocator was created for.
type DeviceID ¶
type DeviceID struct {
Driver, Pool, Device draapi.UniqueString
}
func MakeDeviceID ¶ added in v0.32.0
type Pool ¶
type Pool struct { PoolID IsIncomplete bool IsInvalid bool InvalidReason string Slices []*draapi.ResourceSlice }
func GatherPools ¶
func GatherPools(ctx context.Context, slices []*resourceapi.ResourceSlice, node *v1.Node) ([]*Pool, error)
GatherPools collects information about all resource pools which provide devices that are accessible from the given node.
Out-dated slices are silently ignored. Pools may be incomplete (not all required slices available) or invalid (for example, device names not unique). Both is recorded in the result.