From 214f41c5e6629863487bfa9f671546ae89f5a04d Mon Sep 17 00:00:00 2001 From: wangjianyu Date: Wed, 16 Oct 2024 10:41:23 +0800 Subject: [PATCH] scheduler: allocate tolerate numa-meaning-less device (#2226) Signed-off-by: wangjianyu.wjy Co-authored-by: wangjianyu.wjy --- pkg/scheduler/plugins/deviceshare/device_allocator.go | 2 +- pkg/scheduler/plugins/deviceshare/numa_topology.go | 2 +- pkg/scheduler/plugins/deviceshare/topology_hint.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/scheduler/plugins/deviceshare/device_allocator.go b/pkg/scheduler/plugins/deviceshare/device_allocator.go index e54c7f58a..7c73511ad 100644 --- a/pkg/scheduler/plugins/deviceshare/device_allocator.go +++ b/pkg/scheduler/plugins/deviceshare/device_allocator.go @@ -143,7 +143,7 @@ func (a *AutopilotAllocator) filterNodeDevice( for _, deviceInfo := range deviceInfos { // TODO if a.numaNodes == nil && selector == nil return all device of this deviceType if a.numaNodes != nil { - if deviceInfo.Topology == nil || !a.numaNodes.IsSet(int(deviceInfo.Topology.NodeID)) { + if deviceInfo.Topology == nil || (deviceInfo.Topology.NodeID != -1 && !a.numaNodes.IsSet(int(deviceInfo.Topology.NodeID))) { continue } } diff --git a/pkg/scheduler/plugins/deviceshare/numa_topology.go b/pkg/scheduler/plugins/deviceshare/numa_topology.go index 04fca7e95..18aee9956 100644 --- a/pkg/scheduler/plugins/deviceshare/numa_topology.go +++ b/pkg/scheduler/plugins/deviceshare/numa_topology.go @@ -43,7 +43,7 @@ func newNUMATopology(deviceObj *schedulingv1alpha1.Device) *NUMATopology { devicesInPCIe := map[PCIeIndex]map[schedulingv1alpha1.DeviceType][]int{} for i := range deviceObj.Spec.Devices { deviceInfo := &deviceObj.Spec.Devices[i] - if deviceInfo.Topology == nil { + if deviceInfo.Topology == nil || deviceInfo.Topology.NodeID == -1 { // // NOTE: By default, it must be assigned according to the topology, // and the Required/Preferred strategy should be provided later. diff --git a/pkg/scheduler/plugins/deviceshare/topology_hint.go b/pkg/scheduler/plugins/deviceshare/topology_hint.go index e43a515b1..520c8c66f 100644 --- a/pkg/scheduler/plugins/deviceshare/topology_hint.go +++ b/pkg/scheduler/plugins/deviceshare/topology_hint.go @@ -147,7 +147,7 @@ func (p *Plugin) generateTopologyHints(cycleState *framework.CycleState, state * maskNodes := mask.GetBits() totalDevices := calcTotalDevicesByNUMA(nodeDevice, maskNodes) for deviceType, wanted := range allocator.desiredCountPerDeviceType { - if totalDevices[deviceType] < wanted { + if totalCount, exists := totalDevices[deviceType]; exists && totalCount < wanted { return } }