Skip to content

Commit 8ad1b5b

Browse files
lmdalyklueska
andcommitted
Single-numa-node Topology Manager bug fix
Added one off fix for single-numa-node policy to correctly reject pod admission on a resource allocation that spans NUMA nodes Co-authored-by: Kevin Klues <[email protected]>
1 parent f6c085f commit 8ad1b5b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

pkg/kubelet/cm/topologymanager/topology_manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ func (m *manager) calculateAffinity(pod v1.Pod, container v1.Container) Topology
231231
if !hint.Preferred {
232232
preferred = false
233233
}
234+
// Special case PolicySingleNumaNode to only prefer hints where
235+
// all providers have a single NUMA affinity set.
236+
if m.policy != nil && m.policy.Name() == PolicySingleNumaNode && hint.NUMANodeAffinity.Count() > 1 {
237+
preferred = false
238+
}
234239
numaAffinities = append(numaAffinities, hint.NUMANodeAffinity)
235240
}
236241
}

pkg/kubelet/cm/topologymanager/topology_manager_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func TestCalculateAffinity(t *testing.T) {
111111
name string
112112
hp []HintProvider
113113
expected TopologyHint
114+
policy Policy
114115
}{
115116
{
116117
name: "TopologyHint not set",
@@ -655,10 +656,45 @@ func TestCalculateAffinity(t *testing.T) {
655656
Preferred: true,
656657
},
657658
},
659+
{
660+
name: "Special cased PolicySingleNumaNode for single NUMA hint generation",
661+
policy: NewSingleNumaNodePolicy(),
662+
hp: []HintProvider{
663+
&mockHintProvider{
664+
map[string][]TopologyHint{
665+
"resource1": {
666+
{
667+
NUMANodeAffinity: NewTestSocketMask(0, 1),
668+
Preferred: true,
669+
},
670+
},
671+
"resource2": {
672+
{
673+
NUMANodeAffinity: NewTestSocketMask(0),
674+
Preferred: true,
675+
},
676+
{
677+
NUMANodeAffinity: NewTestSocketMask(1),
678+
Preferred: true,
679+
},
680+
{
681+
NUMANodeAffinity: NewTestSocketMask(0, 1),
682+
Preferred: false,
683+
},
684+
},
685+
},
686+
},
687+
},
688+
expected: TopologyHint{
689+
NUMANodeAffinity: NewTestSocketMask(0),
690+
Preferred: false,
691+
},
692+
},
658693
}
659694

660695
for _, tc := range tcases {
661696
mngr := manager{
697+
policy: tc.policy,
662698
hintProviders: tc.hp,
663699
numaNodes: numaNodes,
664700
}

0 commit comments

Comments
 (0)