internal

package
v0.35.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

README

The allocator code exists in three variants which get picked depending on which features are enabled:

  • stable: for a "GA only" feature configuration, minimal changes going forward
  • incubating: the default implementation, adds support for beta features
  • experimental: under active development, including alpha features

This structure serves as a safety net because experimental changes cannot break more stable Kubernetes configurations, something that happened already once despite careful reviews.

The goal is to rotate the implementations wholesale instead of copying individual code chunks, i.e. at some point "incubating" replaces "stable", "experimental" replaces "incubating", and "experimental" becomes a copy of "incubating" until new changes get added to it again.

Ideally changes should be limited to "experimental", but sometimes changes have to be applied the same way across different variants, for example bug fixes or changes to the package API.

Tests are shared between all implementations, with test cases applied depending on what features they require. Further testing is covered by test/integration/scheduler_perf. When promoting implementations, the selection of implementations which support certain features there needs to be updated. For example []string{"experimental"} in TestSchedulerPerf of test/integration/scheduler_perf/dra/consumablecapacity/consumablecapacity_test.go will eventually become []string{"incubating", "experimental"}. The explicit selection of the implementation for benchmarking in EnableAllocators("experimental") then becomes EnableAllocators("incubating").

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFailedAllocationOnNode = errors.New("")

ErrFailedAllocationOnNode is an empty sentinel for errors.Is. See allocator.go for details.

View Source
var FeaturesAll = Features{
	AdminAccess:            true,
	ConsumableCapacity:     true,
	DeviceBindingAndStatus: true,
	DeviceTaints:           true,
	PartitionableDevices:   true,
	PrioritizedList:        true,
}

Functions

func GenerateShareID

func GenerateShareID() *types.UID

GenerateShareID is a helper function that generates a new share ID. This remains in the internal package as it's a utility function.

Types

type AllocatedState

type AllocatedState = schedulerapi.AllocatedState

type Allocator

type Allocator interface {
	Allocate(ctx context.Context, node *v1.Node, claims []*resourceapi.ResourceClaim) (finalResult []resourceapi.AllocationResult, finalErr error)
}

Allocator is intentionally not documented here. See the main package for docs.

This interface is also broader than the public one.

type AllocatorExtended

type AllocatorExtended interface {
	// Stats shows statistics from the allocation process.
	// May return nil if not implemented.
	GetStats() Stats
}

AllocatorExtended is an optional interface. Not all variants implement it.

type ConsumedCapacity

type ConsumedCapacity = schedulerapi.ConsumedCapacity

func NewConsumedCapacity

func NewConsumedCapacity() ConsumedCapacity

type ConsumedCapacityCollection

type ConsumedCapacityCollection = schedulerapi.ConsumedCapacityCollection

func NewConsumedCapacityCollection

func NewConsumedCapacityCollection() ConsumedCapacityCollection

type DeviceClassLister

type DeviceClassLister interface {
	// List returns a list of all DeviceClasses.
	List() ([]*resourceapi.DeviceClass, error)
	// Get returns the DeviceClass with the given className.
	Get(className string) (*resourceapi.DeviceClass, error)
}

type DeviceConsumedCapacity

type DeviceConsumedCapacity = schedulerapi.DeviceConsumedCapacity

func NewDeviceConsumedCapacity

func NewDeviceConsumedCapacity(deviceID DeviceID, consumedCapacity map[resourceapi.QualifiedName]resource.Quantity) DeviceConsumedCapacity

type DeviceID

type DeviceID = schedulerapi.DeviceID

Type aliases pointing to the schedulerapi package where the actual definitions are maintained. This ensures that any changes to these types require autoscaler approval.

func MakeDeviceID

func MakeDeviceID(driver, pool, device string) DeviceID

Wrapper functions that delegate to the schedulerapi package

type Features

type Features struct {
	AdminAccess            bool
	ConsumableCapacity     bool
	DeviceBindingAndStatus bool
	DeviceTaints           bool
	PartitionableDevices   bool
	PrioritizedList        bool
}

Features control optional functionality during ResourceClaim allocation. Each entry must correspond to at least one control flow change. Entries can be removed when the control flow change is no longer necessary (= feature is considered stable and always enabled).

This often corresponds to feature gates, but not always: if a KEP implementation depends on a set of feature gates, then a single entry here should control whether that implementation is active.

func (Features) Set

func (f Features) Set() sets.Set[string]

Set returns all features which are set to true. The names of the features happen to match the Kubernetes feature gates where applicable. Plain strings are used because not all allocator features necessarily have to be Kubernetes feature gates and this package must not depend on those definitions.

type SharedDeviceID

type SharedDeviceID = schedulerapi.SharedDeviceID

func MakeSharedDeviceID

func MakeSharedDeviceID(deviceID DeviceID, shareID *types.UID) SharedDeviceID

type Stats

type Stats struct {
	// NumAllocateOneInvocations counts the number of times the allocateOne function
	// got called.
	NumAllocateOneInvocations int64
}

Stats shows statistics from the allocation process.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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