Fixed bug in TopologyManager with SingleNUMANode Policy

This patch fixes an issue where best-effort pods were not admitted
to the node if the single-numa-node policy was set.

This was because the Admit policy in single-numa-node policy does
not admit any pod where the hint is anything but single NUMA node. The 'best hint' in this case is {<set bits for num. Numa Nodes on machine>, true}
So on a machine with 2 NUMA nodes the best hint for a best-effort pod is {11,true} as best-effort pods have no Topology preferences.

The single-numa-node policy fails any pod with a not preferred hint OR a hint where > 1 bits are set, thus the above example resulting in termintaed pods with a Topology Affinity Error.

This is a short term fix for the single-numa-node policy, as there will be code refactoring for the 1.17 release.
This commit is contained in:
Louise Daly 2019-10-11 07:00:37 +01:00
parent 017842d49d
commit a353247d44
3 changed files with 19 additions and 11 deletions

View File

@ -37,7 +37,7 @@ func (p *singleNumaNodePolicy) Name() string {
}
func (p *singleNumaNodePolicy) CanAdmitPodResult(hint *TopologyHint) lifecycle.PodAdmitResult {
if !hint.Preferred || hint.NUMANodeAffinity.Count() > 1 {
if !hint.Preferred {
return lifecycle.PodAdmitResult{
Admit: false,
Reason: "Topology Affinity Error",

View File

@ -31,16 +31,6 @@ func TestPolicySingleNumaNodeCanAdmitPodResult(t *testing.T) {
hint: TopologyHint{nil, false},
expected: false,
},
{
name: "NUMANodeAffinity has multiple NUMA Nodes masked in topology hints",
hint: TopologyHint{NewTestBitMask(0, 1), true},
expected: false,
},
{
name: "NUMANodeAffinity has one NUMA Node masked in topology hints",
hint: TopologyHint{NewTestBitMask(0), true},
expected: true,
},
}
for _, tc := range tcases {

View File

@ -857,6 +857,24 @@ func TestAdmit(t *testing.T) {
hp: []HintProvider{},
expected: true,
},
{
name: "QOSClass set as BestEffort. single-numa-node Policy. No Hints.",
qosClass: v1.PodQOSBestEffort,
policy: NewRestrictedPolicy(),
hp: []HintProvider{
&mockHintProvider{},
},
expected: true,
},
{
name: "QOSClass set as BestEffort. Restricted Policy. No Hints.",
qosClass: v1.PodQOSBestEffort,
policy: NewRestrictedPolicy(),
hp: []HintProvider{
&mockHintProvider{},
},
expected: true,
},
{
name: "QOSClass set as Guaranteed. BestEffort Policy. Preferred Affinity.",
qosClass: v1.PodQOSGuaranteed,