From 8e0a3ba1e0b611d1c40dffb9ab29e0444be59aa9 Mon Sep 17 00:00:00 2001 From: "wangjianyu.wjy" Date: Tue, 27 Aug 2024 16:55:15 +0800 Subject: [PATCH] scheduler: assure only gpu will allocate by topology Signed-off-by: wangjianyu.wjy --- .../plugins/deviceshare/device_allocator.go | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pkg/scheduler/plugins/deviceshare/device_allocator.go b/pkg/scheduler/plugins/deviceshare/device_allocator.go index d93059970..435df555e 100644 --- a/pkg/scheduler/plugins/deviceshare/device_allocator.go +++ b/pkg/scheduler/plugins/deviceshare/device_allocator.go @@ -366,13 +366,24 @@ func (a *AutopilotAllocator) allocateDevices(requestCtx *requestContext, nodeDev if deviceAllocations[deviceType] != nil { continue } - topologyGuide := newDeviceTopologyGuide(nodeDevice, requestCtx.requestsPerInstance, deviceType, nil) - allocations, status := a.allocateByTopology(requestCtx, nodeDevice, topologyGuide, deviceType, nil, nil) - if !status.IsSuccess() { - return nil, status - } - if len(allocations) != 0 && len(allocations[deviceType]) != 0 { - deviceAllocations[deviceType] = allocations[deviceType] + if deviceType != schedulingv1alpha1.GPU { + allocations, status := allocateDevices(requestCtx, nodeDevice, deviceType, requestCtx.requestsPerInstance[deviceType], requestCtx.desiredCountPerDeviceType[deviceType], nil) + if !status.IsSuccess() { + return nil, status + } + if len(allocations) != 0 { + deviceAllocations[deviceType] = allocations + } + } else { + // assure only gpu will allocate by topology + topologyGuide := newDeviceTopologyGuide(nodeDevice, requestCtx.requestsPerInstance, deviceType, nil) + allocations, status := a.allocateByTopology(requestCtx, nodeDevice, topologyGuide, deviceType, nil, nil) + if !status.IsSuccess() { + return nil, status + } + if len(allocations) != 0 && len(allocations[deviceType]) != 0 { + deviceAllocations[deviceType] = allocations[deviceType] + } } } return deviceAllocations, nil