Skip to content

Commit 887edd2

Browse files
authored
Merge pull request kubernetes#82099 from lmdaly/single-numa-node-policy
Topology Manager Policy: single-numa-node
2 parents 8019ebf + 8ad1b5b commit 887edd2

File tree

15 files changed

+192
-30
lines changed

15 files changed

+192
-30
lines changed

cmd/kubelet/app/options/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
518518
fs.StringVar(&c.CPUManagerPolicy, "cpu-manager-policy", c.CPUManagerPolicy, "CPU Manager policy to use. Possible values: 'none', 'static'. Default: 'none'")
519519
fs.DurationVar(&c.CPUManagerReconcilePeriod.Duration, "cpu-manager-reconcile-period", c.CPUManagerReconcilePeriod.Duration, "<Warning: Alpha feature> CPU Manager reconciliation period. Examples: '10s', or '1m'. If not supplied, defaults to `NodeStatusUpdateFrequency`")
520520
fs.Var(cliflag.NewMapStringString(&c.QOSReserved), "qos-reserved", "<Warning: Alpha feature> A set of ResourceName=Percentage (e.g. memory=50%) pairs that describe how pod resource requests are reserved at the QoS level. Currently only memory is supported. Requires the QOSReserved feature gate to be enabled.")
521-
fs.StringVar(&c.TopologyManagerPolicy, "topology-manager-policy", c.TopologyManagerPolicy, "Topology Manager policy to use. Possible values: 'none', 'best-effort', 'restricted'.")
521+
fs.StringVar(&c.TopologyManagerPolicy, "topology-manager-policy", c.TopologyManagerPolicy, "Topology Manager policy to use. Possible values: 'none', 'best-effort', 'restricted', 'single-numa-node'.")
522522
fs.DurationVar(&c.RuntimeRequestTimeout.Duration, "runtime-request-timeout", c.RuntimeRequestTimeout.Duration, "Timeout of all runtime requests except long running request - pull, logs, exec and attach. When timeout exceeded, kubelet will cancel the request, throw out an error and retry later.")
523523
fs.StringVar(&c.HairpinMode, "hairpin-mode", c.HairpinMode, "How should the kubelet setup hairpin NAT. This allows endpoints of a Service to loadbalance back to themselves if they should try to access their own Service. Valid values are \"promiscuous-bridge\", \"hairpin-veth\" and \"none\".")
524524
fs.Int32Var(&c.MaxPods, "max-pods", c.MaxPods, "Number of Pods that can run on this Kubelet.")

pkg/kubelet/apis/config/types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,17 @@ const (
5555
// watches to observe changes to objects that are in its interest.
5656
WatchChangeDetectionStrategy ResourceChangeDetectionStrategy = "Watch"
5757
// RestrictedTopologyManagerPolicy is a mode in which kubelet only allows
58-
// pods with a single NUMA alignment of CPU and device resources.
58+
// pods with optimal NUMA node alignment for requested resources
5959
RestrictedTopologyManagerPolicy = "restricted"
6060
// BestEffortTopologyManagerPolicy is a mode in which kubelet will favour
6161
// pods with NUMA alignment of CPU and device resources.
6262
BestEffortTopologyManagerPolicy = "best-effort"
6363
// NoneTopologyManager Policy is a mode in which kubelet has no knowledge
6464
// of NUMA alignment of a pod's CPU and device resources.
6565
NoneTopologyManagerPolicy = "none"
66+
// SingleNumaNodeTopologyManager Policy iis a mode in which kubelet only allows
67+
// pods with a single NUMA alignment of CPU and device resources.
68+
SingleNumaNodeTopologyManager = "single-numa-node"
6669
)
6770

6871
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

pkg/kubelet/cm/topologymanager/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ go_library(
88
"policy_best_effort.go",
99
"policy_none.go",
1010
"policy_restricted.go",
11+
"policy_single_numa_node.go",
1112
"topology_manager.go",
1213
],
1314
importpath = "k8s.io/kubernetes/pkg/kubelet/cm/topologymanager",
@@ -45,6 +46,7 @@ go_test(
4546
"policy_best_effort_test.go",
4647
"policy_none_test.go",
4748
"policy_restricted_test.go",
49+
"policy_single_numa_node_test.go",
4850
"topology_manager_test.go",
4951
],
5052
embed = [":go_default_library"],

pkg/kubelet/cm/topologymanager/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ type Policy interface {
2525
//Returns Policy Name
2626
Name() string
2727
//Returns Pod Admit Handler Response based on hints and policy type
28-
CanAdmitPodResult(admit bool) lifecycle.PodAdmitResult
28+
CanAdmitPodResult(hint *TopologyHint) lifecycle.PodAdmitResult
2929
}

pkg/kubelet/cm/topologymanager/policy_best_effort.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (p *bestEffortPolicy) Name() string {
3636
return PolicyBestEffort
3737
}
3838

39-
func (p *bestEffortPolicy) CanAdmitPodResult(admit bool) lifecycle.PodAdmitResult {
39+
func (p *bestEffortPolicy) CanAdmitPodResult(hint *TopologyHint) lifecycle.PodAdmitResult {
4040
return lifecycle.PodAdmitResult{
4141
Admit: true,
4242
}

pkg/kubelet/cm/topologymanager/policy_best_effort_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,24 @@ import (
2323
func TestPolicyBestEffortCanAdmitPodResult(t *testing.T) {
2424
tcases := []struct {
2525
name string
26-
admit bool
26+
hint TopologyHint
2727
expected bool
2828
}{
2929
{
30-
name: "Affinity is set to false in topology hints",
31-
admit: false,
30+
name: "Preferred is set to false in topology hints",
31+
hint: TopologyHint{nil, false},
3232
expected: true,
3333
},
3434
{
35-
name: "Affinity is set to true in topology hints",
36-
admit: true,
35+
name: "Preferred is set to true in topology hints",
36+
hint: TopologyHint{nil, true},
3737
expected: true,
3838
},
3939
}
4040

4141
for _, tc := range tcases {
4242
policy := NewBestEffortPolicy()
43-
admit := tc.admit
44-
result := policy.CanAdmitPodResult(admit)
43+
result := policy.CanAdmitPodResult(&tc.hint)
4544

4645
if result.Admit != tc.expected {
4746
t.Errorf("Expected Admit field in result to be %t, got %t", tc.expected, result.Admit)

pkg/kubelet/cm/topologymanager/policy_none.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (p *nonePolicy) Name() string {
3636
return PolicyNone
3737
}
3838

39-
func (p *nonePolicy) CanAdmitPodResult(admit bool) lifecycle.PodAdmitResult {
39+
func (p *nonePolicy) CanAdmitPodResult(hint *TopologyHint) lifecycle.PodAdmitResult {
4040
return lifecycle.PodAdmitResult{
4141
Admit: true,
4242
}

pkg/kubelet/cm/topologymanager/policy_none_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,24 @@ func TestName(t *testing.T) {
4141
func TestPolicyNoneCanAdmitPodResult(t *testing.T) {
4242
tcases := []struct {
4343
name string
44-
admit bool
44+
hint TopologyHint
4545
expected bool
4646
}{
4747
{
48-
name: "Affinity is set to false in topology hints",
49-
admit: false,
48+
name: "Preferred is set to false in topology hints",
49+
hint: TopologyHint{nil, false},
5050
expected: true,
5151
},
5252
{
53-
name: "Affinity is set to true in topology hints",
54-
admit: true,
53+
name: "Preferred is set to true in topology hints",
54+
hint: TopologyHint{nil, true},
5555
expected: true,
5656
},
5757
}
5858

5959
for _, tc := range tcases {
6060
policy := NewNonePolicy()
61-
admit := tc.admit
62-
result := policy.CanAdmitPodResult(admit)
61+
result := policy.CanAdmitPodResult(&tc.hint)
6362

6463
if result.Admit != tc.expected {
6564
t.Errorf("Expected Admit field in result to be %t, got %t", tc.expected, result.Admit)

pkg/kubelet/cm/topologymanager/policy_restricted.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func (p *restrictedPolicy) Name() string {
3636
return PolicyRestricted
3737
}
3838

39-
func (p *restrictedPolicy) CanAdmitPodResult(admit bool) lifecycle.PodAdmitResult {
40-
if !admit {
39+
func (p *restrictedPolicy) CanAdmitPodResult(hint *TopologyHint) lifecycle.PodAdmitResult {
40+
if !hint.Preferred {
4141
return lifecycle.PodAdmitResult{
4242
Admit: false,
4343
Reason: "Topology Affinity Error",

pkg/kubelet/cm/topologymanager/policy_restricted_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,24 @@ import (
2323
func TestPolicyRestrictedCanAdmitPodResult(t *testing.T) {
2424
tcases := []struct {
2525
name string
26-
admit bool
26+
hint TopologyHint
2727
expected bool
2828
}{
2929
{
30-
name: "Affinity is set to false in topology hints",
31-
admit: false,
30+
name: "Preferred is set to false in topology hints",
31+
hint: TopologyHint{nil, false},
3232
expected: false,
3333
},
3434
{
35-
name: "Affinity is set to true in topology hints",
36-
admit: true,
35+
name: "Preferred is set to true in topology hints",
36+
hint: TopologyHint{nil, true},
3737
expected: true,
3838
},
3939
}
4040

4141
for _, tc := range tcases {
4242
policy := NewRestrictedPolicy()
43-
admit := tc.admit
44-
result := policy.CanAdmitPodResult(admit)
43+
result := policy.CanAdmitPodResult(&tc.hint)
4544

4645
if result.Admit != tc.expected {
4746
t.Errorf("Expected Admit field in result to be %t, got %t", tc.expected, result.Admit)

0 commit comments

Comments
 (0)