From 8544dd00f7a63254c67a77e30c1f5eed082f5aa0 Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 4 Feb 2024 15:18:11 +0800 Subject: [PATCH] scheduler: correct NodeNUMAResource handling with NodeFullPCPUsOnly and preferredCPUBindPolicy Signed-off-by: Joseph --- .../plugins/nodenumaresource/plugin.go | 8 +++-- .../plugins/nodenumaresource/plugin_test.go | 32 ++++++++++++++++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/pkg/scheduler/plugins/nodenumaresource/plugin.go b/pkg/scheduler/plugins/nodenumaresource/plugin.go index dd618c8c4..f12220e47 100644 --- a/pkg/scheduler/plugins/nodenumaresource/plugin.go +++ b/pkg/scheduler/plugins/nodenumaresource/plugin.go @@ -308,9 +308,11 @@ func (p *Plugin) Filter(ctx context.Context, cycleState *framework.CycleState, p return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrSMTAlignmentError) } - if nodeRequiredFullPCPUsOnly && - (state.requiredCPUBindPolicy != schedulingconfig.CPUBindPolicyFullPCPUs || state.preferredCPUBindPolicy != schedulingconfig.CPUBindPolicyFullPCPUs) { - return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrRequiredFullPCPUsPolicy) + if nodeRequiredFullPCPUsOnly { + if (state.requiredCPUBindPolicy != "" && state.requiredCPUBindPolicy != schedulingconfig.CPUBindPolicyFullPCPUs) || + (state.preferredCPUBindPolicy != "" && state.preferredCPUBindPolicy != schedulingconfig.CPUBindPolicyFullPCPUs) { + return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrRequiredFullPCPUsPolicy) + } } } diff --git a/pkg/scheduler/plugins/nodenumaresource/plugin_test.go b/pkg/scheduler/plugins/nodenumaresource/plugin_test.go index fbd767d09..0bbdf1bcb 100644 --- a/pkg/scheduler/plugins/nodenumaresource/plugin_test.go +++ b/pkg/scheduler/plugins/nodenumaresource/plugin_test.go @@ -593,7 +593,7 @@ func TestPlugin_Filter(t *testing.T) { want: nil, }, { - name: "verify FullPCPUsOnly with SMTAlignmentError", + name: "failed to verify Node FullPCPUsOnly with SMTAlignmentError", nodeLabels: map[string]string{ extension.LabelNodeCPUBindPolicy: string(extension.NodeCPUBindPolicyFullPCPUsOnly), }, @@ -607,17 +607,41 @@ func TestPlugin_Filter(t *testing.T) { want: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrSMTAlignmentError), }, { - name: "verify required FullPCPUs SMTAlignmentError", + name: "verify Node FullPCPUsOnly", + nodeLabels: map[string]string{ + extension.LabelNodeCPUBindPolicy: string(extension.NodeCPUBindPolicyFullPCPUsOnly), + }, state: &preFilterState{ requestCPUBind: true, - requiredCPUBindPolicy: schedulingconfig.CPUBindPolicyFullPCPUs, preferredCPUBindPolicy: schedulingconfig.CPUBindPolicyFullPCPUs, - numCPUsNeeded: 5, + numCPUsNeeded: 4, + }, + cpuTopology: buildCPUTopologyForTest(2, 1, 4, 2), + allocationState: NewNodeAllocation("test-node-1"), + want: nil, + }, + { + name: "failed to verify required FullPCPUs SMTAlignmentError", + state: &preFilterState{ + requestCPUBind: true, + requiredCPUBindPolicy: schedulingconfig.CPUBindPolicyFullPCPUs, + numCPUsNeeded: 5, }, cpuTopology: buildCPUTopologyForTest(2, 1, 4, 2), allocationState: NewNodeAllocation("test-node-1"), want: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrSMTAlignmentError), }, + { + name: "verify required FullPCPUs", + state: &preFilterState{ + requestCPUBind: true, + requiredCPUBindPolicy: schedulingconfig.CPUBindPolicyFullPCPUs, + numCPUsNeeded: 4, + }, + cpuTopology: buildCPUTopologyForTest(2, 1, 4, 2), + allocationState: NewNodeAllocation("test-node-1"), + want: nil, + }, { name: "verify FullPCPUsOnly with preferred SpreadByPCPUs", nodeLabels: map[string]string{