From 0e7928edce5de164b8f162d51ebeb849873847d3 Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Tue, 12 Oct 2021 09:24:05 +0000 Subject: [PATCH] Add new CPUManager policy option for "distribute-cpus-across-numa" This commit only adds the option to the policy options framework. A subsequent commit will add the logic to utilize it. The KEP describing this new option can be found here: https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2902-cpumanager-distribute-cpus-policy-option Signed-off-by: Kevin Klues --- pkg/kubelet/cm/cpumanager/policy_options.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pkg/kubelet/cm/cpumanager/policy_options.go b/pkg/kubelet/cm/cpumanager/policy_options.go index 84461cf1b94..64b14833e58 100644 --- a/pkg/kubelet/cm/cpumanager/policy_options.go +++ b/pkg/kubelet/cm/cpumanager/policy_options.go @@ -26,13 +26,15 @@ import ( ) const ( - // FullPCPUsOnlyOption is the name of the CPU Manager policy option - FullPCPUsOnlyOption string = "full-pcpus-only" + FullPCPUsOnlyOption string = "full-pcpus-only" + DistributeCPUsAcrossNUMAOption string = "distribute-cpus-across-numa" ) var ( - alphaOptions = sets.NewString() - betaOptions = sets.NewString( + alphaOptions = sets.NewString( + DistributeCPUsAcrossNUMAOption, + ) + betaOptions = sets.NewString( FullPCPUsOnlyOption, ) stableOptions = sets.NewString() @@ -64,6 +66,9 @@ type StaticPolicyOptions struct { // any possible naming scheme will lead to ambiguity to some extent. // We picked "pcpu" because it the established docs hints at vCPU already. FullPhysicalCPUsOnly bool + // Flag to evenly distribute CPUs across NUMA nodes in cases where more + // than one NUMA node is required to satisfy the allocation. + DistributeCPUsAcrossNUMA bool } func NewStaticPolicyOptions(policyOptions map[string]string) (StaticPolicyOptions, error) { @@ -80,6 +85,12 @@ func NewStaticPolicyOptions(policyOptions map[string]string) (StaticPolicyOption return opts, fmt.Errorf("bad value for option %q: %w", name, err) } opts.FullPhysicalCPUsOnly = optValue + case DistributeCPUsAcrossNUMAOption: + optValue, err := strconv.ParseBool(value) + if err != nil { + return opts, fmt.Errorf("bad value for option %q: %w", name, err) + } + opts.DistributeCPUsAcrossNUMA = optValue default: // this should never be reached, we already detect unknown options, // but we keep it as further safety.