Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClaimAllocation ¶
type ClaimAllocation struct { PodClaimName string Claim *resourcev1alpha2.ResourceClaim Class *resourcev1alpha2.ResourceClass ClaimParameters interface{} ClassParameters interface{} // UnsuitableNodes needs to be filled in by the driver when // Driver.UnsuitableNodes gets called. UnsuitableNodes []string // Driver must populate this field with resources that were // allocated for the claim in case of successful allocation. Allocation *resourcev1alpha2.AllocationResult // In case of error allocating particular claim, driver must // populate this field. Error error }
ClaimAllocation represents information about one particular pod.Spec.ResourceClaim entry.
type Controller ¶
type Controller interface { // Run starts the controller. Run(workers int) // SetReservedFor can be used to disable adding the Pod which // triggered allocation to the status.reservedFor. Normally, // DRA drivers should always do that, so it's the default. // But nothing in the protocol between the scheduler and // a driver requires it, so at least for testing the control // plane components it is useful to disable it. SetReservedFor(enabled bool) }
Controller watches ResourceClaims and triggers allocation and deallocation as needed.
func New ¶
func New( ctx context.Context, name string, driver Driver, kubeClient kubernetes.Interface, informerFactory informers.SharedInformerFactory) Controller
New creates a new controller.
type Driver ¶
type Driver interface { // GetClassParameters gets called to retrieve the parameter object // referenced by a class. The content should be validated now if // possible. class.Parameters may be nil. // // The caller will wrap the error to include the parameter reference. GetClassParameters(ctx context.Context, class *resourcev1alpha2.ResourceClass) (interface{}, error) // GetClaimParameters gets called to retrieve the parameter object // referenced by a claim. The content should be validated now if // possible. claim.Spec.Parameters may be nil. // // The caller will wrap the error to include the parameter reference. GetClaimParameters(ctx context.Context, claim *resourcev1alpha2.ResourceClaim, class *resourcev1alpha2.ResourceClass, classParameters interface{}) (interface{}, error) // Allocate gets called when all same-driver ResourceClaims for Pod are ready // to be allocated. The selectedNode is empty for ResourceClaims with immediate // allocation, in which case the resource driver decides itself where // to allocate. If there is already an on-going allocation, the driver // may finish it and ignore the new parameters or abort the on-going // allocation and try again with the new parameters. // // Parameters have been retrieved earlier. // // Driver must set the result of allocation for every claim in "claims" // parameter items. In case if there was no error encountered and allocation // was successful - claims[i].Allocation field should be set. In case of // particular claim allocation fail - respective item's claims[i].Error field // should be set, in this case claims[i].Allocation will be ignored. // // If selectedNode is set, the driver must attempt to allocate for that // node. If that is not possible, it must return an error. The // controller will call UnsuitableNodes and pass the new information to // the scheduler, which then will lead to selecting a diffent node // if the current one is not suitable. // // The Claim, ClaimParameters, Class, ClassParameters fields of "claims" parameter // items are read-only and must not be modified. This call must be idempotent. Allocate(ctx context.Context, claims []*ClaimAllocation, selectedNode string) // Deallocate gets called when a ResourceClaim is ready to be // freed. // // The claim is read-only and must not be modified. This call must be // idempotent. In particular it must not return an error when the claim // is currently not allocated. // // Deallocate may get called when a previous allocation got // interrupted. Deallocate must then stop any on-going allocation // activity and free resources before returning without an error. Deallocate(ctx context.Context, claim *resourcev1alpha2.ResourceClaim) error // UnsuitableNodes checks all pending claims with delayed allocation // for a pod. All claims are ready for allocation by the driver // and parameters have been retrieved. // // The driver may consider each claim in isolation, but it's better // to mark nodes as unsuitable for all claims if it not all claims // can be allocated for it (for example, two GPUs requested but // the node only has one). // // The result of the check is in ClaimAllocation.UnsuitableNodes. // An error indicates that the entire check must be repeated. UnsuitableNodes(ctx context.Context, pod *v1.Pod, claims []*ClaimAllocation, potentialNodes []string) error }
Driver provides the actual allocation and deallocation operations.
Click to show internal directories.
Click to hide internal directories.