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 f089122
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
13 changes: 8 additions & 5 deletions pkg/scheduler/plugins/nodenumaresource/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,18 @@ func (p *Plugin) Filter(ctx context.Context, cycleState *framework.CycleState, p
if !topologyOptions.CPUTopology.IsValid() {
return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrInvalidCPUTopology)
}
nodeRequiredFullPCPUsOnly := extension.GetNodeCPUBindPolicy(node.Labels, topologyOptions.Policy) == extension.NodeCPUBindPolicyFullPCPUsOnly
if nodeRequiredFullPCPUsOnly || state.requiredCPUBindPolicy == schedulingconfig.CPUBindPolicyFullPCPUs {
nodeCPUBindPolicy := extension.GetNodeCPUBindPolicy(node.Labels, topologyOptions.Policy)
if nodeCPUBindPolicy == extension.NodeCPUBindPolicyFullPCPUsOnly ||
state.requiredCPUBindPolicy == schedulingconfig.CPUBindPolicyFullPCPUs {
if state.numCPUsNeeded%topologyOptions.CPUTopology.CPUsPerCore() != 0 {
return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrSMTAlignmentError)
}

if nodeRequiredFullPCPUsOnly &&
(state.requiredCPUBindPolicy != schedulingconfig.CPUBindPolicyFullPCPUs || state.preferredCPUBindPolicy != schedulingconfig.CPUBindPolicyFullPCPUs) {
return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrRequiredFullPCPUsPolicy)
if nodeCPUBindPolicy == extension.NodeCPUBindPolicyFullPCPUsOnly {
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 f089122

Please sign in to comment.