@@ -100,8 +100,8 @@ type informationForClaim struct {
100
100
allocation * resourceapi.AllocationResult
101
101
}
102
102
103
- // dynamicResources is a plugin that ensures that ResourceClaims are allocated.
104
- type dynamicResources struct {
103
+ // DynamicResources is a plugin that ensures that ResourceClaims are allocated.
104
+ type DynamicResources struct {
105
105
enabled bool
106
106
enableAdminAccess bool
107
107
enableSchedulingQueueHint bool
@@ -171,10 +171,10 @@ type dynamicResources struct {
171
171
func New (ctx context.Context , plArgs runtime.Object , fh framework.Handle , fts feature.Features ) (framework.Plugin , error ) {
172
172
if ! fts .EnableDynamicResourceAllocation {
173
173
// Disabled, won't do anything.
174
- return & dynamicResources {}, nil
174
+ return & DynamicResources {}, nil
175
175
}
176
176
177
- pl := & dynamicResources {
177
+ pl := & DynamicResources {
178
178
enabled : true ,
179
179
enableAdminAccess : fts .EnableDRAAdminAccess ,
180
180
enableSchedulingQueueHint : fts .EnableSchedulingQueueHint ,
@@ -189,22 +189,22 @@ func New(ctx context.Context, plArgs runtime.Object, fh framework.Handle, fts fe
189
189
return pl , nil
190
190
}
191
191
192
- var _ framework.PreEnqueuePlugin = & dynamicResources {}
193
- var _ framework.PreFilterPlugin = & dynamicResources {}
194
- var _ framework.FilterPlugin = & dynamicResources {}
195
- var _ framework.PostFilterPlugin = & dynamicResources {}
196
- var _ framework.ReservePlugin = & dynamicResources {}
197
- var _ framework.EnqueueExtensions = & dynamicResources {}
198
- var _ framework.PreBindPlugin = & dynamicResources {}
192
+ var _ framework.PreEnqueuePlugin = & DynamicResources {}
193
+ var _ framework.PreFilterPlugin = & DynamicResources {}
194
+ var _ framework.FilterPlugin = & DynamicResources {}
195
+ var _ framework.PostFilterPlugin = & DynamicResources {}
196
+ var _ framework.ReservePlugin = & DynamicResources {}
197
+ var _ framework.EnqueueExtensions = & DynamicResources {}
198
+ var _ framework.PreBindPlugin = & DynamicResources {}
199
199
200
200
// Name returns name of the plugin. It is used in logs, etc.
201
- func (pl * dynamicResources ) Name () string {
201
+ func (pl * DynamicResources ) Name () string {
202
202
return Name
203
203
}
204
204
205
205
// EventsToRegister returns the possible events that may make a Pod
206
206
// failed by this plugin schedulable.
207
- func (pl * dynamicResources ) EventsToRegister (_ context.Context ) ([]framework.ClusterEventWithHint , error ) {
207
+ func (pl * DynamicResources ) EventsToRegister (_ context.Context ) ([]framework.ClusterEventWithHint , error ) {
208
208
if ! pl .enabled {
209
209
return nil , nil
210
210
}
@@ -239,7 +239,7 @@ func (pl *dynamicResources) EventsToRegister(_ context.Context) ([]framework.Clu
239
239
// PreEnqueue checks if there are known reasons why a pod currently cannot be
240
240
// scheduled. When this fails, one of the registered events can trigger another
241
241
// attempt.
242
- func (pl * dynamicResources ) PreEnqueue (ctx context.Context , pod * v1.Pod ) (status * framework.Status ) {
242
+ func (pl * DynamicResources ) PreEnqueue (ctx context.Context , pod * v1.Pod ) (status * framework.Status ) {
243
243
if ! pl .enabled {
244
244
return nil
245
245
}
@@ -254,7 +254,7 @@ func (pl *dynamicResources) PreEnqueue(ctx context.Context, pod *v1.Pod) (status
254
254
// an informer. It checks whether that change made a previously unschedulable
255
255
// pod schedulable. It errs on the side of letting a pod scheduling attempt
256
256
// happen. The delete claim event will not invoke it, so newObj will never be nil.
257
- func (pl * dynamicResources ) isSchedulableAfterClaimChange (logger klog.Logger , pod * v1.Pod , oldObj , newObj interface {}) (framework.QueueingHint , error ) {
257
+ func (pl * DynamicResources ) isSchedulableAfterClaimChange (logger klog.Logger , pod * v1.Pod , oldObj , newObj interface {}) (framework.QueueingHint , error ) {
258
258
originalClaim , modifiedClaim , err := schedutil .As [* resourceapi.ResourceClaim ](oldObj , newObj )
259
259
if err != nil {
260
260
// Shouldn't happen.
@@ -318,7 +318,7 @@ func (pl *dynamicResources) isSchedulableAfterClaimChange(logger klog.Logger, po
318
318
// isSchedulableAfterPodChange is invoked for update pod events reported by
319
319
// an informer. It checks whether that change adds the ResourceClaim(s) that the
320
320
// pod has been waiting for.
321
- func (pl * dynamicResources ) isSchedulableAfterPodChange (logger klog.Logger , pod * v1.Pod , oldObj , newObj interface {}) (framework.QueueingHint , error ) {
321
+ func (pl * DynamicResources ) isSchedulableAfterPodChange (logger klog.Logger , pod * v1.Pod , oldObj , newObj interface {}) (framework.QueueingHint , error ) {
322
322
_ , modifiedPod , err := schedutil .As [* v1.Pod ](nil , newObj )
323
323
if err != nil {
324
324
// Shouldn't happen.
@@ -351,7 +351,7 @@ func (pl *dynamicResources) isSchedulableAfterPodChange(logger klog.Logger, pod
351
351
// attempt.
352
352
//
353
353
// The delete claim event will not invoke it, so newObj will never be nil.
354
- func (pl * dynamicResources ) isSchedulableAfterResourceSliceChange (logger klog.Logger , pod * v1.Pod , oldObj , newObj interface {}) (framework.QueueingHint , error ) {
354
+ func (pl * DynamicResources ) isSchedulableAfterResourceSliceChange (logger klog.Logger , pod * v1.Pod , oldObj , newObj interface {}) (framework.QueueingHint , error ) {
355
355
_ , modifiedSlice , err := schedutil .As [* resourceapi.ResourceSlice ](oldObj , newObj )
356
356
if err != nil {
357
357
// Shouldn't happen.
@@ -375,7 +375,7 @@ func (pl *dynamicResources) isSchedulableAfterResourceSliceChange(logger klog.Lo
375
375
}
376
376
377
377
// podResourceClaims returns the ResourceClaims for all pod.Spec.PodResourceClaims.
378
- func (pl * dynamicResources ) podResourceClaims (pod * v1.Pod ) ([]* resourceapi.ResourceClaim , error ) {
378
+ func (pl * DynamicResources ) podResourceClaims (pod * v1.Pod ) ([]* resourceapi.ResourceClaim , error ) {
379
379
claims := make ([]* resourceapi.ResourceClaim , 0 , len (pod .Spec .ResourceClaims ))
380
380
if err := pl .foreachPodResourceClaim (pod , func (_ string , claim * resourceapi.ResourceClaim ) {
381
381
// We store the pointer as returned by the lister. The
@@ -391,7 +391,7 @@ func (pl *dynamicResources) podResourceClaims(pod *v1.Pod) ([]*resourceapi.Resou
391
391
392
392
// foreachPodResourceClaim checks that each ResourceClaim for the pod exists.
393
393
// It calls an optional handler for those claims that it finds.
394
- func (pl * dynamicResources ) foreachPodResourceClaim (pod * v1.Pod , cb func (podResourceName string , claim * resourceapi.ResourceClaim )) error {
394
+ func (pl * DynamicResources ) foreachPodResourceClaim (pod * v1.Pod , cb func (podResourceName string , claim * resourceapi.ResourceClaim )) error {
395
395
for _ , resource := range pod .Spec .ResourceClaims {
396
396
claimName , mustCheckOwner , err := resourceclaim .Name (pod , & resource )
397
397
if err != nil {
@@ -432,7 +432,7 @@ func (pl *dynamicResources) foreachPodResourceClaim(pod *v1.Pod, cb func(podReso
432
432
// PreFilter invoked at the prefilter extension point to check if pod has all
433
433
// immediate claims bound. UnschedulableAndUnresolvable is returned if
434
434
// the pod cannot be scheduled at the moment on any node.
435
- func (pl * dynamicResources ) PreFilter (ctx context.Context , state * framework.CycleState , pod * v1.Pod ) (* framework.PreFilterResult , * framework.Status ) {
435
+ func (pl * DynamicResources ) PreFilter (ctx context.Context , state * framework.CycleState , pod * v1.Pod ) (* framework.PreFilterResult , * framework.Status ) {
436
436
if ! pl .enabled {
437
437
return nil , framework .NewStatus (framework .Skip )
438
438
}
@@ -563,7 +563,7 @@ func (cl *claimListerForAssumeCache) ListAllAllocated() ([]*resourceapi.Resource
563
563
}
564
564
565
565
// PreFilterExtensions returns prefilter extensions, pod add and remove.
566
- func (pl * dynamicResources ) PreFilterExtensions () framework.PreFilterExtensions {
566
+ func (pl * DynamicResources ) PreFilterExtensions () framework.PreFilterExtensions {
567
567
return nil
568
568
}
569
569
@@ -588,7 +588,7 @@ func getStateData(cs *framework.CycleState) (*stateData, error) {
588
588
//
589
589
// For claims that are unbound, it checks whether the claim might get allocated
590
590
// for the node.
591
- func (pl * dynamicResources ) Filter (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeInfo * framework.NodeInfo ) * framework.Status {
591
+ func (pl * DynamicResources ) Filter (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeInfo * framework.NodeInfo ) * framework.Status {
592
592
if ! pl .enabled {
593
593
return nil
594
594
}
@@ -675,7 +675,7 @@ func (pl *dynamicResources) Filter(ctx context.Context, cs *framework.CycleState
675
675
// deallocated to help get the Pod schedulable. If yes, it picks one and
676
676
// requests its deallocation. This only gets called when filtering found no
677
677
// suitable node.
678
- func (pl * dynamicResources ) PostFilter (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , filteredNodeStatusMap framework.NodeToStatusReader ) (* framework.PostFilterResult , * framework.Status ) {
678
+ func (pl * DynamicResources ) PostFilter (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , filteredNodeStatusMap framework.NodeToStatusReader ) (* framework.PostFilterResult , * framework.Status ) {
679
679
if ! pl .enabled {
680
680
return nil , framework .NewStatus (framework .Unschedulable , "plugin disabled" )
681
681
}
@@ -708,7 +708,7 @@ func (pl *dynamicResources) PostFilter(ctx context.Context, cs *framework.CycleS
708
708
}
709
709
710
710
// Reserve reserves claims for the pod.
711
- func (pl * dynamicResources ) Reserve (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) (status * framework.Status ) {
711
+ func (pl * DynamicResources ) Reserve (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) (status * framework.Status ) {
712
712
if ! pl .enabled {
713
713
return nil
714
714
}
@@ -784,7 +784,7 @@ func (pl *dynamicResources) Reserve(ctx context.Context, cs *framework.CycleStat
784
784
785
785
// Unreserve clears the ReservedFor field for all claims.
786
786
// It's idempotent, and does nothing if no state found for the given pod.
787
- func (pl * dynamicResources ) Unreserve (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) {
787
+ func (pl * DynamicResources ) Unreserve (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) {
788
788
if ! pl .enabled {
789
789
return
790
790
}
@@ -832,7 +832,7 @@ func (pl *dynamicResources) Unreserve(ctx context.Context, cs *framework.CycleSt
832
832
// If anything fails, we return an error and
833
833
// the pod will have to go into the backoff queue. The scheduler will call
834
834
// Unreserve as part of the error handling.
835
- func (pl * dynamicResources ) PreBind (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) * framework.Status {
835
+ func (pl * DynamicResources ) PreBind (ctx context.Context , cs * framework.CycleState , pod * v1.Pod , nodeName string ) * framework.Status {
836
836
if ! pl .enabled {
837
837
return nil
838
838
}
@@ -863,7 +863,7 @@ func (pl *dynamicResources) PreBind(ctx context.Context, cs *framework.CycleStat
863
863
// bindClaim gets called by PreBind for claim which is not reserved for the pod yet.
864
864
// It might not even be allocated. bindClaim then ensures that the allocation
865
865
// and reservation are recorded. This finishes the work started in Reserve.
866
- func (pl * dynamicResources ) bindClaim (ctx context.Context , state * stateData , index int , pod * v1.Pod , nodeName string ) (patchedClaim * resourceapi.ResourceClaim , finalErr error ) {
866
+ func (pl * DynamicResources ) bindClaim (ctx context.Context , state * stateData , index int , pod * v1.Pod , nodeName string ) (patchedClaim * resourceapi.ResourceClaim , finalErr error ) {
867
867
logger := klog .FromContext (ctx )
868
868
claim := state .claims [index ].DeepCopy ()
869
869
allocation := state .informationsForClaim [index ].allocation
0 commit comments