Skip to content

Commit dfb8ab6

Browse files
committed
DRA scheduler: fail in PreFilter when DRAPrioritizedList is disabled and used
This was previously caught during Filter by the allocator check. Doing it sooner avoids wasting resources on a pod which ultimately cannot get scheduled. While at it, be a bit more clear about which feature is disabled. The user might not know that.
1 parent 672f57e commit dfb8ab6

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ func (pl *DynamicResources) PreFilter(ctx context.Context, state *framework.Cycl
415415
return nil, status
416416
}
417417
} else {
418+
if !pl.enablePrioritizedList {
419+
return nil, statusUnschedulable(logger, fmt.Sprintf("resource claim %s, request %s: has subrequests, but the DRAPrioritizedList feature is disabled", klog.KObj(claim), request.Name))
420+
}
418421
for _, subRequest := range request.FirstAvailable {
419422
qualRequestName := strings.Join([]string{request.Name, subRequest.Name}, "/")
420423
if status := pl.validateDeviceClass(logger, subRequest.DeviceClassName, qualRequestName); status != nil {

pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,11 @@ func TestPlugin(t *testing.T) {
861861
claims: []*resourceapi.ResourceClaim{claimWithPrioritzedList},
862862
classes: []*resourceapi.DeviceClass{deviceClass},
863863
want: want{
864-
filter: perNodeResult{
865-
workerNode.Name: {
866-
status: framework.NewStatus(framework.UnschedulableAndUnresolvable, `claim default/my-pod-my-resource, request req-1: has subrequests, but the feature is disabled`),
867-
},
864+
prefilter: result{
865+
status: framework.NewStatus(framework.UnschedulableAndUnresolvable, `claim default/my-pod-my-resource, request req-1: has subrequests, but the DRAPrioritizedList feature is disabled`),
866+
},
867+
postfilter: result{
868+
status: framework.NewStatus(framework.Unschedulable, `no new claims to deallocate`),
868869
},
869870
},
870871
},

staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (a *Allocator) Allocate(ctx context.Context, node *v1.Node) (finalResult []
171171
// Error out if the prioritizedList feature is not enabled and the request
172172
// has subrequests. This is to avoid surprising behavior for users.
173173
if !a.prioritizedListEnabled && hasSubRequests {
174-
return nil, fmt.Errorf("claim %s, request %s: has subrequests, but the feature is disabled", klog.KObj(claim), request.Name)
174+
return nil, fmt.Errorf("claim %s, request %s: has subrequests, but the DRAPrioritizedList feature is disabled", klog.KObj(claim), request.Name)
175175
}
176176

177177
if hasSubRequests {

0 commit comments

Comments
 (0)