From 4f7db67627c70c50fed11731013df4cc04fd4279 Mon Sep 17 00:00:00 2001 From: KunWuLuan Date: Mon, 25 Mar 2024 15:39:20 +0800 Subject: [PATCH] use CamelCase Signed-off-by: KunWuLuan --- apis/extension/numa_aware.go | 34 ++++++------- .../frameworkext/framework_extender.go | 2 +- pkg/scheduler/frameworkext/interface.go | 2 +- .../frameworkext/topologymanager/manager.go | 14 +++--- .../frameworkext/topologymanager/policy.go | 12 ++--- .../topologymanager/policy_best_effort.go | 2 +- .../topologymanager/policy_none.go | 2 +- .../topologymanager/policy_none_test.go | 2 +- .../topologymanager/policy_restricted.go | 2 +- .../policy_single_numa_node.go | 2 +- .../topologymanager/policy_test.go | 50 +++++++++---------- .../nodenumaresource/node_allocation.go | 12 ++--- .../plugins/nodenumaresource/plugin.go | 12 ++--- .../plugins/nodenumaresource/plugin_test.go | 16 +++--- .../plugins/nodenumaresource/scoring.go | 2 +- .../plugins/nodenumaresource/scoring_test.go | 20 ++++---- .../plugins/nodenumaresource/topology_hint.go | 4 +- .../nodenumaresource/topology_hint_test.go | 2 +- .../nodenumaresource/topology_options.go | 12 ++--- .../plugins/nodenumaresource/util.go | 6 +-- .../plugins/nodenumaresource/util_test.go | 24 ++++----- test/e2e/scheduling/nodenumaresource.go | 28 +++++------ 22 files changed, 131 insertions(+), 131 deletions(-) diff --git a/apis/extension/numa_aware.go b/apis/extension/numa_aware.go index 9be740bc3..4b1b947a6 100644 --- a/apis/extension/numa_aware.go +++ b/apis/extension/numa_aware.go @@ -59,11 +59,11 @@ const ( // ResourceSpec describes extra attributes of the resource requirements. type ResourceSpec struct { // NumaTopologyPolicy represents the numa topology policy when schedule pod - NumaTopologyPolicy NUMATopologyPolicy `json:"numaTopologyPolicy,omitempty"` + NumaTopologyPolicy NumaTopologyPolicy `json:"numaTopologyPolicy,omitempty"` // SingleNUMANodeExclusive represents whether a Pod that will use a single NUMA node/multiple NUMA nodes // on a NUMA node can be scheduled to use the NUMA node when another Pod that uses multiple NUMA nodes/a single NUMA node // is already running on the same node. - SingleNUMANodeExclusive NUMATopologyExclusive `json:"singleNUMANodeExclusive,omitempty"` + SingleNUMANodeExclusive NumaTopologyExclusive `json:"singleNUMANodeExclusive,omitempty"` // RequiredCPUBindPolicy indicates that the CPU is allocated strictly // according to the specified CPUBindPolicy, otherwise the scheduling fails RequiredCPUBindPolicy CPUBindPolicy `json:"requiredCPUBindPolicy,omitempty"` @@ -141,28 +141,28 @@ const ( NodeNUMAAllocateStrategyMostAllocated = NUMAMostAllocated ) -type NUMATopologyExclusive string +type NumaTopologyExclusive string const ( - NUMATopologyExclusivePreferred NUMATopologyExclusive = "Preferred" - NUMATopologyExclusiveRequired NUMATopologyExclusive = "Required" + NumaTopologyExclusivePreferred NumaTopologyExclusive = "Preferred" + NumaTopologyExclusiveRequired NumaTopologyExclusive = "Required" ) -type NUMANodeStatus string +type NumaNodeStatus string const ( - NUMANodeStatusIdle NUMANodeStatus = "idle" - NUMANodeStatusShared NUMANodeStatus = "shared" - NUMANodeStatusSingle NUMANodeStatus = "single" + NumaNodeStatusIdle NumaNodeStatus = "idle" + NumaNodeStatusShared NumaNodeStatus = "shared" + NumaNodeStatusSingle NumaNodeStatus = "single" ) -type NUMATopologyPolicy string +type NumaTopologyPolicy string const ( - NUMATopologyPolicyNone NUMATopologyPolicy = "" - NUMATopologyPolicyBestEffort NUMATopologyPolicy = "BestEffort" - NUMATopologyPolicyRestricted NUMATopologyPolicy = "Restricted" - NUMATopologyPolicySingleNUMANode NUMATopologyPolicy = "SingleNUMANode" + NumaTopologyPolicyNone NumaTopologyPolicy = "" + NumaTopologyPolicyBestEffort NumaTopologyPolicy = "BestEffort" + NumaTopologyPolicyRestricted NumaTopologyPolicy = "Restricted" + NumaTopologyPolicySingleNUMANode NumaTopologyPolicy = "SingleNUMANode" ) const ( @@ -345,11 +345,11 @@ func GetNodeCPUBindPolicy(nodeLabels map[string]string, kubeletCPUPolicy *Kubele return NodeCPUBindPolicyNone } -func GetNodeNUMATopologyPolicy(labels map[string]string) NUMATopologyPolicy { - return NUMATopologyPolicy(labels[LabelNUMATopologyPolicy]) +func GetNodeNUMATopologyPolicy(labels map[string]string) NumaTopologyPolicy { + return NumaTopologyPolicy(labels[LabelNUMATopologyPolicy]) } -func SetNodeNUMATopologyPolicy(obj metav1.Object, policy NUMATopologyPolicy) { +func SetNodeNUMATopologyPolicy(obj metav1.Object, policy NumaTopologyPolicy) { labels := obj.GetLabels() if labels == nil { labels = map[string]string{} diff --git a/pkg/scheduler/frameworkext/framework_extender.go b/pkg/scheduler/frameworkext/framework_extender.go index f00d24c94..e4244be0e 100644 --- a/pkg/scheduler/frameworkext/framework_extender.go +++ b/pkg/scheduler/frameworkext/framework_extender.go @@ -445,7 +445,7 @@ func (ext *frameworkExtenderImpl) ForgetPod(pod *corev1.Pod) error { return nil } -func (ext *frameworkExtenderImpl) RunNUMATopologyManagerAdmit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NUMATopologyPolicy, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) *framework.Status { +func (ext *frameworkExtenderImpl) RunNUMATopologyManagerAdmit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NumaTopologyPolicy, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) *framework.Status { return ext.topologyManager.Admit(ctx, cycleState, pod, nodeName, numaNodes, policyType, exclusivePolicy, allNUMANodeStatus) } diff --git a/pkg/scheduler/frameworkext/interface.go b/pkg/scheduler/frameworkext/interface.go index 408298d26..4584071c0 100644 --- a/pkg/scheduler/frameworkext/interface.go +++ b/pkg/scheduler/frameworkext/interface.go @@ -64,7 +64,7 @@ type FrameworkExtender interface { RunReservationFilterPlugins(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, reservationInfo *ReservationInfo, nodeName string) *framework.Status RunReservationScorePlugins(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, reservationInfos []*ReservationInfo, nodeName string) (PluginToReservationScores, *framework.Status) - RunNUMATopologyManagerAdmit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NUMATopologyPolicy, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) *framework.Status + RunNUMATopologyManagerAdmit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NumaTopologyPolicy, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) *framework.Status RunResizePod(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string) *framework.Status } diff --git a/pkg/scheduler/frameworkext/topologymanager/manager.go b/pkg/scheduler/frameworkext/topologymanager/manager.go index 4cfdc6741..b392c6764 100644 --- a/pkg/scheduler/frameworkext/topologymanager/manager.go +++ b/pkg/scheduler/frameworkext/topologymanager/manager.go @@ -27,7 +27,7 @@ import ( ) type Interface interface { - Admit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NUMATopologyPolicy, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) *framework.Status + Admit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NumaTopologyPolicy, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) *framework.Status } type NUMATopologyHintProvider interface { @@ -55,7 +55,7 @@ func New(hintProviderFactory NUMATopologyHintProviderFactory) Interface { } } -func (m *topologyManager) Admit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NUMATopologyPolicy, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) *framework.Status { +func (m *topologyManager) Admit(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, numaNodes []int, policyType apiext.NumaTopologyPolicy, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) *framework.Status { s, err := cycleState.Read(affinityStateKey) if err != nil { return framework.AsStatus(err) @@ -79,7 +79,7 @@ func (m *topologyManager) Admit(ctx context.Context, cycleState *framework.Cycle return nil } -func (m *topologyManager) calculateAffinity(ctx context.Context, cycleState *framework.CycleState, policy Policy, pod *corev1.Pod, nodeName string, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) (NUMATopologyHint, bool) { +func (m *topologyManager) calculateAffinity(ctx context.Context, cycleState *framework.CycleState, policy Policy, pod *corev1.Pod, nodeName string, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) (NUMATopologyHint, bool) { providersHints := m.accumulateProvidersHints(ctx, cycleState, pod, nodeName) bestHint, admit := policy.Merge(providersHints, exclusivePolicy, allNUMANodeStatus) if !checkExclusivePolicy(bestHint, exclusivePolicy, allNUMANodeStatus) { @@ -114,14 +114,14 @@ func (m *topologyManager) allocateResources(ctx context.Context, cycleState *fra return nil } -func createNUMATopologyPolicy(policyType apiext.NUMATopologyPolicy, numaNodes []int) Policy { +func createNUMATopologyPolicy(policyType apiext.NumaTopologyPolicy, numaNodes []int) Policy { var p Policy switch policyType { - case apiext.NUMATopologyPolicyBestEffort: + case apiext.NumaTopologyPolicyBestEffort: p = NewBestEffortPolicy(numaNodes) - case apiext.NUMATopologyPolicyRestricted: + case apiext.NumaTopologyPolicyRestricted: p = NewRestrictedPolicy(numaNodes) - case apiext.NUMATopologyPolicySingleNUMANode: + case apiext.NumaTopologyPolicySingleNUMANode: p = NewSingleNumaNodePolicy(numaNodes) } return p diff --git a/pkg/scheduler/frameworkext/topologymanager/policy.go b/pkg/scheduler/frameworkext/topologymanager/policy.go index 628446f12..6c3c5c7a5 100644 --- a/pkg/scheduler/frameworkext/topologymanager/policy.go +++ b/pkg/scheduler/frameworkext/topologymanager/policy.go @@ -28,7 +28,7 @@ type Policy interface { // Name returns Policy Name Name() string // Merge returns a merged NUMATopologyHint based on input from hint providers - Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) (NUMATopologyHint, bool) + Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) (NUMATopologyHint, bool) } // NUMATopologyHint is a struct containing the NUMANodeAffinity for a Container @@ -64,18 +64,18 @@ func (th *NUMATopologyHint) LessThan(other NUMATopologyHint) bool { } // Check if the affinity match the exclusive policy, return true if match or false otherwise. -func checkExclusivePolicy(affinity NUMATopologyHint, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) bool { +func checkExclusivePolicy(affinity NUMATopologyHint, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) bool { // check bestHint again if default hint is the best - if exclusivePolicy == apiext.NUMATopologyExclusiveRequired { + if exclusivePolicy == apiext.NumaTopologyExclusiveRequired { if affinity.NUMANodeAffinity.Count() > 1 { // we should make sure no numa is in single state for _, nodeid := range affinity.NUMANodeAffinity.GetBits() { - if allNUMANodeStatus[nodeid] == apiext.NUMANodeStatusSingle { + if allNUMANodeStatus[nodeid] == apiext.NumaNodeStatusSingle { return false } } } else { - if allNUMANodeStatus[affinity.NUMANodeAffinity.GetBits()[0]] == apiext.NUMANodeStatusShared { + if allNUMANodeStatus[affinity.NUMANodeAffinity.GetBits()[0]] == apiext.NumaNodeStatusShared { return false } } @@ -145,7 +145,7 @@ func filterProvidersHints(providersHints []map[string][]NUMATopologyHint) [][]NU return allProviderHints } -func mergeFilteredHints(numaNodes []int, filteredHints [][]NUMATopologyHint, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) NUMATopologyHint { +func mergeFilteredHints(numaNodes []int, filteredHints [][]NUMATopologyHint, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) NUMATopologyHint { // Set the default affinity as an any-numa affinity containing the list // of NUMA Nodes available on this machine. defaultAffinity, _ := bitmask.NewBitMask(numaNodes...) diff --git a/pkg/scheduler/frameworkext/topologymanager/policy_best_effort.go b/pkg/scheduler/frameworkext/topologymanager/policy_best_effort.go index 928965700..53cc6c98e 100644 --- a/pkg/scheduler/frameworkext/topologymanager/policy_best_effort.go +++ b/pkg/scheduler/frameworkext/topologymanager/policy_best_effort.go @@ -42,7 +42,7 @@ func (p *bestEffortPolicy) canAdmitPodResult(hint *NUMATopologyHint) bool { return true } -func (p *bestEffortPolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) (NUMATopologyHint, bool) { +func (p *bestEffortPolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) (NUMATopologyHint, bool) { filteredProvidersHints := filterProvidersHints(providersHints) bestHint := mergeFilteredHints(p.numaNodes, filteredProvidersHints, exclusivePolicy, allNUMANodeStatus) admit := p.canAdmitPodResult(&bestHint) diff --git a/pkg/scheduler/frameworkext/topologymanager/policy_none.go b/pkg/scheduler/frameworkext/topologymanager/policy_none.go index 6de365c28..ca12d555b 100644 --- a/pkg/scheduler/frameworkext/topologymanager/policy_none.go +++ b/pkg/scheduler/frameworkext/topologymanager/policy_none.go @@ -39,6 +39,6 @@ func (p *nonePolicy) canAdmitPodResult(hint *NUMATopologyHint) bool { return true } -func (p *nonePolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) (NUMATopologyHint, bool) { +func (p *nonePolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) (NUMATopologyHint, bool) { return NUMATopologyHint{}, p.canAdmitPodResult(nil) } diff --git a/pkg/scheduler/frameworkext/topologymanager/policy_none_test.go b/pkg/scheduler/frameworkext/topologymanager/policy_none_test.go index 7850a75d3..dc86c4149 100644 --- a/pkg/scheduler/frameworkext/topologymanager/policy_none_test.go +++ b/pkg/scheduler/frameworkext/topologymanager/policy_none_test.go @@ -106,7 +106,7 @@ func TestPolicyNoneMerge(t *testing.T) { for _, tc := range tcases { policy := NewNonePolicy() - result, admit := policy.Merge(tc.providersHints, apiext.NUMATopologyExclusivePreferred, []apiext.NUMANodeStatus{}) + result, admit := policy.Merge(tc.providersHints, apiext.NumaTopologyExclusivePreferred, []apiext.NumaNodeStatus{}) if !result.IsEqual(tc.expectedHint) || admit != tc.expectedAdmit { t.Errorf("Test Case: %s: Expected merge hint to be %v, got %v", tc.name, tc.expectedHint, result) } diff --git a/pkg/scheduler/frameworkext/topologymanager/policy_restricted.go b/pkg/scheduler/frameworkext/topologymanager/policy_restricted.go index a7bfc1e55..6d489ea3a 100644 --- a/pkg/scheduler/frameworkext/topologymanager/policy_restricted.go +++ b/pkg/scheduler/frameworkext/topologymanager/policy_restricted.go @@ -41,7 +41,7 @@ func (p *restrictedPolicy) canAdmitPodResult(hint *NUMATopologyHint) bool { return hint.Preferred } -func (p *restrictedPolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) (NUMATopologyHint, bool) { +func (p *restrictedPolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) (NUMATopologyHint, bool) { filteredHints := filterProvidersHints(providersHints) hint := mergeFilteredHints(p.numaNodes, filteredHints, exclusivePolicy, allNUMANodeStatus) admit := p.canAdmitPodResult(&hint) diff --git a/pkg/scheduler/frameworkext/topologymanager/policy_single_numa_node.go b/pkg/scheduler/frameworkext/topologymanager/policy_single_numa_node.go index 194594915..2947bf23b 100644 --- a/pkg/scheduler/frameworkext/topologymanager/policy_single_numa_node.go +++ b/pkg/scheduler/frameworkext/topologymanager/policy_single_numa_node.go @@ -63,7 +63,7 @@ func filterSingleNumaHints(allResourcesHints [][]NUMATopologyHint) [][]NUMATopol return filteredResourcesHints } -func (p *singleNumaNodePolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NUMATopologyExclusive, allNUMANodeStatus []apiext.NUMANodeStatus) (NUMATopologyHint, bool) { +func (p *singleNumaNodePolicy) Merge(providersHints []map[string][]NUMATopologyHint, exclusivePolicy apiext.NumaTopologyExclusive, allNUMANodeStatus []apiext.NumaNodeStatus) (NUMATopologyHint, bool) { filteredHints := filterProvidersHints(providersHints) // Filter to only include don't care and hints with a single NUMA node. singleNumaHints := filterSingleNumaHints(filteredHints) diff --git a/pkg/scheduler/frameworkext/topologymanager/policy_test.go b/pkg/scheduler/frameworkext/topologymanager/policy_test.go index 2a55da896..0e5def87d 100644 --- a/pkg/scheduler/frameworkext/topologymanager/policy_test.go +++ b/pkg/scheduler/frameworkext/topologymanager/policy_test.go @@ -893,7 +893,7 @@ func testPolicyMerge(policy Policy, tcases []policyMergeTestCase, t *testing.T) providersHints = append(providersHints, hints) } - actual, _ := policy.Merge(providersHints, extension.NUMATopologyExclusivePreferred, []extension.NUMANodeStatus{}) + actual, _ := policy.Merge(providersHints, extension.NumaTopologyExclusivePreferred, []extension.NumaNodeStatus{}) if !reflect.DeepEqual(actual, tc.expected) { t.Errorf("%v: Expected Topology Hint to be %v, got %v:", tc.name, tc.expected, actual) } @@ -903,8 +903,8 @@ func testPolicyMerge(policy Policy, tcases []policyMergeTestCase, t *testing.T) func Test_checkExclusivePolicy(t *testing.T) { type args struct { affinity NUMATopologyHint - exclusivePolicy apiext.NUMATopologyExclusive - allNUMANodeStatus []apiext.NUMANodeStatus + exclusivePolicy apiext.NumaTopologyExclusive + allNUMANodeStatus []apiext.NumaNodeStatus } tests := []struct { name string @@ -916,8 +916,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "preferred policy 1", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusivePreferred, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusShared, apiext.NUMANodeStatusShared}, + exclusivePolicy: apiext.NumaTopologyExclusivePreferred, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusShared, apiext.NumaNodeStatusShared}, }, want: true, }, @@ -925,8 +925,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "preferred policy 2", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0, 1), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusivePreferred, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusShared, apiext.NUMANodeStatusShared}, + exclusivePolicy: apiext.NumaTopologyExclusivePreferred, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusShared, apiext.NumaNodeStatusShared}, }, want: true, }, @@ -934,8 +934,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "preferred policy 3", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusivePreferred, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusIdle, apiext.NUMANodeStatusSingle}, + exclusivePolicy: apiext.NumaTopologyExclusivePreferred, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusIdle, apiext.NumaNodeStatusSingle}, }, want: true, }, @@ -943,8 +943,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "preferred policy 4", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0, 1), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusivePreferred, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusIdle, apiext.NUMANodeStatusSingle}, + exclusivePolicy: apiext.NumaTopologyExclusivePreferred, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusIdle, apiext.NumaNodeStatusSingle}, }, want: true, }, @@ -952,8 +952,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "required policy 1", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusiveRequired, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusIdle, apiext.NUMANodeStatusSingle}, + exclusivePolicy: apiext.NumaTopologyExclusiveRequired, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusIdle, apiext.NumaNodeStatusSingle}, }, want: true, }, @@ -961,8 +961,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "required policy 2", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusiveRequired, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusShared, apiext.NUMANodeStatusSingle}, + exclusivePolicy: apiext.NumaTopologyExclusiveRequired, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusShared, apiext.NumaNodeStatusSingle}, }, want: false, }, @@ -970,8 +970,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "required policy 3", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusiveRequired, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusShared, apiext.NUMANodeStatusShared}, + exclusivePolicy: apiext.NumaTopologyExclusiveRequired, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusShared, apiext.NumaNodeStatusShared}, }, want: false, }, @@ -979,8 +979,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "required policy 4", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusiveRequired, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusSingle, apiext.NUMANodeStatusShared}, + exclusivePolicy: apiext.NumaTopologyExclusiveRequired, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusSingle, apiext.NumaNodeStatusShared}, }, want: true, }, @@ -988,8 +988,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "required policy 5", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0, 1), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusiveRequired, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusShared, apiext.NUMANodeStatusSingle}, + exclusivePolicy: apiext.NumaTopologyExclusiveRequired, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusShared, apiext.NumaNodeStatusSingle}, }, want: false, }, @@ -997,8 +997,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "required policy 6", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0, 1), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusiveRequired, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusShared, apiext.NUMANodeStatusIdle}, + exclusivePolicy: apiext.NumaTopologyExclusiveRequired, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusShared, apiext.NumaNodeStatusIdle}, }, want: true, }, @@ -1006,8 +1006,8 @@ func Test_checkExclusivePolicy(t *testing.T) { name: "required policy 7", args: args{ affinity: NUMATopologyHint{NUMANodeAffinity: NewTestBitMask(0, 1), Preferred: true, Score: 0}, - exclusivePolicy: apiext.NUMATopologyExclusiveRequired, - allNUMANodeStatus: []apiext.NUMANodeStatus{apiext.NUMANodeStatusShared, apiext.NUMANodeStatusShared}, + exclusivePolicy: apiext.NumaTopologyExclusiveRequired, + allNUMANodeStatus: []apiext.NumaNodeStatus{apiext.NumaNodeStatusShared, apiext.NumaNodeStatusShared}, }, want: true, }, diff --git a/pkg/scheduler/plugins/nodenumaresource/node_allocation.go b/pkg/scheduler/plugins/nodenumaresource/node_allocation.go index a72ff0709..1dbfaaac5 100644 --- a/pkg/scheduler/plugins/nodenumaresource/node_allocation.go +++ b/pkg/scheduler/plugins/nodenumaresource/node_allocation.go @@ -49,22 +49,22 @@ type PodAllocation struct { NUMANodeResources []NUMANodeResource `json:"numaNodeResources,omitempty"` } -func (n *NodeAllocation) GetAllNUMANodeStatus(numaNodes int) []extension.NUMANodeStatus { - status := make([]extension.NUMANodeStatus, numaNodes) +func (n *NodeAllocation) GetAllNUMANodeStatus(numaNodes int) []extension.NumaNodeStatus { + status := make([]extension.NumaNodeStatus, numaNodes) for i := 0; i < numaNodes; i++ { status = append(status, n.NUMANodeSharedStatus(i)) } return status } -func (n *NodeAllocation) NUMANodeSharedStatus(nodeid int) extension.NUMANodeStatus { +func (n *NodeAllocation) NUMANodeSharedStatus(nodeid int) extension.NumaNodeStatus { if len(n.singleNUMANode[nodeid]) == 0 && len(n.sharedNode[nodeid]) == 0 { - return extension.NUMANodeStatusIdle + return extension.NumaNodeStatusIdle } if len(n.singleNUMANode[nodeid]) > 0 && len(n.sharedNode[nodeid]) == 0 { - return extension.NUMANodeStatusSingle + return extension.NumaNodeStatusSingle } - return extension.NUMANodeStatusShared + return extension.NumaNodeStatusShared } func NewNodeAllocation(nodeName string) *NodeAllocation { diff --git a/pkg/scheduler/plugins/nodenumaresource/plugin.go b/pkg/scheduler/plugins/nodenumaresource/plugin.go index 3d37644c0..c0ebf664e 100644 --- a/pkg/scheduler/plugins/nodenumaresource/plugin.go +++ b/pkg/scheduler/plugins/nodenumaresource/plugin.go @@ -181,8 +181,8 @@ type preFilterState struct { requiredCPUBindPolicy schedulingconfig.CPUBindPolicy preferredCPUBindPolicy schedulingconfig.CPUBindPolicy preferredCPUExclusivePolicy schedulingconfig.CPUExclusivePolicy - podNUMATopologyPolicy extension.NUMATopologyPolicy - podNUMAExclusive extension.NUMATopologyExclusive + podNUMATopologyPolicy extension.NumaTopologyPolicy + podNUMAExclusive extension.NumaTopologyExclusive numCPUsNeeded int allocation *PodAllocation } @@ -292,7 +292,7 @@ func (p *Plugin) Filter(ctx context.Context, cycleState *framework.CycleState, p // when numa topology policy is set on node, we should maintain the same behavior as before, so we only // set default podNUMAExclusive when podNUMATopologyPolicy is not none if podNUMAExclusive == "" && podNUMATopologyPolicy != "" { - podNUMAExclusive = extension.NUMATopologyExclusiveRequired + podNUMAExclusive = extension.NumaTopologyExclusiveRequired } numaTopologyPolicy := getNUMATopologyPolicy(node.Labels, topologyOptions.NUMATopologyPolicy) numaTopologyPolicy, err := mergeTopologyPolicy(numaTopologyPolicy, podNUMATopologyPolicy) @@ -332,7 +332,7 @@ func (p *Plugin) Filter(ctx context.Context, cycleState *framework.CycleState, p } } - if requiredCPUBindPolicy != "" && numaTopologyPolicy == extension.NUMATopologyPolicyNone { + if requiredCPUBindPolicy != "" && numaTopologyPolicy == extension.NumaTopologyPolicyNone { resourceOptions, err := p.getResourceOptions(cycleState, state, node, pod, requestCPUBind, topologymanager.NUMATopologyHint{}, topologyOptions) if err != nil { return framework.AsStatus(err) @@ -344,7 +344,7 @@ func (p *Plugin) Filter(ctx context.Context, cycleState *framework.CycleState, p } } - if numaTopologyPolicy != extension.NUMATopologyPolicyNone { + if numaTopologyPolicy != extension.NumaTopologyPolicyNone { return p.FilterByNUMANode(ctx, cycleState, pod, node.Name, numaTopologyPolicy, podNUMAExclusive, topologyOptions) } @@ -410,7 +410,7 @@ func (p *Plugin) Reserve(ctx context.Context, cycleState *framework.CycleState, if !status.IsSuccess() { return status } - if !requestCPUBind && numaTopologyPolicy == extension.NUMATopologyPolicyNone { + if !requestCPUBind && numaTopologyPolicy == extension.NumaTopologyPolicyNone { return nil } diff --git a/pkg/scheduler/plugins/nodenumaresource/plugin_test.go b/pkg/scheduler/plugins/nodenumaresource/plugin_test.go index 522627caf..5eb96d403 100644 --- a/pkg/scheduler/plugins/nodenumaresource/plugin_test.go +++ b/pkg/scheduler/plugins/nodenumaresource/plugin_test.go @@ -778,7 +778,7 @@ func TestPlugin_Filter(t *testing.T) { { name: "verify FullPCPUs with NUMA Topology Policy", nodeLabels: map[string]string{ - extension.LabelNUMATopologyPolicy: string(extension.NUMATopologyPolicySingleNUMANode), + extension.LabelNUMATopologyPolicy: string(extension.NumaTopologyPolicySingleNUMANode), }, state: &preFilterState{ requestCPUBind: true, @@ -792,7 +792,7 @@ func TestPlugin_Filter(t *testing.T) { { name: "verify FullPCPUs with NUMA Topology Policy and amplification ratio", nodeLabels: map[string]string{ - extension.LabelNUMATopologyPolicy: string(extension.NUMATopologyPolicySingleNUMANode), + extension.LabelNUMATopologyPolicy: string(extension.NumaTopologyPolicySingleNUMANode), }, nodeAnnotations: map[string]string{ extension.AnnotationNodeResourceAmplificationRatio: `{"cpu": 1.5}`, @@ -809,7 +809,7 @@ func TestPlugin_Filter(t *testing.T) { { name: "verify FullPCPUs with None NUMA Topology Policy and amplification ratio", nodeLabels: map[string]string{ - extension.LabelNUMATopologyPolicy: string(extension.NUMATopologyPolicyNone), + extension.LabelNUMATopologyPolicy: string(extension.NumaTopologyPolicyNone), }, nodeAnnotations: map[string]string{ extension.AnnotationNodeResourceAmplificationRatio: `{"cpu": 1.5}`, @@ -1686,7 +1686,7 @@ func TestFilterWithNUMANodeScoring(t *testing.T) { name: "single numa nodes and select most allocated", node: st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode)). + Label(extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode)). Obj(), numaNodeCount: 2, requestedPod: st.MakePod().Req(map[corev1.ResourceName]string{"cpu": "4", "memory": "40Gi"}).Obj(), @@ -1708,7 +1708,7 @@ func TestFilterWithNUMANodeScoring(t *testing.T) { name: "single numa nodes and select least allocated", node: st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode)). + Label(extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode)). Obj(), numaNodeCount: 2, requestedPod: st.MakePod().Req(map[corev1.ResourceName]string{"cpu": "4", "memory": "40Gi"}).Obj(), @@ -1730,7 +1730,7 @@ func TestFilterWithNUMANodeScoring(t *testing.T) { name: "single numa nodes and only one node can be used", node: st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode)). + Label(extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode)). Obj(), numaNodeCount: 2, requestedPod: st.MakePod().Req(map[corev1.ResourceName]string{"cpu": "4", "memory": "40Gi"}).Obj(), @@ -1752,7 +1752,7 @@ func TestFilterWithNUMANodeScoring(t *testing.T) { name: "restricted numa nodes and select most allocated and preferred", node: st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyRestricted)). + Label(extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyRestricted)). Obj(), numaNodeCount: 4, requestedPod: st.MakePod().Req(map[corev1.ResourceName]string{"cpu": "4", "memory": "40Gi"}).Obj(), @@ -1780,7 +1780,7 @@ func TestFilterWithNUMANodeScoring(t *testing.T) { name: "restricted numa nodes and select least allocated and preferred", node: st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyRestricted)). + Label(extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyRestricted)). Obj(), numaNodeCount: 4, requestedPod: st.MakePod().Req(map[corev1.ResourceName]string{"cpu": "4", "memory": "40Gi"}).Obj(), diff --git a/pkg/scheduler/plugins/nodenumaresource/scoring.go b/pkg/scheduler/plugins/nodenumaresource/scoring.go index 6f74a2a00..62d471662 100644 --- a/pkg/scheduler/plugins/nodenumaresource/scoring.go +++ b/pkg/scheduler/plugins/nodenumaresource/scoring.go @@ -87,7 +87,7 @@ func (p *Plugin) Score(ctx context.Context, cycleState *framework.CycleState, po return 0, nil } - if numaTopologyPolicy == extension.NUMATopologyPolicyNone { + if numaTopologyPolicy == extension.NumaTopologyPolicyNone { return p.scoreWithAmplifiedCPUs(state, nodeInfo, resourceOptions) } diff --git a/pkg/scheduler/plugins/nodenumaresource/scoring_test.go b/pkg/scheduler/plugins/nodenumaresource/scoring_test.go index 91dd4113a..6890c3fc9 100644 --- a/pkg/scheduler/plugins/nodenumaresource/scoring_test.go +++ b/pkg/scheduler/plugins/nodenumaresource/scoring_test.go @@ -59,11 +59,11 @@ func TestNUMANodeScore(t *testing.T) { nodes: []*corev1.Node{ st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), st.MakeNode().Name("test-node-2"). Capacity(map[corev1.ResourceName]string{"cpu": "64", "memory": "128Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), }, numaNodeCounts: map[string]int{ @@ -100,11 +100,11 @@ func TestNUMANodeScore(t *testing.T) { nodes: []*corev1.Node{ st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicyRestricted)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicyRestricted)). Obj(), st.MakeNode().Name("test-node-2"). Capacity(map[corev1.ResourceName]string{"cpu": "64", "memory": "128Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicyRestricted)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicyRestricted)). Obj(), }, numaNodeCounts: map[string]int{ @@ -141,15 +141,15 @@ func TestNUMANodeScore(t *testing.T) { nodes: []*corev1.Node{ st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), st.MakeNode().Name("test-node-2"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), st.MakeNode().Name("test-node-3"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), }, numaNodeCounts: map[string]int{ @@ -196,15 +196,15 @@ func TestNUMANodeScore(t *testing.T) { nodes: []*corev1.Node{ st.MakeNode().Name("test-node-1"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), st.MakeNode().Name("test-node-2"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), st.MakeNode().Name("test-node-3"). Capacity(map[corev1.ResourceName]string{"cpu": "104", "memory": "256Gi"}). - Label(apiext.LabelNUMATopologyPolicy, string(apiext.NUMATopologyPolicySingleNUMANode)). + Label(apiext.LabelNUMATopologyPolicy, string(apiext.NumaTopologyPolicySingleNUMANode)). Obj(), }, numaNodeCounts: map[string]int{ diff --git a/pkg/scheduler/plugins/nodenumaresource/topology_hint.go b/pkg/scheduler/plugins/nodenumaresource/topology_hint.go index 61ba18806..6f1b80e98 100644 --- a/pkg/scheduler/plugins/nodenumaresource/topology_hint.go +++ b/pkg/scheduler/plugins/nodenumaresource/topology_hint.go @@ -27,8 +27,8 @@ import ( "github.com/koordinator-sh/koordinator/pkg/scheduler/frameworkext/topologymanager" ) -func (p *Plugin) FilterByNUMANode(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, policyType apiext.NUMATopologyPolicy, exclusivePolicy apiext.NUMATopologyExclusive, topologyOptions TopologyOptions) *framework.Status { - if policyType == apiext.NUMATopologyPolicyNone { +func (p *Plugin) FilterByNUMANode(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string, policyType apiext.NumaTopologyPolicy, exclusivePolicy apiext.NumaTopologyExclusive, topologyOptions TopologyOptions) *framework.Status { + if policyType == apiext.NumaTopologyPolicyNone { return nil } numaNodes := topologyOptions.getNUMANodes() diff --git a/pkg/scheduler/plugins/nodenumaresource/topology_hint_test.go b/pkg/scheduler/plugins/nodenumaresource/topology_hint_test.go index 5f7ed9a4c..c9828ac09 100644 --- a/pkg/scheduler/plugins/nodenumaresource/topology_hint_test.go +++ b/pkg/scheduler/plugins/nodenumaresource/topology_hint_test.go @@ -34,7 +34,7 @@ func TestReserveByNUMANode(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "test-node", Labels: map[string]string{ - apiext.LabelNUMATopologyPolicy: string(apiext.NUMATopologyPolicySingleNUMANode), + apiext.LabelNUMATopologyPolicy: string(apiext.NumaTopologyPolicySingleNUMANode), }, }, Status: corev1.NodeStatus{ diff --git a/pkg/scheduler/plugins/nodenumaresource/topology_options.go b/pkg/scheduler/plugins/nodenumaresource/topology_options.go index 9fcba14be..85df4be31 100644 --- a/pkg/scheduler/plugins/nodenumaresource/topology_options.go +++ b/pkg/scheduler/plugins/nodenumaresource/topology_options.go @@ -42,7 +42,7 @@ type TopologyOptions struct { ReservedCPUs cpuset.CPUSet `json:"reservedCPUs"` MaxRefCount int `json:"maxRefCount"` Policy *extension.KubeletCPUManagerPolicy `json:"policy,omitempty"` - NUMATopologyPolicy extension.NUMATopologyPolicy `json:"numaTopologyPolicy"` + NUMATopologyPolicy extension.NumaTopologyPolicy `json:"numaTopologyPolicy"` NUMANodeResources []NUMANodeResource `json:"numaNodeResources"` AmplificationRatios map[corev1.ResourceName]extension.Ratio `json:"amplificationRatios,omitempty"` } @@ -210,18 +210,18 @@ func extractNUMANodeResources(nrt *nrtv1alpha1.NodeResourceTopology) []NUMANodeR return numaNodeResources } -func convertToNUMATopologyPolicy(nrt *nrtv1alpha1.NodeResourceTopology) extension.NUMATopologyPolicy { +func convertToNUMATopologyPolicy(nrt *nrtv1alpha1.NodeResourceTopology) extension.NumaTopologyPolicy { for _, policy := range nrt.TopologyPolicies { switch nrtv1alpha1.TopologyManagerPolicy(policy) { case nrtv1alpha1.BestEffort: - return extension.NUMATopologyPolicyBestEffort + return extension.NumaTopologyPolicyBestEffort case nrtv1alpha1.Restricted: - return extension.NUMATopologyPolicyRestricted + return extension.NumaTopologyPolicyRestricted case nrtv1alpha1.SingleNUMANodePodLevel: - return extension.NUMATopologyPolicySingleNUMANode + return extension.NumaTopologyPolicySingleNUMANode } } - return extension.NUMATopologyPolicyNone + return extension.NumaTopologyPolicyNone } func (opts *TopologyOptions) getNUMANodes() []int { diff --git a/pkg/scheduler/plugins/nodenumaresource/util.go b/pkg/scheduler/plugins/nodenumaresource/util.go index 8bba59ad7..2c7bd427a 100644 --- a/pkg/scheduler/plugins/nodenumaresource/util.go +++ b/pkg/scheduler/plugins/nodenumaresource/util.go @@ -51,7 +51,7 @@ func AllowUseCPUSet(pod *corev1.Pod) bool { return (qosClass == extension.QoSLSE || qosClass == extension.QoSLSR) && priorityClass == extension.PriorityProd } -func mergeTopologyPolicy(nodePolicy, podPolicy extension.NUMATopologyPolicy) (extension.NUMATopologyPolicy, error) { +func mergeTopologyPolicy(nodePolicy, podPolicy extension.NumaTopologyPolicy) (extension.NumaTopologyPolicy, error) { if nodePolicy != "" && podPolicy != "" && podPolicy != nodePolicy { return "", errors.New(ErrNotMatchNUMATopology) } @@ -61,9 +61,9 @@ func mergeTopologyPolicy(nodePolicy, podPolicy extension.NUMATopologyPolicy) (ex return nodePolicy, nil } -func getNUMATopologyPolicy(nodeLabels map[string]string, kubeletTopologyManagerPolicy extension.NUMATopologyPolicy) extension.NUMATopologyPolicy { +func getNUMATopologyPolicy(nodeLabels map[string]string, kubeletTopologyManagerPolicy extension.NumaTopologyPolicy) extension.NumaTopologyPolicy { policyType := extension.GetNodeNUMATopologyPolicy(nodeLabels) - if policyType != extension.NUMATopologyPolicyNone { + if policyType != extension.NumaTopologyPolicyNone { return policyType } return kubeletTopologyManagerPolicy diff --git a/pkg/scheduler/plugins/nodenumaresource/util_test.go b/pkg/scheduler/plugins/nodenumaresource/util_test.go index b0eaf2864..b30c27210 100644 --- a/pkg/scheduler/plugins/nodenumaresource/util_test.go +++ b/pkg/scheduler/plugins/nodenumaresource/util_test.go @@ -106,39 +106,39 @@ func Test_getCPUBindPolicy(t *testing.T) { func Test_mergeTopologyPolicy(t *testing.T) { type args struct { - nodePolicy extension.NUMATopologyPolicy - podPolicy extension.NUMATopologyPolicy + nodePolicy extension.NumaTopologyPolicy + podPolicy extension.NumaTopologyPolicy } tests := []struct { name string args args - want extension.NUMATopologyPolicy + want extension.NumaTopologyPolicy wantErr error }{ // TODO: Add test cases. { name: "no policy on pod", args: args{ - nodePolicy: extension.NUMATopologyPolicyRestricted, - podPolicy: extension.NUMATopologyPolicyNone, + nodePolicy: extension.NumaTopologyPolicyRestricted, + podPolicy: extension.NumaTopologyPolicyNone, }, - want: extension.NUMATopologyPolicyRestricted, + want: extension.NumaTopologyPolicyRestricted, }, { name: "policy on pod", args: args{ - nodePolicy: extension.NUMATopologyPolicyRestricted, - podPolicy: extension.NUMATopologyPolicyRestricted, + nodePolicy: extension.NumaTopologyPolicyRestricted, + podPolicy: extension.NumaTopologyPolicyRestricted, }, - want: extension.NUMATopologyPolicyRestricted, + want: extension.NumaTopologyPolicyRestricted, }, { name: "policy on pod not match policy on node", args: args{ - nodePolicy: extension.NUMATopologyPolicyRestricted, - podPolicy: extension.NUMATopologyPolicyBestEffort, + nodePolicy: extension.NumaTopologyPolicyRestricted, + podPolicy: extension.NumaTopologyPolicyBestEffort, }, - want: extension.NUMATopologyPolicyNone, + want: extension.NumaTopologyPolicyNone, wantErr: errors.New(ErrNotMatchNUMATopology), }, } diff --git a/test/e2e/scheduling/nodenumaresource.go b/test/e2e/scheduling/nodenumaresource.go index a30b1814e..da5504ffb 100644 --- a/test/e2e/scheduling/nodenumaresource.go +++ b/test/e2e/scheduling/nodenumaresource.go @@ -473,8 +473,8 @@ var _ = SIGDescribe("NodeNUMAResource", func() { node, err := f.ClientSet.CoreV1().Nodes().Get(context.TODO(), nrt.Name, metav1.GetOptions{}) framework.ExpectNoError(err, "unable to get node") - ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode))) - framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode)) + ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode))) + framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode)) targetNodeName = node.Name ginkgo.By("Create two pods allocate 56% resources of Node, and every Pod allocates 28% resources per NUMA Node") @@ -556,8 +556,8 @@ var _ = SIGDescribe("NodeNUMAResource", func() { node, err := f.ClientSet.CoreV1().Nodes().Get(context.TODO(), nrt.Name, metav1.GetOptions{}) framework.ExpectNoError(err, "unable to get node") - ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode))) - framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode)) + ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode))) + framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode)) targetNodeName = node.Name ginkgo.By("Create two pods allocate 56% resources of Node, and every Pod allocates 28% resources per NUMA Node") @@ -647,8 +647,8 @@ var _ = SIGDescribe("NodeNUMAResource", func() { node, err := f.ClientSet.CoreV1().Nodes().Get(context.TODO(), nrt.Name, metav1.GetOptions{}) framework.ExpectNoError(err, "unable to get node") - ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode))) - framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode)) + ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode))) + framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode)) targetNodeName = node.Name ginkgo.By("Create two pods allocate 56% resources of Node, and every Pod allocates 28% resources per NUMA Node") @@ -736,8 +736,8 @@ var _ = SIGDescribe("NodeNUMAResource", func() { node, err := f.ClientSet.CoreV1().Nodes().Get(context.TODO(), nrt.Name, metav1.GetOptions{}) framework.ExpectNoError(err, "unable to get node") - ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode))) - framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicySingleNUMANode)) + ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode))) + framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicySingleNUMANode)) targetNodeName = node.Name ginkgo.By("Create two pods allocate 40% cpu of one NUMA Node, and 40% memory of one NUMA Node") @@ -814,8 +814,8 @@ var _ = SIGDescribe("NodeNUMAResource", func() { node, err := f.ClientSet.CoreV1().Nodes().Get(context.TODO(), nrt.Name, metav1.GetOptions{}) framework.ExpectNoError(err, "unable to get node") - ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyRestricted))) - framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyRestricted)) + ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyRestricted))) + framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyRestricted)) targetNodeName = node.Name ginkgo.By("Create two pods allocate 60% resources of Node, and every Pod allocates 30% resources per NUMA Node") @@ -898,8 +898,8 @@ var _ = SIGDescribe("NodeNUMAResource", func() { node, err := f.ClientSet.CoreV1().Nodes().Get(context.TODO(), nrt.Name, metav1.GetOptions{}) framework.ExpectNoError(err, "unable to get node") - ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyRestricted))) - framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyRestricted)) + ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyRestricted))) + framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyRestricted)) targetNodeName = node.Name ginkgo.By("Create two pods allocate 40% cpu of one NUMA Node, and 40% memory of one NUMA Node") @@ -977,8 +977,8 @@ var _ = SIGDescribe("NodeNUMAResource", func() { node, err := f.ClientSet.CoreV1().Nodes().Get(context.TODO(), nrt.Name, metav1.GetOptions{}) framework.ExpectNoError(err, "unable to get node") - ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyBestEffort))) - framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NUMATopologyPolicyBestEffort)) + ginkgo.By(fmt.Sprintf("Label node %s with %s=%s", node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyBestEffort))) + framework.AddOrUpdateLabelOnNode(f.ClientSet, node.Name, extension.LabelNUMATopologyPolicy, string(extension.NumaTopologyPolicyBestEffort)) targetNodeName = node.Name ginkgo.By("Create two pods allocate 60% resources of Node, and every Pod allocates 30% resources per NUMA Node")