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 <kklues@nvidia.com>
This commit is contained in:
Louise Daly 2019-08-30 07:12:49 +01:00
parent f6c085f60e
commit 8ad1b5ba3b
2 changed files with 41 additions and 0 deletions

View File

@ -231,6 +231,11 @@ func (m *manager) calculateAffinity(pod v1.Pod, container v1.Container) Topology
if !hint.Preferred {
preferred = false
}
// Special case PolicySingleNumaNode to only prefer hints where
// all providers have a single NUMA affinity set.
if m.policy != nil && m.policy.Name() == PolicySingleNumaNode && hint.NUMANodeAffinity.Count() > 1 {
preferred = false
}
numaAffinities = append(numaAffinities, hint.NUMANodeAffinity)
}
}

View File

@ -111,6 +111,7 @@ func TestCalculateAffinity(t *testing.T) {
name string
hp []HintProvider
expected TopologyHint
policy Policy
}{
{
name: "TopologyHint not set",
@ -655,10 +656,45 @@ func TestCalculateAffinity(t *testing.T) {
Preferred: true,
},
},
{
name: "Special cased PolicySingleNumaNode for single NUMA hint generation",
policy: NewSingleNumaNodePolicy(),
hp: []HintProvider{
&mockHintProvider{
map[string][]TopologyHint{
"resource1": {
{
NUMANodeAffinity: NewTestSocketMask(0, 1),
Preferred: true,
},
},
"resource2": {
{
NUMANodeAffinity: NewTestSocketMask(0),
Preferred: true,
},
{
NUMANodeAffinity: NewTestSocketMask(1),
Preferred: true,
},
{
NUMANodeAffinity: NewTestSocketMask(0, 1),
Preferred: false,
},
},
},
},
},
expected: TopologyHint{
NUMANodeAffinity: NewTestSocketMask(0),
Preferred: false,
},
},
}
for _, tc := range tcases {
mngr := manager{
policy: tc.policy,
hintProviders: tc.hp,
numaNodes: numaNodes,
}