 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
const ( // Including adds in the mutation cache is not safe: We could add a slice, store it, // and then the slice gets deleted without the informer hearing anything about that. // Then the obsolete slice remains in the mutation cache. // // To mitigate this, we use a TTL and check a pool again once added slices expire. DefaultMutationCacheTTL = time.Minute // DefaultSyncDelay defines how long to wait between receiving the most recent // informer event and syncing again. This is long enough that the informer cache // should be up-to-date (matters 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. DefaultSyncDelay = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func DevicesDeepEqual ¶ added in v0.33.0
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 ¶ added in v0.32.0
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. Nil is valid and the same as an empty resources struct.
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 ¶ added in v0.32.0
func (in *DriverResources) DeepCopy() *DriverResources
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverResources.
func (*DriverResources) DeepCopyInto ¶ added in v0.32.0
func (in *DriverResources) DeepCopyInto(out *DriverResources)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type DroppedFieldsError ¶ added in v0.34.0
type DroppedFieldsError struct {
	PoolName                  string
	SliceIndex                int
	DesiredSlice, ActualSlice *resourceapi.ResourceSlice
}
    DroppedFieldsError is reported through the ErrorHandler in Options if a slice could not be published exactly as desired by the driver.
func (*DroppedFieldsError) DisabledFeatures ¶ added in v0.34.0
func (err *DroppedFieldsError) DisabledFeatures() []string
func (*DroppedFieldsError) Error ¶ added in v0.34.0
func (err *DroppedFieldsError) Error() string
type Options ¶ added in v0.32.0
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. Nil means "no resources".
	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
	// ErrorHandler will get called whenever the controller encounters
	// a problem while trying to publish ResourceSlices. The controller
	// will retry once the handler returns. What the handler does with
	// that information is up to the handler. It could log the error,
	// replace the slices if they cannot be published (see below),
	// or force the program running the controller to fail by exiting.
	//
	// If some fields were dropped because the cluster does not support
	// the feature they depend on, then the error is or wraps an
	// [DroppedFieldsError] instance. Use [errors.As] to convert to that
	// type:
	//    var droppedFields *resourceslice.DroppedFieldsError
	//    if errors.As(err, &droppedFields) { ... do something with droppedFields ... }
	//
	// The default is [utilruntime.HandleErrorWithContext] which just logs
	// the problem.
	ErrorHandler func(ctx context.Context, err error, msg string)
}
    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 ¶ added in v0.32.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Owner.
func (*Owner) DeepCopyInto ¶ added in v0.32.0
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. If 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 ¶ added in v0.32.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Pool.
func (*Pool) DeepCopyInto ¶ added in v0.32.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Slice ¶ added in v0.32.0
type Slice struct {
	// Devices lists all devices which are part of the slice.
	Devices                []resourceapi.Device
	PerDeviceNodeSelection *bool
}
    Slice is turned into one ResourceSlice by the controller.
func (*Slice) DeepCopy ¶ added in v0.32.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Slice.
func (*Slice) DeepCopyInto ¶ added in v0.32.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.