package resourceslice
import "k8s.io/dynamic-resource-allocation/resourceslice"
Index ¶
- func DevicesDeepEqual(a, b []resourceapi.Device) bool
- type Controller
- func StartController(ctx context.Context, options Options) (*Controller, error)
- func (c *Controller) GetStats() Stats
- func (c *Controller) Stop()
- func (c *Controller) Update(resources *DriverResources)
- type DriverResources
- func (in *DriverResources) DeepCopy() *DriverResources
- func (in *DriverResources) DeepCopyInto(out *DriverResources)
- type Options
- type Owner
- type Pool
- type Slice
- type Stats
Functions ¶
func DevicesDeepEqual ¶
func DevicesDeepEqual(a, b []resourceapi.Device) bool
DevicesDeepEqual compares two slices of Devices. It behaves like apiequality.Semantic.DeepEqual, with one small difference: a nil DeviceTaint.TimeAdded is equal to a non-nil time. Also, rounding to full seconds (caused by round-tripping) is tolerated.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller synchronizes information about resources of one driver with ResourceSlice objects. It supports node-local and network-attached resources. A DRA driver for node-local resources typically runs this controller as part of its kubelet plugin.
func StartController ¶
func StartController(ctx context.Context, options Options) (*Controller, error)
StartController constructs a new controller and starts it.
func (*Controller) GetStats ¶
func (c *Controller) GetStats() Stats
GetStats provides some insights into operations of the controller.
func (*Controller) Stop ¶
func (c *Controller) Stop()
Stop cancels all background activity and blocks until the controller has stopped.
func (*Controller) Update ¶
func (c *Controller) Update(resources *DriverResources)
Update sets the new desired state of the resource information.
The controller is doing a deep copy, so the caller may update the instance once Update returns.
type DriverResources ¶
type DriverResources struct { // Each driver may manage different resource pools. Pools map[string]Pool }
DriverResources is a complete description of all resources synchronized by the controller.
func (*DriverResources) DeepCopy ¶
func (in *DriverResources) DeepCopy() *DriverResources
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverResources.
func (*DriverResources) DeepCopyInto ¶
func (in *DriverResources) DeepCopyInto(out *DriverResources)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Options ¶
type Options struct { // DriverName is the required name of the DRA driver. DriverName string // KubeClient is used to read Node objects (if necessary) and to access // ResourceSlices. It must be specified. KubeClient kubernetes.Interface // If the owner is a v1.Node, then the NodeName field in the // ResourceSlice objects is set and used to identify objects // managed by the controller. The UID is not needed in that // case, the controller will determine it automatically. // // The owner must be cluster-scoped. This is not always possible, // therefore it is optional. A driver without a owner must take // care that remaining slices get deleted manually as part of // a driver uninstall because garbage collection won't work. Owner *Owner // This is the initial desired set of slices. Resources *DriverResources // Queue can be used to override the default work queue implementation. Queue workqueue.TypedRateLimitingInterface[string] // MutationCacheTTL can be used to change the default TTL of one minute. // See source code for details. MutationCacheTTL *time.Duration // SyncDelay defines how long to wait between receiving the most recent // informer event and syncing again. The default is 30 seconds. // // This is long enough that the informer cache should be up-to-date // (matter mostly for deletes because an out-dated cache causes // redundant delete API calls) and not too long that a human mistake // doesn't get fixed while that human is waiting for it. SyncDelay *time.Duration }
Options contains various optional settings for StartController.
type Owner ¶
Owner is the resource which is meant to be listed as owner of the resource slices. For a node the UID may be left blank. The controller will look it up automatically.
func (*Owner) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Owner.
func (*Owner) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Pool ¶
type Pool struct { // NodeSelector may be different for each pool. Must not get set together // with Resources.NodeName. It nil and Resources.NodeName is not set, // then devices are available on all nodes. NodeSelector *v1.NodeSelector // Generation can be left at zero. It gets bumped up automatically // by the controller. Generation int64 // Slices is a list of all ResourceSlices that the driver // wants to publish for this pool. The driver must ensure // that each resulting slice is valid. See the API // definition for details, in particular the limit on // the number of devices. // // If slices are not valid, then the controller will // log errors produced by the apiserver. // // Drivers should publish at least one slice for each // pool that they normally manage, even if that slice // is empty. "Empty pool" is different from "no pool" // because it shows that the driver is up-and-running // and simply doesn't have any devices. Slices []Slice }
Pool is the collection of devices belonging to the same pool.
func (*Pool) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Pool.
func (*Pool) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Slice ¶
type Slice struct { // Devices lists all devices which are part of the slice. Devices []resourceapi.Device []resourceapi.CounterSet PerDeviceNodeSelection *bool }
Slice is turned into one ResourceSlice by the controller.
func (*Slice) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Slice.
func (*Slice) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Stats ¶
type Stats struct { // NumCreates counts the number of ResourceSlices that got created. NumCreates int64 // NumUpdates counts the number of ResourceSlices that got update. NumUpdates int64 // NumDeletes counts the number of ResourceSlices that got deleted. NumDeletes int64 }
Source Files ¶
resourceslicecontroller.go zz_generated.deepcopy.go
Directories ¶
Path | Synopsis |
---|---|
resourceslice/tracker |
- Version
- v0.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 24 packages
- Last checked
- 7 hours ago –
Tools for package owners.