diff --git a/pkg/scheduler/apis/config/types.go b/pkg/scheduler/apis/config/types.go index 2793d7949..2545120a2 100644 --- a/pkg/scheduler/apis/config/types.go +++ b/pkg/scheduler/apis/config/types.go @@ -219,4 +219,6 @@ type DeviceShareArgs struct { Allocator string // ScoringStrategy selects the device resource scoring strategy. ScoringStrategy *ScoringStrategy + // DisableDeviceNUMATopologyAlignment indicates device don't need to align with other resources' numa topology + DisableDeviceNUMATopologyAlignment bool } diff --git a/pkg/scheduler/apis/config/v1beta3/types.go b/pkg/scheduler/apis/config/v1beta3/types.go index 12c35924c..b194264fb 100644 --- a/pkg/scheduler/apis/config/v1beta3/types.go +++ b/pkg/scheduler/apis/config/v1beta3/types.go @@ -214,4 +214,6 @@ type DeviceShareArgs struct { Allocator string `json:"allocator,omitempty"` // ScoringStrategy selects the device resource scoring strategy. ScoringStrategy *ScoringStrategy `json:"scoringStrategy,omitempty"` + // DisableDeviceNUMATopologyAlignment indicates device don't need to align with other resources' numa topology + DisableDeviceNUMATopologyAlignment bool `json:"disableDeviceNUMATopologyAlignment,omitempty"` } diff --git a/pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go b/pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go index 49cd0f181..1340a4e2b 100644 --- a/pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go +++ b/pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go @@ -163,6 +163,7 @@ func Convert_config_CoschedulingArgs_To_v1beta3_CoschedulingArgs(in *config.Cosc func autoConvert_v1beta3_DeviceShareArgs_To_config_DeviceShareArgs(in *DeviceShareArgs, out *config.DeviceShareArgs, s conversion.Scope) error { out.Allocator = in.Allocator out.ScoringStrategy = (*config.ScoringStrategy)(unsafe.Pointer(in.ScoringStrategy)) + out.DisableDeviceNUMATopologyAlignment = in.DisableDeviceNUMATopologyAlignment return nil } @@ -174,6 +175,7 @@ func Convert_v1beta3_DeviceShareArgs_To_config_DeviceShareArgs(in *DeviceShareAr func autoConvert_config_DeviceShareArgs_To_v1beta3_DeviceShareArgs(in *config.DeviceShareArgs, out *DeviceShareArgs, s conversion.Scope) error { out.Allocator = in.Allocator out.ScoringStrategy = (*ScoringStrategy)(unsafe.Pointer(in.ScoringStrategy)) + out.DisableDeviceNUMATopologyAlignment = in.DisableDeviceNUMATopologyAlignment return nil } diff --git a/pkg/scheduler/plugins/deviceshare/plugin.go b/pkg/scheduler/plugins/deviceshare/plugin.go index 82945864c..3706fc20b 100644 --- a/pkg/scheduler/plugins/deviceshare/plugin.go +++ b/pkg/scheduler/plugins/deviceshare/plugin.go @@ -67,9 +67,10 @@ var ( ) type Plugin struct { - handle frameworkext.ExtendedHandle - nodeDeviceCache *nodeDeviceCache - scorer *resourceAllocationScorer + disableDeviceNUMATopologyAlignment bool + handle frameworkext.ExtendedHandle + nodeDeviceCache *nodeDeviceCache + scorer *resourceAllocationScorer } type preFilterState struct { @@ -292,8 +293,11 @@ func (p *Plugin) Filter(ctx context.Context, cycleState *framework.CycleState, p restoreState := reservationRestoreState.getNodeState(node.Name) preemptible := appendAllocated(nil, restoreState.mergedUnmatchedUsed, state.preemptibleDevices[node.Name]) - store := topologymanager.GetStore(cycleState) - affinity := store.GetAffinity(node.Name) + var affinity topologymanager.NUMATopologyHint + if !p.disableDeviceNUMATopologyAlignment { + store := topologymanager.GetStore(cycleState) + affinity = store.GetAffinity(nodeInfo.Node().Name) + } allocator := &AutopilotAllocator{ state: state, @@ -302,6 +306,9 @@ func (p *Plugin) Filter(ctx context.Context, cycleState *framework.CycleState, p pod: pod, numaNodes: affinity.NUMANodeAffinity, } + if !p.disableDeviceNUMATopologyAlignment { + allocator.numaNodes = nil + } nodeDeviceInfo.lock.RLock() defer nodeDeviceInfo.lock.RUnlock() @@ -354,8 +361,11 @@ func (p *Plugin) FilterReservation(ctx context.Context, cycleState *framework.Cy return nil } - store := topologymanager.GetStore(cycleState) - affinity := store.GetAffinity(nodeInfo.Node().Name) + var affinity topologymanager.NUMATopologyHint + if !p.disableDeviceNUMATopologyAlignment { + store := topologymanager.GetStore(cycleState) + affinity = store.GetAffinity(nodeInfo.Node().Name) + } allocator := &AutopilotAllocator{ state: state, @@ -393,8 +403,11 @@ func (p *Plugin) Reserve(ctx context.Context, cycleState *framework.CycleState, return nil } - store := topologymanager.GetStore(cycleState) - affinity := store.GetAffinity(nodeInfo.Node().Name) + var affinity topologymanager.NUMATopologyHint + if !p.disableDeviceNUMATopologyAlignment { + store := topologymanager.GetStore(cycleState) + affinity = store.GetAffinity(nodeInfo.Node().Name) + } allocator := &AutopilotAllocator{ state: state, @@ -559,8 +572,9 @@ func New(obj runtime.Object, handle framework.Handle) (framework.Plugin, error) go deviceCache.gcNodeDevice(context.TODO(), handle.SharedInformerFactory(), defaultGCPeriod) return &Plugin{ - handle: extendedHandle, - nodeDeviceCache: deviceCache, - scorer: scorePlugin(args), + handle: extendedHandle, + nodeDeviceCache: deviceCache, + scorer: scorePlugin(args), + disableDeviceNUMATopologyAlignment: args.DisableDeviceNUMATopologyAlignment, }, nil } diff --git a/pkg/scheduler/plugins/deviceshare/topology_hint.go b/pkg/scheduler/plugins/deviceshare/topology_hint.go index a3cd4905b..5aa2c4917 100644 --- a/pkg/scheduler/plugins/deviceshare/topology_hint.go +++ b/pkg/scheduler/plugins/deviceshare/topology_hint.go @@ -31,6 +31,9 @@ import ( ) func (p *Plugin) GetPodTopologyHints(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string) (map[string][]topologymanager.NUMATopologyHint, *framework.Status) { + if p.disableDeviceNUMATopologyAlignment { + return nil, nil + } state, status := getPreFilterState(cycleState) if !status.IsSuccess() { return nil, status @@ -55,6 +58,9 @@ func (p *Plugin) GetPodTopologyHints(ctx context.Context, cycleState *framework. } func (p *Plugin) Allocate(ctx context.Context, cycleState *framework.CycleState, affinity topologymanager.NUMATopologyHint, pod *corev1.Pod, nodeName string) *framework.Status { + if p.disableDeviceNUMATopologyAlignment { + return nil + } state, status := getPreFilterState(cycleState) if !status.IsSuccess() { return status