Skip to content

Commit

Permalink
scheduler: correct NodeNUMAResource handling with NodeFullPCPUsOnly a…
Browse files Browse the repository at this point in the history
…nd preferredCPUBindPolicy

Signed-off-by: Joseph <joseph.t.lee@outlook.com>
  • Loading branch information
eahydra committed Feb 4, 2024
1 parent 451740f commit 8544dd0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
8 changes: 5 additions & 3 deletions pkg/scheduler/plugins/nodenumaresource/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
32 changes: 28 additions & 4 deletions pkg/scheduler/plugins/nodenumaresource/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
Expand All @@ -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{
Expand Down

0 comments on commit 8544dd0

Please sign in to comment.