From dfb8ab6521019995a708564989cf8f4620e6b896 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 6 Mar 2025 12:55:03 +0100 Subject: [PATCH] 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. --- .../plugins/dynamicresources/dynamicresources.go | 3 +++ .../plugins/dynamicresources/dynamicresources_test.go | 9 +++++---- .../dynamic-resource-allocation/structured/allocator.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go index 171e17e7c68..3b792d0bd17 100644 --- a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go +++ b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources.go @@ -415,6 +415,9 @@ func (pl *DynamicResources) PreFilter(ctx context.Context, state *framework.Cycl return nil, status } } else { + if !pl.enablePrioritizedList { + return nil, statusUnschedulable(logger, fmt.Sprintf("resource claim %s, request %s: has subrequests, but the DRAPrioritizedList feature is disabled", klog.KObj(claim), request.Name)) + } for _, subRequest := range request.FirstAvailable { qualRequestName := strings.Join([]string{request.Name, subRequest.Name}, "/") if status := pl.validateDeviceClass(logger, subRequest.DeviceClassName, qualRequestName); status != nil { diff --git a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go index dd79e6dcaca..0b85ac77aac 100644 --- a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go +++ b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go @@ -861,10 +861,11 @@ func TestPlugin(t *testing.T) { claims: []*resourceapi.ResourceClaim{claimWithPrioritzedList}, classes: []*resourceapi.DeviceClass{deviceClass}, want: want{ - filter: perNodeResult{ - workerNode.Name: { - status: framework.NewStatus(framework.UnschedulableAndUnresolvable, `claim default/my-pod-my-resource, request req-1: has subrequests, but the feature is disabled`), - }, + prefilter: result{ + status: framework.NewStatus(framework.UnschedulableAndUnresolvable, `claim default/my-pod-my-resource, request req-1: has subrequests, but the DRAPrioritizedList feature is disabled`), + }, + postfilter: result{ + status: framework.NewStatus(framework.Unschedulable, `no new claims to deallocate`), }, }, }, diff --git a/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go b/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go index 0068a0e5e79..4a4b5add94b 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go @@ -171,7 +171,7 @@ func (a *Allocator) Allocate(ctx context.Context, node *v1.Node) (finalResult [] // Error out if the prioritizedList feature is not enabled and the request // has subrequests. This is to avoid surprising behavior for users. if !a.prioritizedListEnabled && hasSubRequests { - return nil, fmt.Errorf("claim %s, request %s: has subrequests, but the feature is disabled", klog.KObj(claim), request.Name) + return nil, fmt.Errorf("claim %s, request %s: has subrequests, but the DRAPrioritizedList feature is disabled", klog.KObj(claim), request.Name) } if hasSubRequests {