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