From 351b08423fa331e58522f665a83baae67c0047b5 Mon Sep 17 00:00:00 2001 From: "wangjianyu.wjy" Date: Fri, 15 Mar 2024 16:00:49 +0800 Subject: [PATCH] scheduler: give more context to device allocator Signed-off-by: wangjianyu.wjy --- pkg/scheduler/plugins/deviceshare/device_allocator.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/scheduler/plugins/deviceshare/device_allocator.go b/pkg/scheduler/plugins/deviceshare/device_allocator.go index f70d6d9936..0bf5d93044 100644 --- a/pkg/scheduler/plugins/deviceshare/device_allocator.go +++ b/pkg/scheduler/plugins/deviceshare/device_allocator.go @@ -59,6 +59,8 @@ type requestContext struct { required map[schedulingv1alpha1.DeviceType]sets.Int preferred map[schedulingv1alpha1.DeviceType]sets.Int allocationScorer *resourceAllocationScorer + nodeDevice *nodeDevice + allocateByTopology bool } type AutopilotAllocator struct { @@ -113,6 +115,7 @@ func (a *AutopilotAllocator) Allocate( allocationScorer: a.scorer, required: required, preferred: preferred, + nodeDevice: a.nodeDevice, } deviceAllocations, status := a.tryJointAllocate(requestCtx, a.state.jointAllocate, nodeDevice) @@ -210,6 +213,10 @@ func (a *AutopilotAllocator) tryJointAllocate(requestCtx *requestContext, jointA } func (a *AutopilotAllocator) allocateByTopology(requestCtx *requestContext, nodeDevice *nodeDevice, topologyGuide *deviceTopologyGuide, primaryDeviceType schedulingv1alpha1.DeviceType, jointAllocate *apiext.DeviceJointAllocate, secondaryDeviceTypes []schedulingv1alpha1.DeviceType) (apiext.DeviceAllocations, *framework.Status) { + requestCtx.allocateByTopology = true + defer func() { + requestCtx.allocateByTopology = false + }() desiredCount := requestCtx.desiredCountPerDeviceType[primaryDeviceType] if desiredCount == 0 { return nil, nil @@ -236,6 +243,7 @@ func (a *AutopilotAllocator) allocateByTopology(requestCtx *requestContext, node // TODO(joseph): Currently, scenarios with multiple sockets and multiple nodes are not supported + requestCtx.allocateByTopology = false // In this case, we can only try to allocate jointly from the whole machine dimension and try to allocate them together as much as possible. var preferredPCIes sets.String for _, group := range groupedNodeDevices {